Revision 07d32070
b/example/instance-image.d/grub | ||
---|---|---|
47 | 47 |
|
48 | 48 |
boot_dir="${TARGET}/boot/grub" |
49 | 49 |
|
50 |
if [ -n "${INSTANCE_HV_kernel_path}" -o "${IMPORT_SCRIPT}" = "1" ] ; then |
|
51 |
# make /dev/$disk |
|
50 |
setup_disk_devs() { |
|
51 |
root_part="${ROOT_DEV/*-/}" |
|
52 |
boot_part="${BOOT_DEV/*-/}" |
|
53 |
|
|
52 | 54 |
mknod ${TARGET}/dev/${disk} b $(stat -L -c "0x%t 0x%T" $BLOCKDEV) |
53 | 55 |
CLEANUP+=("rm -f ${TARGET}/dev/$disk") |
54 | 56 |
|
55 |
# make /dev/${disk}1 |
|
56 |
mknod ${TARGET}/dev/${disk}1 b $(stat -L -c "0x%t 0x%T" $BOOT_DEV) |
|
57 |
CLEANUP+=("rm -f ${TARGET}/dev/${disk}1") |
|
57 |
mknod ${TARGET}/dev/${disk}${root_part} b $(stat -L -c "0x%t 0x%T" $ROOT_DEV) |
|
58 |
CLEANUP+=("rm -f ${TARGET}/dev/${disk}${root_part}") |
|
58 | 59 |
|
59 |
# make /dev/${disk}1 |
|
60 |
mknod ${TARGET}/dev/${disk}3 b $(stat -L -c "0x%t 0x%T" $ROOT_DEV) |
|
61 |
CLEANUP+=("rm -f ${TARGET}/dev/${disk}3") |
|
60 |
if [ -n "$BOOT_DEV" ] ; then |
|
61 |
mknod ${TARGET}/dev/${disk}${boot_part} b $(stat -L -c "0x%t 0x%T" $BOOT_DEV) |
|
62 |
CLEANUP+=("rm -f ${TARGET}/dev/${disk}${boot_part}") |
|
63 |
fi |
|
64 |
} |
|
62 | 65 |
|
63 |
if [ -e "${boot_dir}/menu.lst" ] ; then |
|
64 |
# create device.map |
|
65 |
cat > "${TARGET}/boot/grub/device.map" <<EOF |
|
66 |
add_devicemap() { |
|
67 |
cat > "${TARGET}/boot/grub/device.map" <<EOF |
|
66 | 68 |
(hd0) /dev/${disk} |
67 | 69 |
EOF |
70 |
} |
|
71 |
|
|
72 |
if [ -n "${INSTANCE_HV_kernel_path}" -o "${IMPORT_SCRIPT}" = "1" ] ; then |
|
73 |
setup_disk_devs |
|
68 | 74 |
|
75 |
if [ -e "${boot_dir}/menu.lst" ] ; then |
|
76 |
add_devicemap |
|
69 | 77 |
# install grub to the block device |
70 | 78 |
chroot ${TARGET} grub --batch --no-floppy \ |
71 | 79 |
--device-map=/boot/grub/device.map <<EOF |
... | ... | |
73 | 81 |
setup (hd0) |
74 | 82 |
quit |
75 | 83 |
EOF |
76 |
|
|
77 | 84 |
# check to see if grub is using UUID's and replace if so |
78 | 85 |
if [ -n "$(grep 'root=UUID' ${boot_dir}/menu.lst)" ] ; then |
79 | 86 |
root_uuid="$($VOL_ID $ROOT_DEV)" |
80 | 87 |
sed --follow-symlinks -ie "s/\(root=UUID=\)\([a-z0-9-]*\)/\1${root_uuid}/g" \ |
81 | 88 |
${boot_dir}/menu.lst |
82 | 89 |
fi |
83 |
|
|
84 | 90 |
elif [ -e "${boot_dir}/grub.cfg" -a -e "${TARGET}/etc/default/grub" ] ; then |
85 | 91 |
chroot ${TARGET} grub2-install /dev/${disk} |
86 | 92 |
# check to see if grub is using UUID's and replace if so |
... | ... | |
94 | 100 |
|
95 | 101 |
# setup serial console |
96 | 102 |
if [ "${INSTANCE_HV_serial_console}" = "True" ] ; then |
103 |
if [ ! -e ${TARGET}/dev/${disk} ] ; then |
|
104 |
setup_disk_devs |
|
105 |
fi |
|
97 | 106 |
if [ -e "${boot_dir}/menu.lst" ] ; then |
98 |
# Grub 0.x
|
|
107 |
# grub 0.x
|
|
99 | 108 |
sed --follow-symlinks -ie 's/^default.*/default 0\n\nserial --unit=0\nterminal --timeout=3 console serial/' \ |
100 | 109 |
${boot_dir}/menu.lst |
101 | 110 |
sed --follow-symlinks -ie 's/\(.*kernel.*\)/\1 console=ttyS0,115200n8/g' \ |
102 | 111 |
${boot_dir}/menu.lst |
103 | 112 |
elif [ -e "${boot_dir}/grub.cfg" -a -e "${TARGET}/etc/default/grub" ] ; then |
104 |
# Grub 2.x |
|
113 |
# grub 2.x |
|
114 |
add_devicemap |
|
105 | 115 |
sed -ie 's/.*GRUB_TERMINAL.*/GRUB_TERMINAL=serial/' ${TARGET}/etc/default/grub |
106 | 116 |
sed -ie 's/.*GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\"console=ttyS0,115200n8\"/' \ |
107 | 117 |
${TARGET}/etc/default/grub |
108 | 118 |
echo "GRUB_SERIAL_COMMAND=\"serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1\"" \ |
109 | 119 |
>> ${TARGET}/etc/default/grub |
110 |
chroot ${TARGET} /usr/sbin/update-grub
|
|
120 |
chroot ${TARGET} update-grub |
|
111 | 121 |
else |
112 | 122 |
echo "No grub bootloader found, skipping..." |
113 | 123 |
fi |
Also available in: Unified diff