[CentOS] grub, initrd and Co

Philippe Naudin

philippe.naudin at supagro.inra.fr
Tue Jun 8 11:26:23 UTC 2010


Hi all,

I am trying to boot from a HD created as a copy of a running system 
(and it doesn't work, and I don't understand why ...) 

This is the system to be copied :
File-system            Size  Used Avail Use% Mounted on
/dev/hda1             2.0G  797M  1.1G  43% /
tmpfs                 506M     0  506M   0% /dev/shm
/dev/hda5             4.7G  3.3G  1.2G  74% /var/spool/squid/cache1
/dev/hda6             4.7G  3.3G  1.2G  74% /var/spool/squid/cache2

The backup of the system has been done with :
/bin/tar czO -C / --preserve-permissions --sparse --one-file-system \
  --exclude=lost+found --exclude=tmp/* \
  . \
  | /usr/bin/nc -w 5 my.workstation 6060 # ( after executing
  # netcat -l -p 6060 > $IMAGE on my.workstation )

On the target HD, I have created three "type 83" partitions and a
swap, ran mke2fs -cc -j /dev/$D for the three FS and mkswap -c /dev/$D
for the future swap.

The target root FS was restored with : tar xzpf $IMAGE -C /mnt/linux

On the target root FS, I edited /etc/fstab and /etc/grub.conf, 
replacing any reference to LABEL=... by the real device (/dev/hda1 
and so on).

Then I took care of the initrd (future / is mounted on /mnt/linux/) :
mount -o bind /dev /mnt/linux/dev
mount -t proc none /mnt/linux/proc
mount -t sysfs none /mnt/linux/sys
rm /mnt/linux/boot/initrd* 
chroot /mnt/linux 
mkinitrd /boot/initrd-2.6.18-194.3.1.el5.img 2.6.18-194.3.1.el5
# so far, so good...

... and installed grub on the target HD :
/sbin/grub --no-curses
  find /boot/grub/stage1 # answer : (hd0,0)
  root (hd0,0)
  setup (hd0)  # answer : succeeded
  quit
exit # (chroot)

When I try to boot the target HD (set as hda in a new PC), I get the 
grub prompt, and I can boot the system. Every thing goes too quickly, 
so I can't see what is going on, until :

...
Trying to resume from /dev/hda3
No suspend signature on swap, not resuming.
Creating root device.
Mounting root filesystem.
mount: error mounting /dev/root on /sysroot as auto: No such device
Setting up other filesystems.
Setting up new root fs
setuproot: moving /dev/failed: No such file or directory
no fstab.sys, mounting internal defaults
  Then it complains about missing /proc and /sys, and end with :
switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!

/dev/hda3 is the swap partition on the new disk. The swap was in 
/dev/hda2 on the old disk, but fstab has been modified accordingly ;
other FS are just like on the old disk (I mean, / is hda1, cache1 is
hda5 and cache2 is hda6).

I have certainly forgotten something, but I am unable to find what...
Who can help me ?

Thanks,

-- 
Philippe



More information about the CentOS mailing list