4 mount
--bind /dev
${MOUNTPOINT}/dev
7 mv ${MOUNTPOINT}/etc
/mtab
${MOUNTPOINT}/etc
/mtab.orig
10 #cat /proc/self/mounts | grep -E '^(/dev/m|devtmpfs)' | perl -pne 's%/media(/?)%$1%' | sort | uniq > /media/etc/mtab
11 perl
-pne "/^(devtmpfs \\/dev|\\/dev\\/(md|dm|mapper))/ || undef \$_; s%${MOUNTPOINT}/?%/%" /proc
/self
/mounts
> ${MOUNTPOINT}/etc
/mtab
13 # Backup old device.map
14 mv ${MOUNTPOINT}/boot
/grub
/device.map
${MOUNTPOINT}/boot
/grub
/device.map.orig
17 for i
in $LOOPB $LOOPA; do
18 # Create new device map
19 echo "(hd0) $i" > ${MOUNTPOINT}/boot
/grub
/device.map
22 #XXX: e2fs_stage1_5 is 20 sectors embedded, but it fail with gpt
23 #XXX: we use install command directly instead of setup (hd0) because it fail with loop
24 cat << EOF | chroot ${MOUNTPOINT} grub --device-map=/boot/grub/device.map
26 install --stage2=/boot/grub/stage2 /grub/stage1 (hd0) /grub/stage2 p /grub/menu.lst
30 # Restore old device.map
31 mv -f ${MOUNTPOINT}/boot
/grub
/device.map.orig
${MOUNTPOINT}/boot
/grub
/device.map
34 mount
--bind /proc
${MOUNTPOINT}/proc
37 mount
--bind /sys
${MOUNTPOINT}/sys
39 # Extract last kernel version
40 KVER
=`chroot ${MOUNTPOINT} rpm -qa | perl -pne '/kernel-server-latest/||undef $_;s%^kernel-(server)-latest-([^-]+)-(.+)$%\2-\1-\3%'`
42 #XXX: force non hostonly else it don't store commandline : rd.luks.uuid rd.md.uuid ip=dhcp rd.neednet=1
43 DRACUT_SKIP_FORCED_NON_HOSTONLY
=1 chroot
${MOUNTPOINT} mkinitrd
-f /boot
/initrd
-${KVER}.img
${KVER}
46 umount
${MOUNTPOINT}/sys
49 umount
${MOUNTPOINT}/proc
52 umount
${MOUNTPOINT}/dev
55 mv -f ${MOUNTPOINT}/etc
/mtab.orig
${MOUNTPOINT}/etc
/mtab
58 umount
${MOUNTPOINT}/boot