Results 1 to 2 of 2

Thread: Linux on the go!

Hybrid View

  1. #1
    Very good friend of the forum Virchanza's Avatar
    Join Date
    Jan 2010
    Posts
    863

    Default Linux on the go!

    OK so I was heading away on holidays and I wanted to keep my luggage to a minimum. I didn't want to bring my laptop with me, but I still wanted to have full access to all my files, my programs, my entire operating system.



    So I figured hey, I can take the hard disk out of my laptop, stick it in a USB enclosure, and then just bring the hard disk around with me. The idea was I could take my hard disk and connect it into any computer and then just boot off it.



    Before I went away, my Grub entry for booting Linux was as follows:



    Code:
    title         Main Linux OS
    
    root          (hd0,2)
    
    kernel        /boot/vmlinuz-2.6.31-17-generic root=/dev/sda3 ro quiet splash
    
    initrd        /boot/initrd.img-2.6.31-17-generic
    
    quiet
    So I went away on holidays and I hooked my hard disk up to a computer via USB and then booted off it. The Grub menu appeared, and I simply hit Enter to boot into Linux. It booted up fine and everything worked.



    But with some computers, there was complications.



    If you look at my Grub entry above, you'll see that it makes two references to the partition on which Linux resides:



    Reference 1: (hd0,2)

    Reference 2: /dev/sda3



    The first reference never seems to cause any problems, reason being that "hd0" will always refer to the hard disk which Grub has just booted off (or at least that's how it seems).



    The second reference however can cause problems. On some of the computers I used, the Grub menu appeared, I hit Enter, and then Linux failed to load. The problem was that my own hard disk was being given the designation of sdb instead of sda. I had a workaround for this. When the Grub menu appeared, I would press E to edit the entry, and I would change the following line:



    Code:
    kernel        /boot/vmlinuz-2.6.31-17-generic root=/dev/sda3 ro quiet splash
    to:



    Code:
    kernel        /boot/vmlinuz-2.6.31-17-generic root=/dev/sdb3 ro quiet splash
    After I made that change, I pressed B to boot up Linux, and it booted up fine. (I didn't need to change root (hd0,2) to root (hd1,2)).



    Here's what my fstab file looked like:



    Code:
    proc              /proc           proc         defaults                     0       0
    
    /dev/sda3         /               ext3         relatime,errors=remount-ro   0       1
    As you can see, my Linux partition was referred to as "/dev/sda3" in my fstab file. Even on the computers where my hard disk was designated as sdb at boot-time, this fstab entry didn't cause any problems (you'd think I would have had to change it to sdb!). Even though my own Linux partition was designated as sdb3 at boot-time, it appears as though it was known as sda3 by the time it came to mounting the root filesystem. (Don't ask me, I haven't got a clue either).



    I wanted to find the best way of making my Linux installation fully portable so that I could bring my hard disk around and boot it on different computers.



    ...and that's when I discovered UUID's



    UUID's solve the problem of hard disks being given different designations on different systems (e.g. sda VS sdb VS sdc). Every Linux partition (e.g. ext2 ext3 ext4) has its own unique UUID. You can use this UUID to refer to the partition instead of using "/dev/sda3". To make use of UUID's, I had to change two files on my hard disk: my Grub file and my fstab file. I changed them as follows.



    Here's my Grub file:

    Code:
    title           Main Linux OS
    
    uuid            8c5055d5-75e5-5f57-9585-5a5525551524
    
    kernel          /boot/vmlinuz-2.6.31-17-generic root=UUID=8c5055d5-75e5-5f57-9585-5a5525551524 ro quiet splash
    
    initrd          /boot/initrd.img-2.6.31-17-generic
    
    quiet
    And here's my fstab:

    Code:
    proc                                       /proc           proc         defaults                     0       0
    
    UUID=8c5055d5-75e5-5f57-9585-5a5525551524  /               ext3         relatime,errors=remount-ro   0       1
    After I made those changes, it booted every time on every computer. Notice, in these two files, that there's no reference to the hard disk number or even the partition number. You can move this Linux partition around however you like, you can change the partition order on your current hard disk, or you can move the Linux partition to a different hard disk. Your Linux installation should still boot right away without a problem because it's working off the UUID of the partition.



    Anyway I thought this was pretty cool when I got it working right, and I just had to share it... this is the kind of stuff that makes me really love Linux



    If you wanna find out the UUID's of your partitions, do the following:

    Code:
    sudo blkid | sort


    Also, another little cool thing I found is the "/dev/disk" folder. Navigate into that folder and take a look around!

  2. #2
    Developer balding_parrot's Avatar
    Join Date
    May 2007
    Posts
    3,399

    Default Re: Linux on the go!

    Although not really a BackTrack tutorial, I am going to allow this one (but only just).
    But please in future make them more closely BackTrack howto's.

Similar Threads

  1. If you are new to Back Track or Linux read this thread.
    By Archangel-Amael in forum Beginners Forum
    Replies: 95
    Last Post: 04-24-2011, 07:57 PM
  2. installing linux driver for my wireless card
    By leeyj4951 in forum Beginners Forum
    Replies: 4
    Last Post: 04-24-2010, 03:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •