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 label l0
menu label Debian GNU/Linux, kernel {kernel_version} menu label Debian GNU/Linux, kernel {kernel_version}
linux /boot/vmlinuz-{kernel_version} linux {boot_prefix}/vmlinuz-{kernel_version}
append initrd=/boot/initrd.img-{kernel_version} root=UUID={UUID} ro quiet console=ttyS0 append initrd={boot_prefix}/initrd.img-{kernel_version} root=UUID={root_uuid} ro quiet console=ttyS0
label l0r label l0r
menu label Debian GNU/Linux, kernel {kernel_version} (recovery mode) menu label Debian GNU/Linux, kernel {kernel_version} (recovery mode)
linux /boot/vmlinuz-{kernel_version} linux {boot_prefix}/vmlinuz-{kernel_version}
append initrd=/boot/initrd.img-{kernel_version} root=UUID={UUID} ro console=ttyS0 single append initrd={boot_prefix}/initrd.img-{kernel_version} root=UUID={root_uuid} ro console=ttyS0 single
text help text help
This option boots the system into recovery mode (single-user) This option boots the system into recovery mode (single-user)
endtext endtext

View file

@ -69,19 +69,26 @@ class ConfigureExtlinuxJessie(Task):
os.mkdir(extlinux_path) os.mkdir(extlinux_path)
from . import assets from . import assets
extlinux_assets_path = os.path.join(assets, 'extlinux') with open(os.path.join(assets, 'extlinux/extlinux.conf')) as template:
extlinux_tpl_path = os.path.join(extlinux_assets_path, 'extlinux.conf') extlinux_config_tpl = template.read()
with open(extlinux_tpl_path) as extlinux_tpl:
extlinux_config = extlinux_tpl.read()
root_uuid = info.volume.partition_map.root.get_uuid() config_vars = {'root_uuid': info.volume.partition_map.root.get_uuid(),
extlinux_config = extlinux_config.format(kernel_version=info.kernel_version, UUID=root_uuid) 'kernel_version': info.kernel_version}
extlinux_config_path = os.path.join(extlinux_path, 'extlinux.conf') # Check if / and /boot are on the same partition
with open(extlinux_config_path, 'w') as extlinux_conf_handle: # 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) extlinux_conf_handle.write(extlinux_config)
from shutil import copy
# Copy the boot message # 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')) copy(boot_txt_path, os.path.join(extlinux_path, 'boot.txt'))