Fix extlinux booting on jessie when /boot is on another partition

This commit is contained in:
Anders Ingemann 2015-01-21 22:32:04 +01:00
parent b70e24a848
commit 75e70c96f7
2 changed files with 21 additions and 14 deletions

View file

@ -5,13 +5,13 @@ timeout 50
label l0
menu label Debian GNU/Linux, kernel {kernel_version}
linux /boot/vmlinuz-{kernel_version}
append initrd=/boot/initrd.img-{kernel_version} root=UUID={UUID} ro quiet console=ttyS0
linux {boot_prefix}/vmlinuz-{kernel_version}
append initrd={boot_prefix}/initrd.img-{kernel_version} root=UUID={root_uuid} ro quiet console=ttyS0
label l0r
menu label Debian GNU/Linux, kernel {kernel_version} (recovery mode)
linux /boot/vmlinuz-{kernel_version}
append initrd=/boot/initrd.img-{kernel_version} root=UUID={UUID} ro console=ttyS0 single
linux {boot_prefix}/vmlinuz-{kernel_version}
append initrd={boot_prefix}/initrd.img-{kernel_version} root=UUID={root_uuid} ro console=ttyS0 single
text help
This option boots the system into recovery mode (single-user)
endtext

View file

@ -69,19 +69,26 @@ class ConfigureExtlinuxJessie(Task):
os.mkdir(extlinux_path)
from . import assets
extlinux_assets_path = os.path.join(assets, 'extlinux')
extlinux_tpl_path = os.path.join(extlinux_assets_path, 'extlinux.conf')
with open(extlinux_tpl_path) as extlinux_tpl:
extlinux_config = extlinux_tpl.read()
with open(os.path.join(assets, 'extlinux/extlinux.conf')) as template:
extlinux_config_tpl = template.read()
root_uuid = info.volume.partition_map.root.get_uuid()
extlinux_config = extlinux_config.format(kernel_version=info.kernel_version, UUID=root_uuid)
extlinux_config_path = os.path.join(extlinux_path, 'extlinux.conf')
with open(extlinux_config_path, 'w') as extlinux_conf_handle:
config_vars = {'root_uuid': info.volume.partition_map.root.get_uuid(),
'kernel_version': info.kernel_version}
# Check if / and /boot are on the same partition
# If not, /boot will actually be / when booting
if hasattr(info.volume.partition_map, 'boot'):
config_vars['boot_prefix'] = ''
else:
config_vars['boot_prefix'] = '/boot'
extlinux_config = extlinux_config_tpl.format(**config_vars)
with open(os.path.join(extlinux_path, 'extlinux.conf'), 'w') as extlinux_conf_handle:
extlinux_conf_handle.write(extlinux_config)
from shutil import copy
# Copy the boot message
boot_txt_path = os.path.join(extlinux_assets_path, 'boot.txt')
from shutil import copy
boot_txt_path = os.path.join(assets, 'extlinux/boot.txt')
copy(boot_txt_path, os.path.join(extlinux_path, 'boot.txt'))