image.py: add create_filesystem(), improve log output in cmd_inspect()
This commit is contained in:
parent
fc58f4288f
commit
f0a9d3a670
1 changed files with 22 additions and 24 deletions
46
image.py
46
image.py
|
@ -268,36 +268,31 @@ def partition_device(device: str):
|
||||||
raise Exception(f'Failed to create partitions on {device}')
|
raise Exception(f'Failed to create partitions on {device}')
|
||||||
|
|
||||||
|
|
||||||
def create_root_fs(device: str, blocksize: int):
|
def create_filesystem(device: str, blocksize: int = 4096, label=None, options=[], fstype='ext4'):
|
||||||
result = subprocess.run([
|
# blocksize can be 4k max due to pagesize
|
||||||
'mkfs.ext4',
|
blocksize = min(blocksize, 4096)
|
||||||
'-O',
|
if fstype.startswith('ext'):
|
||||||
'^metadata_csum',
|
# blocksize for ext-fs must be >=1024
|
||||||
|
blocksize = max(blocksize, 1024)
|
||||||
|
|
||||||
|
labels = ['-L', label] if label else []
|
||||||
|
cmd = [
|
||||||
|
f'mkfs.{fstype}',
|
||||||
'-F',
|
'-F',
|
||||||
'-L',
|
|
||||||
'kupfer_root',
|
|
||||||
'-N',
|
|
||||||
'100000',
|
|
||||||
'-b',
|
'-b',
|
||||||
str(blocksize),
|
str(blocksize),
|
||||||
device,
|
] + labels + [device]
|
||||||
])
|
result = subprocess.run(cmd)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise Exception(f'Failed to create ext4 filesystem on {device}')
|
raise Exception(f'Failed to create {fstype} filesystem on {device} with CMD: {cmd}')
|
||||||
|
|
||||||
|
|
||||||
|
def create_root_fs(device: str, blocksize: int):
|
||||||
|
create_filesystem(device, blocksize=blocksize, label='kupfer_root', options=['-O', '^metadata_csum', '-N', '100000'])
|
||||||
|
|
||||||
|
|
||||||
def create_boot_fs(device: str, blocksize: int):
|
def create_boot_fs(device: str, blocksize: int):
|
||||||
result = subprocess.run([
|
create_filesystem(device, blocksize=blocksize, label='kupfer_boot', fstype='ext2')
|
||||||
'mkfs.ext2',
|
|
||||||
'-F',
|
|
||||||
'-L',
|
|
||||||
'kupfer_boot',
|
|
||||||
'-b',
|
|
||||||
str(blocksize),
|
|
||||||
device,
|
|
||||||
])
|
|
||||||
if result.returncode != 0:
|
|
||||||
raise Exception(f'Failed to create ext2 filesystem on {device}')
|
|
||||||
|
|
||||||
|
|
||||||
def install_rootfs(rootfs_device: str, bootfs_device: str, device, flavour, arch, packages, extra_repos, profile):
|
def install_rootfs(rootfs_device: str, bootfs_device: str, device, flavour, arch, packages, extra_repos, profile):
|
||||||
|
@ -437,7 +432,10 @@ def cmd_inspect(shell: bool = False):
|
||||||
if shell:
|
if shell:
|
||||||
chroot.initialized = True
|
chroot.initialized = True
|
||||||
chroot.activate()
|
chroot.activate()
|
||||||
build_enable_qemu_binfmt(arch)
|
if arch != config.runtime['arch']:
|
||||||
|
logging.info('Installing requisites for foreign-arch shell')
|
||||||
|
build_enable_qemu_binfmt(arch)
|
||||||
|
logging.info('Starting inspection shell')
|
||||||
chroot.run_cmd('/bin/bash')
|
chroot.run_cmd('/bin/bash')
|
||||||
else:
|
else:
|
||||||
pause()
|
pause()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue