Linux Boot Issues when adding drives


Linux Boot Issues when adding drives Problem: Linux is set up using some SCSI driver (SATA, USB, or honest to goodness SCSI) and working properly. A drive is added to the system which changes the drive order, so the system tries to find its root and boot images in the wrong spot (the new drive). I have had this problem under the following scenarios:

  • System working just fine with internal SATA RAID array. Added an external SCSI RAID array (for additional data storage) and it tried to boot off the external RAID array. Had to go in and rebuild the modules priority file in the initrd. This solution would have solved that.
  • Another system was up and running using a 3Ware SATA RAID 1 controller. Added another of the exact same model, and put a couple of extra drives. Since it uses the same module, I'm not sure how to tell it which one is first. This solves that issue.
  • Third system uses a 3Ware SATA RAID 1 for its primary, but I set up the SATA controller on the motherboard to allow me to insert drives that I wanted to get data off of. When I insert the drives, it randomly chooses the 3Ware or the motherboard, depending on what mood it is in. Again, this solution fixes that.

All of the above are being done on Debian Etch.

Solution: Use UUID or LABEL instead of the old /dev/sdx syntax. As a quick aside, the UUID is simply a long, randomly generated number. UUID stands for Universally Unique Identifier. Using UUID's for managing disk partitions is fairly new (see next paragraph), and the implementation is not all that great yet. It is the wave of the future, but be prepared to be on the "bleeding edge" if you are using a distro that has not tested it well yet. I'd stick with LABELS for a while.

Note: UUID and Labels are not just for booting. They can work in many applications where you would normally use the /dev/sdx syntax. However, we are just concerned with fixing the current problem.

UUID only works on the newer kernels, appearantly. It will not work under a standard Etch install (though using the latest kernel from backports.org will do the trick). Ubuntu 7.x, and any other setup that uses the newer kernels will, however.

I like Debian, so until the kernel is updated, this will not work for me. However, I tried using labels, and they work just fine. Below are the instructions for both UUID and Labels; they are the same except for syntax. Following is assuming ext2/3 file system, and that sda1 is your root partition with /boot as a directory of it. To avoid confusion, I use long number to specify where you actually type (copy/paste) the UUID, and root where you would type (copy/paste) the LABEL (since root is what I name my root partition, having little imagination).

  1. Get a copy of Knoppix to boot into your system and fix things if this messes up.
  2. Check the UUID or LABEL for your disk partition.
    1. /lib/udev/vol_id /dev/sda1 | grep UUID (replace /dev/sda1 with the correct partition)
    2. e2label /dev/sda1 or sudo dumpe2fs /dev/sda1 | grep -i '\(uuid\)\|\(label\)'
      1. Note: I found that under Lenny, the correct command is sudo dumpe2fs /dev/sda1 | grep -i '\(uuid\)\|\(volume name\)' . Be Careful, I have not completely tested this yet.
  3. Create a UUID or LABEL for your disk partition if it does not have one. Warning If your system already uses UUID or LABEL to mount volumes, and you change it, you will totally screw up your system. Don't do this unless you knowyour system is not using LABEL or UUID already.
    1. e2label /dev/sda1 root or tune2fs -L root /dev/sda1
    2. tune2fs -U random /dev/sda1 (for UUID)
    3. Go back to the previous step, Check the UUID or LABEL for your disk partition, and verify the labels/UID worked.
    4. If you like, label/UUID the rest of your partitions.
  4. Backup, then edit /boot/grub/menu.lst
    1. To test
      1. find the first stanza in your kernel list and duplicate it
      2. change root=/dev/sda1 ro to read root=label=root ro
      3. change title line to read test or something
      4. reboot the system. If this all works, go to the next stage; otherwise, reboot and select the second kernel, then fix any problems.
    2. find the line that says # kopt=. It most likely says # kopt=/dev/sda1 ro or something like that. Yes, you leave the # in front of the line. Change this to say either
      1. # kopt=LABEL=root ro
      2. # kopt=UUID=long number ro
    3. save the file
    4. Execute command update-grub (this will recreate menu.lst)
  5. Backup, then edit /etc/fstab
    1. Find where root is mounted, say /dev/sda1, and change it to read either
      1. LABEL=root / ext3 defaults,errors=remount-ro 0 1
      2. UUID=long number / ext3 defaults,errors=remount-ro 0 1
    2. if you have other partitions, do the same with them. Don't try this on the pseudo partitions, and don't worry about your swap

Sample stanza in /boot/grub/menu.lst

title           test
root            (hd0,0)
kernel          /boot/xen-3.2-1-amd64.gz
module          /boot/vmlinuz-2.6.26-1-xen-amd64 root=UUID=bca0aab0-ca4f-46cf-b93a-26e2dfd7f14d ro console=tty0
module          /boot/initrd.img-2.6.26-1-xen-amd64

Sample kopt line in /boot/grub/menu.lst you must leave the pound sign as the first character

# kopt=root=UUID=bca0aab0-ca4f-46cf-b93a-26e2dfd7f14d ro

Sample line for mounting / from /etc/fstab. Note that in this case, we are using the label to mount the drive. The commented line below uses the UUID, and the third line is the original.

LABEL=root       /               ext3    defaults,errors=remount-ro 0       1
#UUID=bca0aab0-ca4f-46cf-b93a-26e2dfd7f14d   /               ext3    defaults,errors=remount-ro 0       1

Linux Boot Issues when adding drives

Last update:
2013-04-30 02:27
Author:
Rod
Revision:
1.2
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category

Tags