]> Raphaƫl G. Git Repositories - distgen/blob - lib/boot.sh
Commit rename
[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 # Retrieve mdboot and mddata uuids
23 MDBOOTUUID=`mdadm --detail /dev/md/${MDBOOT} | perl -pne '/UUID\s:\s/||undef $_;s/^\s+UUID\s:\s//'`
24 MDDATAUUID=`mdadm --detail /dev/md/${MDDATA} | perl -pne '/UUID\s:\s/||undef $_;s/^\s+UUID\s:\s//'`
25
26 # Regenerate initrd
27 #XXX: request a non hostonly to get all kernel modules
28 #XXX: provide devices uuid to have md and luks ready
29 #XXX: force crypttab presence, mandatory to unlocking
30 #XXX: you may add ip=dhcp rd.neednet=1 for debug purpose
31 chroot ${MOUNTPOINT} dracut -f -N --fstab --hostonly-cmdline --kernel-cmdline 'rd.luks.uuid='$LUKSDATAUUID' rd.md.uuid='$MDBOOTUUID' rd.md.uuid='$MDDATAUUID -I /etc/crypttab /boot/initrd-${KVER}.img ${KVER}
32
33 # Generate grub config
34 chroot ${MOUNTPOINT} grub2-mkconfig -o /boot/grub2/grub.cfg
35
36 # Install grub
37 for i in $LOOPB $LOOPA; do
38 chroot ${MOUNTPOINT} grub2-install $i
39 done
40
41 # Umount dev
42 umount ${MOUNTPOINT}/sys
43
44 # Umount dev
45 umount ${MOUNTPOINT}/proc
46
47 # Umount dev
48 umount ${MOUNTPOINT}/dev
49
50 # Reset mtab
51 mv -f ${MOUNTPOINT}/etc/mtab.orig ${MOUNTPOINT}/etc/mtab
52
53 # Umount mysql
54 umount ${MOUNTPOINT}/var/lib/mysql
55
56 # Umount mail
57 umount ${MOUNTPOINT}/var/spool/mail
58
59 # Umount home
60 umount ${MOUNTPOINT}/home
61
62 # Umount boot
63 umount ${MOUNTPOINT}/boot