mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-04 10:25:25 +01:00
Disk creation improvements
* Support specifying the size of the target disk image for qemu * For bare metal, only pad the image to the next megabyte * Use truncate() to extend images, instead of writing zeros (faster) * Return None from get_disk() with nonexistent name * Leave 1MiB on non-boot disks, or 1GiB on boot disks, unpartitioned (for proper 4K alignment and to help preserve the srcfs or boot partition creation) * Fix qemu invocation when an external.img is not used * Make -qr work with kernel bootstrap (will need kexec-fiwix fix)
This commit is contained in:
parent
dc62d8242c
commit
b4d9c5e7cb
4 changed files with 61 additions and 27 deletions
|
|
@ -31,7 +31,8 @@ def run_as_root(*args, **kwargs):
|
|||
return run("sudo", *args, **kwargs)
|
||||
return run(*args, **kwargs)
|
||||
|
||||
def create_disk(image, disk_type, fs_type, size, mkfs_args=None):
|
||||
# pylint: disable=too-many-arguments
|
||||
def create_disk(image, disk_type, fs_type, size, bootable=False, mkfs_args=None):
|
||||
"""Create a disk image, with a filesystem on it"""
|
||||
if mkfs_args is None:
|
||||
mkfs_args = []
|
||||
|
|
@ -42,7 +43,7 @@ def create_disk(image, disk_type, fs_type, size, mkfs_args=None):
|
|||
# Create the partition
|
||||
if disk_type != "none":
|
||||
run_as_root('parted', '--script', image, 'mklabel', disk_type, 'mkpart',
|
||||
'primary', fs_type, '0%', '100%')
|
||||
'primary', fs_type, '1GiB' if bootable else '1MiB', '100%')
|
||||
run_as_root('partprobe', loop_dev)
|
||||
run_as_root('mkfs.' + fs_type, loop_dev + "p1", *mkfs_args)
|
||||
return loop_dev
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue