]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Give disk images some extra free disk space when we boot them
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 7 May 2023 07:10:19 +0000 (09:10 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 8 May 2023 12:55:41 +0000 (14:55 +0200)
truncate creates the extra disk space sparse so this doesn't affect
the host's disk usage. The extra disk space will have to be partitioned
to be usable inside the image though (but this is perfect for systemd's
use case as we want to partition the free space with systemd-repart).

NEWS.md
mkosi/__init__.py

diff --git a/NEWS.md b/NEWS.md
index bf70d6e37f0d18beabe0294372035573d4d2ec6e..9b2e0964664836b39a48c7107b526b574138b03b 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -82,6 +82,8 @@
 - `--base-image` is split into `--base-tree` and `--overlay`.
 - Removed `--cache-initrd`, instead, use a prebuilt initrd with `Initrds=` to avoid rebuilding the initrd all
   the time.
+- Disk images are now resized to 8G when booted to give some disk space to play around with in the booted
+  image.
 
 ## v14
 
index ebecd31da8fe577aebd7789be760723ef0b9aa46..3d21aadbf96715664257cde3d0df2e53cd480e90 100644 (file)
@@ -2264,6 +2264,10 @@ def run_verb(args: MkosiArgs, presets: Sequence[MkosiConfig]) -> None:
     if build and args.auto_bump:
         bump_image_version()
 
+    # Give disk images some space to play around with if we're booting one.
+    if args.verb in (Verb.shell, Verb.boot, Verb.qemu) and last.output_format == OutputFormat.disk:
+        run(["truncate", "--size", "8G", last.output_dir / last.output])
+
     with prepend_to_environ_path(last.extra_search_paths):
         if args.verb in (Verb.shell, Verb.boot):
             run_shell(args, last)