mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Fix grub install
This commit is contained in:
parent
3c32310346
commit
e740a3b4d8
1 changed files with 22 additions and 23 deletions
|
@ -16,18 +16,29 @@ class ConfigureGrub(Task):
|
||||||
boot_dir = os.path.join(info.root, 'boot')
|
boot_dir = os.path.join(info.root, 'boot')
|
||||||
grub_dir = os.path.join(boot_dir, 'grub')
|
grub_dir = os.path.join(boot_dir, 'grub')
|
||||||
|
|
||||||
# if type(info.volume) is LoopbackVolume:
|
from partitionmaps.none import NoPartitions
|
||||||
if isinstance(info.volume, LoopbackVolume):
|
|
||||||
|
def remount(volume, fn):
|
||||||
# GRUB cannot deal with installing to loopback devices
|
# GRUB cannot deal with installing to loopback devices
|
||||||
# so we fake a real harddisk with dmsetup.
|
# so we fake a real harddisk with dmsetup.
|
||||||
# Guide here: http://ebroder.net/2009/08/04/installing-grub-onto-a-disk-image/
|
# Guide here: http://ebroder.net/2009/08/04/installing-grub-onto-a-disk-image/
|
||||||
info.volume.unmount()
|
volume.unmount_specials()
|
||||||
info.volume.unmap()
|
p_map = volume.partition_map
|
||||||
info.volume.link_dm_node()
|
if hasattr(p_map, 'boot'):
|
||||||
info.volume.map()
|
boot_dir = p_map.boot.mount_dir
|
||||||
info.volume.mount_root(info.root)
|
p_map.boot.unmount()
|
||||||
info.volume.mount_boot()
|
p_map.root.unmount()
|
||||||
info.volume.mount_specials()
|
if isinstance(self.partition_map, NoPartitions):
|
||||||
|
p_map.unmap()
|
||||||
|
fn()
|
||||||
|
p_map.map()
|
||||||
|
p_map.root.mount(info.root)
|
||||||
|
if hasattr(p_map, 'boot'):
|
||||||
|
p_map.boot.mount(boot_dir)
|
||||||
|
volume.mount_specials()
|
||||||
|
|
||||||
|
if isinstance(info.volume, LoopbackVolume):
|
||||||
|
remount(info.volume, info.volume.link_dm_node)
|
||||||
try:
|
try:
|
||||||
[device_path] = log_check_call(['readlink', '-f', info.volume.device_path])
|
[device_path] = log_check_call(['readlink', '-f', info.volume.device_path])
|
||||||
device_map_path = os.path.join(grub_dir, 'device.map')
|
device_map_path = os.path.join(grub_dir, 'device.map')
|
||||||
|
@ -46,20 +57,8 @@ class ConfigureGrub(Task):
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(info.volume, LoopbackVolume):
|
if isinstance(info.volume, LoopbackVolume):
|
||||||
info.volume.unmount()
|
remount(info.volume, info.volume.unlink_dm_node)
|
||||||
info.volume.unmap()
|
|
||||||
info.volume.unlink_dm_node()
|
|
||||||
info.volume.map()
|
|
||||||
info.volume.mount_root(info.root)
|
|
||||||
info.volume.mount_boot()
|
|
||||||
info.volume.mount_specials()
|
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
if isinstance(info.volume, LoopbackVolume):
|
if isinstance(info.volume, LoopbackVolume):
|
||||||
info.volume.unmount()
|
remount(info.volume, info.volume.unlink_dm_node)
|
||||||
info.volume.unmap()
|
|
||||||
info.volume.unlink_dm_node()
|
|
||||||
info.volume.map()
|
|
||||||
info.volume.mount_root(info.root)
|
|
||||||
info.volume.mount_boot()
|
|
||||||
info.volume.mount_specials()
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue