]> Raphaƫl G. Git Repositories - distgen/blob - lib/boot.sh
0e4186ff3572263588ee41a8a12e85ea5d33228d
[distgen] / lib / boot.sh
1 #! /bin/sh -e
2
3 # Bind mount /dev
4 mount --bind /dev ${MOUNTPOINT}/dev
5
6 # Bind mount /proc
7 mount --bind /proc ${MOUNTPOINT}/proc
8
9 # Bind mount /sys
10 mount --bind /sys ${MOUNTPOINT}/sys
11
12 # Backup old mtab
13 mv ${MOUNTPOINT}/etc/mtab ${MOUNTPOINT}/etc/mtab.orig
14
15 # Create new mtab
16 #cat /proc/self/mounts | grep -E '^(/dev/m|devtmpfs)' | perl -pne 's%/media(/?)%$1%' | sort | uniq > /media/etc/mtab
17 perl -pne "/^(devtmpfs \\/dev|\\/dev\\/(md|dm|mapper))/ || undef \$_; s%${MOUNTPOINT}/?%/%" /proc/self/mounts > ${MOUNTPOINT}/etc/mtab
18
19 # Extract last kernel version
20 KVER=`chroot ${MOUNTPOINT} rpm -qa | perl -pne '/kernel-server-latest/||undef $_;s%^kernel-(server)-latest-([^-]+)-(.+)$%\2-\1-\3%'`
21
22 # Regenerate initrd
23 #XXX: force non hostonly else it don't store commandline : rd.luks.uuid rd.md.uuid ip=dhcp rd.neednet=1
24 DRACUT_SKIP_FORCED_NON_HOSTONLY=1 chroot ${MOUNTPOINT} mkinitrd -f /boot/initrd-${KVER}.img ${KVER}
25
26 # Generate grub config
27 chroot ${MOUNTPOINT} grub2-mkconfig -o /boot/grub2/grub.cfg
28
29 # Install grub
30 for i in $LOOPB $LOOPA; do
31 chroot ${MOUNTPOINT} grub2-install $i
32 done
33
34 # Umount dev
35 umount ${MOUNTPOINT}/sys
36
37 # Umount dev
38 umount ${MOUNTPOINT}/proc
39
40 # Umount dev
41 umount ${MOUNTPOINT}/dev
42
43 # Reset mtab
44 mv -f ${MOUNTPOINT}/etc/mtab.orig ${MOUNTPOINT}/etc/mtab
45
46 # Umount home
47 umount ${MOUNTPOINT}/home
48
49 # Umount boot
50 umount ${MOUNTPOINT}/boot