Archive

Archive for December, 2010

Rackspace cloud servers – linux rescue mode

December 30, 2010 1 comment

This post is regarding rescue mode in Rackspace cloud servers, particularly for Linux systems.  Normally, we can find everything at Rackspace cloud servers knowledge base, but it seems there is no article available on Linux rescue environment there, and somebody who hasn’t worked on Linux much, rescue environment might become daunting.  So, I decided to write one here.

When do I require rescue environment?

First of all, you only require rescue environment when your system has become non-bootable, means something is terrible wrong with the server, it could be either file system corruption, boot files corruption, configuration errors.  There are lots of cases where linux system can become non-bootable.  Most of the times, if linux system encounters any problem during booting time, it will drop you to a maintenance mode environment where you can login with your root password and check for any errors.  The problem with maintenance mode are a) your system is read-only b) most of the services are not working, like SSH. c) you can’t copy your data over the network. d) you have to work on console which is slower than SSH login.

So, in such cases you can always bring your server up in rescue environment and debug the issues with SSH login from your desktop and copy any files from your server for recovery purposes as well.

What is Rescue mode?

Rescue mode grants you full access to your non-bootable server’s filesystem. You can use it to modify problem in configuration files or to use scp to copy data from the slice to a remote location.

For somebody familiar with Linux, rescue mode is similar to booting into single-user mode with networking enabled.

Getting your server into Rescue mode.

You have to login into your cloud servers account at https://manage.rackspaceloud.com.  Click on Hosting->Cloud Servers, then you can click on the server which you want to enable rescue mode.  Once you click on your server, you will see a screen similar to below image, where you can click the Rescue button.

Rescue Mode button

Once you click the Rescue button, below message will pop out.

rescue mode button

Click on the Rescue mode button

As you can see Rackspace has done well by putting everything in the above message.  It pretty much explains the whole rescue process there, but as always people are too quick to click enter and never read it.  So, I have put the snapshot so that you will give it a read while you are it. :)

Notice that rescue environment is limited to 90 minutes only.  So you only have 3 hours to fix your server or copy the data.  Of course, you can go back again into rescue mode as many times as possible.  I guess, this time limit is there only to prevent misuse of rescue environment.

cloud servers rescue mode building

cloud server rescue mode building progress

cloud server rescue mode build done

cloud server rescue mode build done

Once the rescue mode build process is complete, your screen should look similar to above, and your system is in rescue mode.  You will receive an e-mail from Rackspace cloud support with new password to login into rescue mode, like below.

rackspace cloud server rescue mode password

rescue mode password e-mail

Once you have received the new password, you can actually SSH into your public IP and use new password to login into rescue environment.  Below is the screen where I logged into my rescue environment.

rackspace cloud server rescue environment

rackspace cloud server rescue environment disks

As you can see fidk -l command in rescue environment show three disks.

/dev/sdb1 = this is the rescue disk
/dev/sda1 = this is our server disk, size of 10.2GB, my current server disk size.  It could be different if your server has a larger disk.
/dev/sda2  =  this is swap disk, as you can see from the size of 536MB

Now, what we need to do is mount /dev/sda1 to a directory into rescue environment.  Once /dev/sda1 is mounted to for example /mnt.  Then you can access all your files under /mnt

Likewise, if you made some wrong entries into your /etc/fstab and due to which your system is not booting.  Now in rescue environment you can edit your fstab at  /mnt/etc/fstab, and make the required corrections.

mounting the /dev/sda1 under rescue environment

eiding the fstab under rescue environment

That’s it!  Once you are done editing/fixing, then you can exit the rescue mode by clicking “Exit Rescue Mode” link in your server details page.

Please post any comments if this helped you anyway and also if you see some issues and some things are needed to changed.  Cheers!

Categories: cloud servers, Linux

Assimilating the change

December 27, 2010 Leave a comment

Today one of my friend had this post on her blog and it relates at many levels to what i’ve been thinking and feeling over the past two months or so.  I came to UK on 4th Oct and also i don’t have my music, books, or even my laptop with me, so had lots of time to burn ….. First of the few things you notice when you come to any new country is a bit of resistance, not particularly from local firangi people, but more from your very own people who have been there for many years… then comes all the other things tv, music, culture, everything… you don’t see your actors on tv whom you have been following up from your childhood, you don’t see the same hosts/presenters on tv and also nobody has any idea what you are going through.  Everything you do or say feels like being judged.  First you start to follow the new culture, music, and TV just to grasp it all and feel how things are here, just out of curiosity, some things you like and some not but then you have to follow these things just so you can socialize and engage with your peers. I think its very difficult changing countries, its very drastic change and totally shakes up your life for a while.

Also there is conflict of sensibilities, I don’t know what places they have visited during their few weeks holidays to India, but they certainly have a very different view of how things are there than me. For them everything is just broke or bad or corrupt about India. I know there are problems but not as bad as they project it to be or think it to be. First you try to defend and clear their wrong assumptions by giving explanations, but you are easily overthrown by shear number of people against you and then finally you give in and let it go, go silent, stop being bothered of what they think, because in your heart you know that they are wrong at many levels.

