mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Parted tasks and grub installation working now
This commit is contained in:
parent
cecdeba45f
commit
7a93002b2d
2 changed files with 27 additions and 13 deletions
|
@ -2,6 +2,7 @@ from base import Task
|
||||||
from common import phases
|
from common import phases
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
import filesystem
|
import filesystem
|
||||||
|
import loopback
|
||||||
|
|
||||||
|
|
||||||
class PartitionVolume(Task):
|
class PartitionVolume(Task):
|
||||||
|
@ -10,14 +11,11 @@ class PartitionVolume(Task):
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
# parted
|
# parted
|
||||||
log_check_call(['parted', '-a', 'optimal',
|
log_check_call(['parted', '-a', 'optimal', '-s', info.bootstrap_device['path'],
|
||||||
'-s', info.bootstrap_device['path'],
|
'--', 'mklabel', 'msdos'])
|
||||||
'mklabel', 'msdos'])
|
log_check_call(['parted', '-a', 'optimal', '-s', info.bootstrap_device['path'],
|
||||||
log_check_call(['parted', '-a', 'optimal',
|
|
||||||
'-s', info.bootstrap_device['path'],
|
|
||||||
'--', 'mkpart', 'primary', 'ext4', '32k', '-1'])
|
'--', 'mkpart', 'primary', 'ext4', '32k', '-1'])
|
||||||
log_check_call(['parted',
|
log_check_call(['parted', '-s', info.bootstrap_device['path'],
|
||||||
'-s', info.bootstrap_device['path'],
|
|
||||||
'--', 'set', '1', 'boot', 'on'])
|
'--', 'set', '1', 'boot', 'on'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +27,11 @@ class MapPartitions(Task):
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
log_check_call(['kpartx', '-a', '-v', info.bootstrap_device['path']])
|
log_check_call(['kpartx', '-a', '-v', info.bootstrap_device['path']])
|
||||||
root_partition_path = info.bootstrap_device['path'].replace('/dev', '/dev/mapper')+'p1'
|
root_partition_path = info.bootstrap_device['path'].replace('/dev', '/dev/mapper')+'p1'
|
||||||
info.bootstrap_device['partitions'] = {'root_path': root_partition_path}
|
|
||||||
|
[root_loopback_path] = log_check_call(['/sbin/losetup', '--find'])
|
||||||
|
log_check_call(['/sbin/losetup', root_loopback_path, root_partition_path])
|
||||||
|
|
||||||
|
info.bootstrap_device['partitions'] = {'root_path': root_loopback_path}
|
||||||
|
|
||||||
|
|
||||||
class FormatPartitions(Task):
|
class FormatPartitions(Task):
|
||||||
|
@ -46,8 +48,11 @@ class FormatPartitions(Task):
|
||||||
class UnmapPartitions(Task):
|
class UnmapPartitions(Task):
|
||||||
description = 'Removing volume partitions mapping'
|
description = 'Removing volume partitions mapping'
|
||||||
phase = phases.volume_unmounting
|
phase = phases.volume_unmounting
|
||||||
|
before = [loopback.Detach]
|
||||||
after = [filesystem.UnmountVolume]
|
after = [filesystem.UnmountVolume]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
log_check_call(['kpartx', '-d', info.loopback_file])
|
log_check_call(['/sbin/losetup', '-d', info.bootstrap_device['partitions']['root_path']])
|
||||||
del info.bootstrap_device['partitions']['root_path']
|
del info.bootstrap_device['partitions']['root_path']
|
||||||
|
|
||||||
|
log_check_call(['kpartx', '-d', info.bootstrap_device['path']])
|
||||||
|
|
|
@ -7,10 +7,19 @@ class ConfigureGrub(Task):
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
|
import os.path
|
||||||
|
device_map_path = os.path.join(info.root, 'boot/grub/device.map')
|
||||||
|
with open(device_map_path, 'w') as device_map:
|
||||||
|
device_map.write(('(hd0) {dev_path}\n'
|
||||||
|
'(hd0,1) {root_path}'
|
||||||
|
.format(dev_path=info.bootstrap_device['path'],
|
||||||
|
root_path=info.bootstrap_device['partitions']['root_path'])))
|
||||||
|
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, 'update-initramfs', '-u'])
|
log_check_call(['/usr/sbin/chroot', info.root, 'update-initramfs', '-u'])
|
||||||
log_check_call(['/usr/sbin/grub-install',
|
|
||||||
'--boot-directory='+info.root+"/boot/",
|
|
||||||
info.bootstrap_device['path']])
|
|
||||||
|
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|
log_check_call(['/usr/sbin/chroot', info.root,
|
||||||
|
'/usr/sbin/grub-mkconfig', '-o', '/boot/grub/grub.cfg'])
|
||||||
|
|
||||||
|
log_check_call(['/usr/sbin/chroot', info.root,
|
||||||
|
'/usr/sbin/grub-install', info.bootstrap_device['path']])
|
||||||
|
|
Loading…
Add table
Reference in a new issue