1

I have a CentOS installation on a portable USB stick, with a grub2 installation on it's first partition. The system can boot when there are no internal hard drives plugged into a machine, but fails if any hard drive is plugged in.

I want my OS, running off the USB stick, to be mounted as /dev/sda, and any other internal hard drives to be labelled from /dev/sdb. I am using partition labels to map to my /boot, /root, /home and /swap. It seems the internal drive appears as sda, so I run into a kernel panic on boot.

lsblk -f
NAME    FSTYPE  LABEL
sda
|___sda1
sdb
|___sdb1 hfsplus DISK_1
|___sdb2 ext4    USB_root
|___sdb3 ext4    USB_home
|___sdb4 swap    USB_swap 

I have udev rules for internal drives to be numbered from /sdb onwards, but it appears that these rules are applied later in the boot sequence, so the internal disk which should be sdb is initialised as sda.

My /boot/grub.conf is as follows:

default=0
timeout=5
chainloader +1
#splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.65-1.el6.elrepo.x86_64)
    #root (hd0,0)
    search --set --label USB_boot   
    kernel /vmlinuz-3.10.65-1.el6.elrepo.x86_64 ro root=LABEL=USB_root nomodeset rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rootdelay=8
    initrd /usbinitrd-3.10.65-1.el6.elrepo.x86_64.img

My usbinitrd was created following the instructions on here

  • Is it possible to have an external USB drive boot initialise as sda before any internal drives?
  • Should I just map my USB device and grub config to something like /sdu so it does not conflict with internal drive naming?
  • I would try and see the details of the init script in initrd. It might be that the mounting of the hard drive is done there. Isn't initrd replaced with initramfs as a default now? – TheMeaningfulEngineer Jan 30 '15 at 19:29
0

This seems to have been a timing issue when booting - the rootdelay=8 on the kernel options in my grub.conf was changed to rootdelay=10, and everything is now working as expected. It seems that the machine had not discovered all partitions on the USB stick by the time it had started booting.

I created another udev rule to map my USB stick to /dev/sdu using the MANUFACTURER label found by udevadm and all is well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.