mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-04 10:25:25 +01:00
Add sysb and sysc scaffolding.
Now that we have the Linux Kernel built, we move to a full-disk (rather than initramfs) setup in sysc. However, we cannot assume the seed kernel has support for mounting hard drives. So, first we need to kexec into sysb, which is used as a jumping off point to create the hard drive for sysc. Additionally, since 2.6.16 does not have support for on-demand initramfs (initramfs must be built into kernel), we will have to rebuild the linux kernel within sysb without the initramfs. All of this process is not performed for chroot mode. Instead, we skip sysb and jump straight to sysc, copying over appropriate data. The python scripts have been changed slightly. Each sys* inherits SysGeneral, which contains various functions which are not specific to any sys* and simplifies those files. rootfs now also handles sysb and sysc. bootstrap.cfg also gives an indication whether we are running in a chroot to avoid attempting to kexec/mount within a chroot.
This commit is contained in:
parent
925ce198c1
commit
5c88f1c87f
75 changed files with 624 additions and 176 deletions
15
lib/utils.py
15
lib/utils.py
|
|
@ -5,13 +5,13 @@ This file contains a few self-contained helper functions
|
|||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
||||
# SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def run(*args, **kwargs):
|
||||
"""A small wrapper around subprocess.run"""
|
||||
arguments = [str(arg) for arg in args]
|
||||
|
|
@ -25,6 +25,19 @@ def run(*args, **kwargs):
|
|||
print("Bootstrapping failed")
|
||||
sys.exit(1)
|
||||
|
||||
def create_disk(image, disk_type, fs_type, size):
|
||||
"""Create a disk image, with a filesystem on it"""
|
||||
run('truncate', '-s', size, image)
|
||||
# First find the device we will use, then actually use it
|
||||
loop_dev = run('losetup', '-f', capture_output=True).stdout.decode().strip()
|
||||
run('sudo', 'losetup', loop_dev, image)
|
||||
# Create the partition
|
||||
run('sudo', 'parted', '--script', image, 'mklabel', disk_type, 'mkpart',
|
||||
'primary', 'ext4', '0%', '100%')
|
||||
run('sudo', 'partprobe', loop_dev)
|
||||
run('sudo', 'mkfs.' + fs_type, loop_dev + "p1")
|
||||
return loop_dev
|
||||
|
||||
def mount(source, target, fs_type, options='', **kwargs):
|
||||
"""Mount filesystem"""
|
||||
run('sudo', 'mount', source, target, '-t', fs_type, '-o', options, **kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue