Tuesday, June 24, 2008

Linux can't complete boot after migrating the root to a raid 1 volume

  • Reinstall Lilo to the MBR of the raid drives
  • I saw the following error after I migrated the / to a raid 1 /dev/md1
    setuproot: moving /dev failed No such file or directory
    setuproot: error mounting /proc: No such file or directory
    setuproot: error mounting /sys: No such file or directory
    switchroot: mount failed: No such file or directory

    It's because the old initrd.img might not invoke the mdadm command or the kernel module for the SATA controller to start the md array before accessing the root file system. This can be verified by
    lsinitrd /boot/initrd.img | grep mdadm
    lsmod | grep sata
    lsinitrd /boot/initrd.img | grep libata

    What I did is to reboot with a repair system, and type the following commands:
    mount /dev/md0 /mnt
    chroot /mnt
    mount /proc
    mount -n -t sysfs /sys /sys
    mv /boot/initrd.img /boot/initrd.backup
    mkinitrd -f --preload=libata --preload=scsi_mod /boot/initrd.img 2.6.26.20
    Then reinstall Lilo if necessary.
  • The content of the initrd.img file may be extracted by the following command
    gunzip < /boot/initrd.img | cpio -i --make-directories
  • Check the content of /dev folder before it's mounted as /dev. If there are any md* entries, delete them. Otherwise it may not boot successfully.
  • The libary package was in compatible with the upgraded e2fsprogs package. But the partition only needed check because the maximum mount count was exceeded. So in the "Repair Filesystem" mode, root can do the following:
    1. disable the fsck on a partition by running the command
      dumpe2fs -h /dev/hda1 | grep 'ount count'
      tune2fs -c 0 -i 0 /dev/hda1

      Reboot and no fsck error whatsoever.

    2. Remount the / to read and write
      mount -o remount,rw /
  • Create the software raid 1 with two sata drives



    1. mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
    2. Run diskdrake to set the mount point for /dev/md0 and mount it
    3. mdadm --examine --scan /dev/sda1 >> /etc/mdadm.conf
    4. Change the partition label with e2label /dev/md0 /home
    5. Manually start the array with mdadm -As /dev/md0
    6. Add auto=yes to the end of every ARRAY clause in /etc/mdadm.conf
    7. Add HOTPLUG_RC_scsi=yes into /etc/sysconfig/hotplug





      References:
    1. Mandriva Initscripts
    2. Choosing a Mandriva Kernel

No comments: