-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
…inux Fedora 15 and others still work with these modifications
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# This script is an improvement over the default grub-install '(hd0)' | ||
# | ||
# However the following issues still exist: | ||
# | ||
# * We don't know what the first disk will be, so we cannot be sure the MBR | ||
# is written to the correct disk(s). That's why we make all disks bootable. | ||
# | ||
# * There is no guarantee that GRUB was the boot loader used originally. One | ||
# solution is to save and restore the MBR for each disk, but this does not | ||
# guarantee a correct boot-order, or even a working boot-lader config (eg. | ||
# GRUB stage2 might not be at the exact same location) | ||
|
||
# Only for GRUB2 - GRUB Legacy will be handled by its own script | ||
[[ $(type -p grub-install) || $(type -p grub2-install) ]] || return | ||
|
||
LogPrint "Installing GRUB2 boot loader" | ||
mount -t proc none /mnt/local/proc | ||
#for i in /dev /dev/pts /proc /sys; do mount -B $i /mnt/local${i} ; done | ||
|
||
if [[ -r "$LAYOUT_FILE" && -r "$LAYOUT_DEPS" ]]; then | ||
|
||
# Check if we find GRUB where we expect it | ||
[[ -d "/mnt/local/boot" ]] | ||
StopIfError "Could not find directory /boot" | ||
[[ -d "/mnt/local/boot/grub2" ]] | ||
StopIfError "Could not find directory /boot/grub2" | ||
[[ -r "/mnt/local/boot/grub2/grub.cfg" ]] | ||
LogIfError "Unable to find /boot/grub2/grub.cfg." | ||
|
||
# Find exclusive partitions belonging to /boot (subtract root partitions from deps) | ||
bootparts=$( (find_partition fs:/boot; find_partition fs:/) | sort | uniq -u ) | ||
grub_prefix=/grub | ||
if [[ -z "$bootparts" ]]; then | ||
bootparts=$(find_partition fs:/) | ||
grub_prefix=/boot/grub2 | ||
fi | ||
# Should never happen | ||
[[ "$bootparts" ]] | ||
BugIfError "Unable to find any /boot partitions" | ||
|
||
# Find the disks that need a new GRUB MBR | ||
disks=$(grep '^disk ' $LAYOUT_FILE | cut -d' ' -f2) | ||
[[ "$disks" ]] | ||
StopIfError "Unable to find any disks" | ||
|
||
for disk in $disks; do | ||
# Use first boot partition by default | ||
part=$(echo $bootparts | cut -d' ' -f1) | ||
|
||
# Use boot partition that matches with this disk, if any | ||
for bootpart in $bootparts; do | ||
bootdisk=$(find_disk "$bootpart") | ||
if [[ "$disk" == "$bootdisk" ]]; then | ||
part=$bootpart | ||
break | ||
fi | ||
done | ||
|
||
# Find boot-disk and partition number | ||
bootdisk=$(find_disk "$part") | ||
partnr=${part#$bootdisk} | ||
partnr=${partnr#p} | ||
partnr=$((partnr - 1)) | ||
|
||
if [[ "$bootdisk" == "$disk" ]]; then | ||
#chroot /mnt/local grub2-mkconfig -o /boot/grub2/grub.cfg | ||
#chroot /mnt/local grub2-install "$bootdisk" | ||
grub2-install --root-directory=/mnt/local/ $bootdisk | ||
else | ||
chroot /mnt/local grub2-mkconfig -o /boot/grub2/grub.cfg | ||
#chroot /mnt/local grub2-install "$bootdisk" | ||
grub2-install --root-directory=/mnt/local/ $bootdisk | ||
fi | ||
|
||
if (( $? == 0 )); then | ||
NOBOOTLOADER= | ||
fi | ||
done | ||
fi | ||
|
||
if [[ "$NOBOOTLOADER" ]]; then | ||
if chroot /mnt/local grub2-install "$disk" >&2 ; then | ||
NOBOOTLOADER= | ||
fi | ||
fi | ||
|
||
#for i in /dev /dev/pts /proc /sys; do umount /mnt/local${i} ; done | ||
umount /mnt/local/proc |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# GRUB2 has much more commands then the legacy grub command, including modules | ||
# check if we're using grub2 before doing something... | ||
[ ! -d $VAR_LIB/recovery ] && mkdir -p $VAR_DIR/recovery | ||
if has_binary grub-probe; then | ||
grub-probe -t device /boot/grub > $VAR_DIR/recovery/bootdisk 2>/dev/null || return | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jsmeix
Member
|
||
elif has_binary grub2-probe; then | ||
grub2-probe -t device /boot/grub >$VAR_DIR/recovery/bootdisk 2>/dev/null || return | ||
fi | ||
This comment has been minimized.
Sorry, something went wrong.
pcahyna
Member
|
||
|
||
PROGS=( "${PROGS[@]}" | ||
grub-install grub-mkdevicemap grub-probe grub-set-default grub-mkconfig grub-reboot grub-setup grub-mkimage | ||
grub2-install grub2-mkdevicemap grub2-probe grub2-set-default grub2-mkconfig grub2-reboot grub2-setup grub2-mkimage | ||
) | ||
|
||
COPY_AS_IS=( "${COPY_AS_IS[@]}" /etc/default/grub /etc/grub.d/* /etc/grub*.cfg /boot/grub* /usr/lib/grub* ) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Unit] | ||
Description=udev Control Socket | ||
DefaultDependencies=no | ||
|
||
[Socket] | ||
Service=udev.service | ||
ListenSequentialPacket=@/org/kernel/udev/udevd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=udev Kernel Socket | ||
DefaultDependencies=no | ||
|
||
[Socket] | ||
Service=udev.service | ||
ReceiveBuffer=134217728 | ||
ListenNetlink=kobject-uevent 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This service is usually not enabled by default. If enabled, it | ||
# acts as a barrier for basic.target -- so all later services will | ||
# wait for udev completely finishing its coldplug run. | ||
# | ||
# If needed, to work around broken or non-hotplug-aware services, | ||
# it might be enabled unconditionally, or pulled-in on-demand by | ||
# the services that assume a fully populated /dev at startup. It | ||
# should not be used or pulled-in ever on systems without such | ||
# legacy services running. | ||
|
||
[Unit] | ||
Description=udev Wait for Complete Device Initialization | ||
DefaultDependencies=no | ||
Wants=udev.service | ||
After=udev-trigger.service | ||
Before=basic.target | ||
|
||
[Service] | ||
Type=oneshot | ||
TimeoutSec=180 | ||
RemainAfterExit=yes | ||
ExecStart=/sbin/udevadm settle | ||
|
||
[Install] | ||
WantedBy=basic.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=udev Coldplug all Devices | ||
Wants=udev.service | ||
After=udev-kernel.socket udev-control.socket | ||
DefaultDependencies=no | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/sbin/udevadm trigger --type=subsystems --action=add ; /sbin/udevadm trigger --type=devices --action=add |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=udev Kernel Device Manager | ||
Wants=udev-control.socket udev-kernel.socket | ||
After=udev-control.socket udev-kernel.socket | ||
Before=basic.target | ||
DefaultDependencies=no | ||
|
||
[Service] | ||
Type=notify | ||
OOMScoreAdjust=-1000 | ||
Sockets=udev-control.socket udev-kernel.socket | ||
Restart=on-failure | ||
ExecStart=/sbin/udevd |
what's the purpose of the
$VAR_DIR/recovery/bootdisk
file? It does not seem to be used for anything.