livemedia-creator: Add support for a squashfs only runtime image
Normally the runtime image is an ext4 filesystem image that is compressed with squashfs. dracut now supports setting up an overlayfs when it detects a bare filesystem tree inside the squashfs. This commit adds support for a --squashfs-only option which places the root tree directly in the squashfs.img
This commit is contained in:
parent
cf10fb40f3
commit
cb91fa3c78
@ -303,6 +303,8 @@ def lmc_parser(dracut_default=""):
|
||||
parser.add_argument("--releasever", default="29",
|
||||
help="substituted for @VERSION@ in bootloader config files")
|
||||
parser.add_argument("--volid", default=None, help="volume id")
|
||||
parser.add_argument("--squashfs-only", action="store_true", default=False,
|
||||
help="Use a plain squashfs filesystem for the runtime.")
|
||||
parser.add_argument("--squashfs_args",
|
||||
help="additional squashfs args")
|
||||
parser.add_argument("--timeout", default=None, type=int,
|
||||
|
@ -202,7 +202,13 @@ def make_runtime(opts, mount_dir, work_dir, size=None):
|
||||
|
||||
rb = RuntimeBuilder(product, arch, fake_dbo)
|
||||
compression, compressargs = squashfs_args(opts)
|
||||
log.info("Creating runtime")
|
||||
|
||||
if opts.squashfs_only:
|
||||
log.info("Creating a squashfs only runtime")
|
||||
rb.create_squashfs_runtime(joinpaths(work_dir, RUNTIME), size=size,
|
||||
compression=compression, compressargs=compressargs)
|
||||
else:
|
||||
log.info("Creating a squashfs+ext4 runtime")
|
||||
rb.create_ext4_runtime(joinpaths(work_dir, RUNTIME), size=size,
|
||||
compression=compression, compressargs=compressargs)
|
||||
|
||||
@ -418,6 +424,16 @@ def make_squashfs(opts, disk_img, work_dir):
|
||||
out any deleted blocks to make it compress better. If this fails for any reason
|
||||
it will return False and log the error.
|
||||
"""
|
||||
os.makedirs(os.path.dirname(joinpaths(work_dir, RUNTIME)))
|
||||
if opts.squashfs_only:
|
||||
log.info("Creating a squashfs only runtime")
|
||||
liveos_dir = joinpaths(work_dir, "runtime")
|
||||
os.makedirs(liveos_dir)
|
||||
with Mount(disk_img, opts="loop", mnt=liveos_dir):
|
||||
compression, compressargs = squashfs_args(opts)
|
||||
rc = mksquashfs(liveos_dir, joinpaths(work_dir, RUNTIME), compression, compressargs)
|
||||
else:
|
||||
log.info("Creating a squashfs+ext4 runtime")
|
||||
# Make sure free blocks are actually zeroed so it will compress
|
||||
rc = execWithRedirect("/usr/sbin/fsck.ext4", ["-y", "-f", "-E", "discard", disk_img])
|
||||
if rc != 0:
|
||||
@ -426,16 +442,22 @@ def make_squashfs(opts, disk_img, work_dir):
|
||||
|
||||
liveos_dir = joinpaths(work_dir, "runtime/LiveOS")
|
||||
os.makedirs(liveos_dir)
|
||||
os.makedirs(os.path.dirname(joinpaths(work_dir, RUNTIME)))
|
||||
|
||||
# Try to hardlink the rootfs file first, fall back top copying it
|
||||
rc = execWithRedirect("/bin/ln", [disk_img, joinpaths(liveos_dir, "rootfs.img")])
|
||||
if rc != 0:
|
||||
shutil.copy2(disk_img, joinpaths(liveos_dir, "rootfs.img"))
|
||||
|
||||
compression, compressargs = squashfs_args(opts)
|
||||
mksquashfs(joinpaths(work_dir, "runtime"),
|
||||
joinpaths(work_dir, RUNTIME), compression, compressargs)
|
||||
rc = mksquashfs(joinpaths(work_dir, "runtime"), joinpaths(work_dir, RUNTIME), compression, compressargs)
|
||||
|
||||
# Cleanup the runtime directory
|
||||
remove(joinpaths(work_dir, "runtime"))
|
||||
|
||||
if rc:
|
||||
log.error("Problem running mksquashfs: rc=%d", rc)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def calculate_disk_size(opts, ks):
|
||||
|
Loading…
Reference in New Issue
Block a user