GNU bug report logs -
#52919
Hidden "disk-image-rw" files aren't deleted after use, filling $tmpdir
Previous Next
Reported by: Leo Famulari <leo <at> famulari.name>
Date: Fri, 31 Dec 2021 18:19:01 UTC
Severity: normal
Done: Mathieu Othacehe <othacehe <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Hey,
Here is a patch to store the rw images in the cache directory. Regarding
the volatile flag, things are a little more complex than what I thought
initially.
The "guix system" help menu states that:
--8<---------------cut here---------------start------------->8---
--volatile for 'image', make the root file system volatile
--8<---------------cut here---------------end--------------->8---
because for an image, it often makes sense to have the root file system
persistent. For the 'vm' command however, it's probably the other way
around as we would prefer not to copy the huge image files if possible.
I feel like creating a '--volatile-image' and a '--persistent-vm' option
is going to make things too much complex.
WDYT?
Thanks,
Mathieu
[0001-system-vm-Do-not-store-rw-image-in-the-tmp-directory.patch (text/x-patch, inline)]
From e4efaf2ffc6d7c699f9d1c41744cfff89be65c12 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe <at> gnu.org>
Date: Tue, 11 Jan 2022 13:27:35 +0100
Subject: [PATCH 1/1] system: vm: Do not store rw image in the /tmp directory.
* gnu/system/vm.scm (system-qemu-image/shared-store-script): Store them in the
cache directory instead.
---
gnu/system/vm.scm | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 0fc9fb57f4..bd21f9416c 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -283,7 +283,9 @@ (define kernel-arguments
#+@(operating-system-kernel-arguments os "/dev/vda1")))
(define rw-image
- #~(format #f "/tmp/.~a-rw" (basename #$base-image)))
+ #~(format #f "~a/~a-rw"
+ #$(string-append (cache-directory) "/images")
+ (basename #$base-image)))
(define qemu-exec
#~(list #+(file-append qemu "/bin/"
@@ -310,10 +312,15 @@ (define builder
#+(file-append bash "/bin/sh"))
(when (not #$volatile?)
(format port "~a~%"
- #$(program-file "copy-image"
- #~(unless (file-exists? #$rw-image)
- (copy-file #$base-image #$rw-image)
- (chmod #$rw-image #o640)))))
+ #$(program-file
+ "copy-image"
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ (unless (file-exists? #$rw-image)
+ (mkdir-p (dirname #$rw-image))
+ (copy-file #$base-image #$rw-image)
+ (chmod #$rw-image #o640)))))))
(format port "exec ~a \"$@\"~%"
(string-join #$qemu-exec " "))
(chmod port #o555))))
--
2.34.0
This bug report was last modified 3 years and 132 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.