Well, changing countries is hard and at times it can get really lonely and you start thinking what am I doing here and you seems to be torn apart between the two worlds, the one you have just left behind and have loved it and the one which you just entered and holds your future and you want to be in it, and I guess this is the point which breads the thoughts of going back someday, buying a big house, and staying happily ever after there.  I guess it becomes even more harder if your family not with you.  Also this may make you realize that its you and your life what matters everything else is just materialistic and doesn’t matter any more.

Also, I think I have been very lucky to have my relatives here, good relatives I should say, who helped me a lot during first phase of this transition by providing a lot of moral support, otherwise without them it would have been very lonely and sad, and I cannot thank them enough for this.

Don’t know if anybody else had the similar experience.  These days I care less about problems of life and more of my family and being happy and trying to be carefree and let it go and enjoy life kind of attitude but I guess mind doesn’t stop thinking hence this post.

Like my friend i’m also going to wait and watch how it all turns out from the first phase to the last one. If i meet someone later who have come through same paths as me i will certainly give him or her a big hug, because at this phase of the transition you really need one.

Enough of my rants now….and I will end this post on inspiring words of my friend.

“change is for good too…the sooner u accept it postively, the better n faster the transition is”

Categories: Thoughts Tags: ,

Satinder Sartaj – Sai and other compositions

December 12, 2010 1 comment

One of the best compositions from Sartaj, really love this one along with all the other songs by Sartaj.  He has been giving so many good numbers, looking forward to listening to them all.  Hope you will like it.

Below are some more good songs from him

Categories: Songs Tags: ,

Extract pages from a PDF file in Ubuntu 10.10

December 11, 2010 1 comment

Yesterday I got an odd task at hand. One of senior members in my team and really amazing person I must say, e-mailed me few PDFs of Linux Journal from past months, and asked if I could extract the troubleshooting articles from them and compile them as a one single pdf, which we can keep for future references, plus this was needed as he has promised the other team to do this in return of the PDFs he gets from their subscription :)

So, then I begin my search on tools and ways to do this in Ubuntu 10.10.  Yes, for the past 3-4 weeks Ubuntu has been my main operating system, not like earlier when I have always kept one windows machine with me. This time I thought lets move completely to Linux without taking any whatsoever help from windows, and let me tell you its been really going great, even better than windows. But more on this later.

Quick Google search revealed that there are a number of ways to extract a range of pages from PDF files. There are PDF related toolkits for doing it or you can use Ghostscript directly for command line option, and also there are graphic applications as well. So I decided to put them all together here.

First: Use of poppler-tools and psutils.
One can extract a range of pages from a larger PDF file using these tools. Like, if you want to extract pages 18–22 of the PDF file one_big_file.pdf, you could use the following command:

$ pdftops one-big-file.pdf - | psselect -p18-22 | ps2pdf - new-file-name.pdf

The pdftops command converts the PDF file to PostScript and psselect command selects the relevant pages from the PostScript, then ps2pdf command converts the selected PostScript into a new PDF file.

Second:Using pdftk toolkit
For example, to extract pages 18-22 from a big PDF file.

Splitting pages from one big file:
$ pdftk A=one_big_file.pdf cat A18-22 new_file_name.pdf

Joining pages into one big file:
$ pdftk file1.pdf file2.pdf cat output single_big_file.pdf

for more options like attaching files, filling forms, etc., check this link

Third:Using Ghostscript
Use of Ghostscript, which unlike pdftk is installed nearly everywhere and you’ve been using it in the last command anyway, goes like following.

$ gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
-dFirstPage=18 -dLastPage=22 \
-sOutputFile=new_file_name.pdf one_big_file.pdf

Merging files with Ghostscript

$ gs -q -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
-sOutputFile=one_big_file.pdf file1.pdf file2.pdf file3.pdf

When using Ghostscript to combine PDF files, you can add any PDF-related option to the command line. For example, you can compress the file, target it to an eBook reader, or encrypt it. See the Ghostscript documentation for more information.

Conclusion
Regarding speed and efficiency of the processing and more important the quality of the output file, the first method above is for sure the worst of the three. The conversion of the original PDF to PostScript and back to PDF (known as “refrying”) is very unlikely to completely preserve advanced PDF features (such as transparency information, font hinting, overprinting information, color profiles, trapping instructions, etc.).

The 3rd method uses Ghostscript only (which the 1st one uses anyway, because ps2pdf is nothing more than a wrapper script around a more or less complicated Ghostscript command line. The 3rd method also preserves all the important PDF objects on your pages as they are, without any “roundtrip” conversions.

Little extra
The only drawback of the 3rd method is that it’s a longer and more complicated command line to type. But you can overcome that drawback if you save it as a bash function. Just put these lines in your ~/.bashrc file:

function pdf-extract()
{
# this function uses 3 arguments:
# $1 is the first page of the range to extract
# $2 is the last page of the range to extract
# $3 is the input file
# output file will be named "inputfile_pXX-pYY.pdf"
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
-dFirstPage=${1} \
-dLastPage=${2} \
-sOutputFile=${3%.pdf}_page${1}_to_page${2}.pdf \
${3}
}

Now you only need to type (after starting a new copy bash or sourcing .bashrc) the following:
$ pdf-extract 22 36 inputfile.pdf
which will result in the file inputfile_p22-p36.pdf in the same directory as the input file.

For a graphic optionhttp://sourceforge.net/projects/pdfshuffler/

Categories: Linux, Ubuntu 10.10 Tags: , ,
Follow

Get every new post delivered to your Inbox.