bug#43366: "error: rmdir: Device or resource busy" when using btrfs
Hello, Pushed to core-updates with commit 7102c18678dc02d5ee6c77a9a70ae344482af841. Closing. Thanks, Maxim
bug#43366: "error: rmdir: Device or resource busy" when using btrfs
Hi Maxim, Maxim Cournoyer writes: > I just sent a patch now, but here's a bit more background on what led to > it. Nice find! I'm unable to test out the patch right now on my original use case as I soft bricked my laptop fiddling around with coreboot. And I'm having some issues with my external flasher. > The issue seems to be with: > > --8<---cut here---start->8--- > ;; If a previous installation was attempted, make sure we start anew; in > ;; particular, we don't want to keep a store database that might not > ;; correspond to what we're actually putting in the store. > (let ((state (string-append target "/var/guix"))) > (when (file-exists? state) > (delete-file-recursively state))) > --8<---cut here---end--->8--- > > Which is part of the install procedure (which gets called when using > 'guix system init /some/target'). So your guess was correct :-). Yay! > To confirm this was the case, I did: > > sudo btrfs subvolume create /tmp/toto > mkdir /tmp/tata > sudo mount -o subvol=/tmp/toto /dev/mapper/cryptroot /tmp/tata > > sudo -E guix repl >> ,import (guix build utils) >> (delete-file-recursively "/tmp/tata/") > ice-9/boot-9.scm:1669:16: In procedure raise-exception: > In procedure rmdir: Device or resource busy > > Bingo! > > Reading the docstring of delete-file-recursively, it says it should > "report but ignore errors", so that's a bug. Yeah, that's is the same error I get when running guix init. So this sounds like it will fix my issue! Thanks for the speedy fix. -- s/Fred[re]+i[ck]+/Fredrik/g
bug#43366: "error: rmdir: Device or resource busy" when using btrfs
Hi Fredrik, I just sent a patch now, but here's a bit more background on what led to it. Fredrik Salomonsson writes: > When you have separate btrfs subvolumes for /gnu and /var/guix, you'll > encounter this error running `guix system init /mnt/etc/config.scm /mnt` > when it tries to copy things to /mnt. My guess is that guix is trying to > remove one of them but fails as they're mounted. The issue seems to be with: --8<---cut here---start->8--- ;; If a previous installation was attempted, make sure we start anew; in ;; particular, we don't want to keep a store database that might not ;; correspond to what we're actually putting in the store. (let ((state (string-append target "/var/guix"))) (when (file-exists? state) (delete-file-recursively state))) --8<---cut here---end--->8--- Which is part of the install procedure (which gets called when using 'guix system init /some/target'). So your guess was correct :-). To confirm this was the case, I did: sudo btrfs subvolume create /tmp/toto mkdir /tmp/tata sudo mount -o subvol=/tmp/toto /dev/mapper/cryptroot /tmp/tata sudo -E guix repl > ,import (guix build utils) > (delete-file-recursively "/tmp/tata/") ice-9/boot-9.scm:1669:16: In procedure raise-exception: In procedure rmdir: Device or resource busy Bingo! Reading the docstring of delete-file-recursively, it says it should "report but ignore errors", so that's a bug. Maxim
bug#43366: "error: rmdir: Device or resource busy" when using btrfs
When you have separate btrfs subvolumes for /gnu and /var/guix, you'll encounter this error running `guix system init /mnt/etc/config.scm /mnt` when it tries to copy things to /mnt. My guess is that guix is trying to remove one of them but fails as they're mounted. I encountered this issue while I tried installing guix system on my main laptop. But I have encountered this before [1]. When I installed guix system on my secondary laptop. I worked around it back then by using guix-0.15.0. For my secondary laptop I have this layout | subvol| Mountpoint | Comment | |---++-| | __current/guixsd-root | / | root for GuixSD | | __current/grub| /boot/grub | grub config | | __current/guix| /var/guix | guix stuff | | __current/gnu | /gnu | Store etc | | __current/home| /home | home partition | For my main laptop I tried: | subvol | Mountpoint | Comment| |++| | @ | / | root for Guix | | @grub | /boot/grub | grub config| | @guix | /var/guix | guix stuff | | @gnu | /gnu | Store etc | | @home | /home | home partition | Found another thread that also had this issue [2], and the same workaround worked for me. I.e. simplified the layout: | subvol| Mountpoint | Comment| |---++| | @ | / | root for Guix | | @home | /home | home partition | This seems to just be an issue when running guix system init, as I've been using my secondary laptop with separate subvolumes for /gnu and /var/guix without any issues since 0.15. The guix version I used to install my main laptop with was 1.1.0-25.44c6e6f. I generated it with guix system disk-image --file-system-type=iso9660 \ gnu/system/install.scm As described in the manual. Thanks [1] https://lists.gnu.org/archive/html/help-guix/2018-12/msg00055.html [2] https://lists.gnu.org/archive/html/help-guix/2019-06/msg00259.html ;; This is an operating system configuration template ;; for a "desktop" setup without full-blown desktop ;; environments. (use-modules (gnu) (gnu packages) (gnu system nss) (gnu system locale) (gnu services nfs) (gnu services sddm) (ice-9 rdelim) (ice-9 format) (srfi srfi-1)) (use-service-modules desktop networking ssh base xorg) (use-package-modules wm certs shells xdisorg display-managers) (define plattfot (user-account (name "plattfot") (group "users") ;; Define a G-Expr to find the path of the zsh binary: ;; https://gitlab.com/rain1/guix-wiki/wikis/FAQ#how-do-i-make-my-login-shell-zsh ;;(shell #~(string-append #$zsh "/bin/zsh")) (supplementary-groups '("wheel" "netdev" "audio" "video")) (home-directory "/home/plattfot"))) ;; Specify a mapped device for the encrypted root partition. ;; The UUID is that returned by 'cryptsetup luksUUID'. (define mapped-swap (mapped-device (source (uuid "3f1a433f-e3d5-46f1-8471-b0cfee72a659")) (target "swap") (type luks-device-mapping))) (define mapped-root (mapped-device (source (uuid "0633603e-019c-4be0-b35e-abb055660909")) (target "root") (type luks-device-mapping))) ;; Partion layout for `root` ;; | subvol| Mountpoint | Comment| Shared | ;; |---+++| ;; | @ | / | root for Guix | no | ;; | @home | /home | home partition | yes| (define btrfs-common-options '("discard" "compress=lzo" "space_cache" "autodefrag")) (define (btrfs-mount-options subvol) "Return the btrfs mount options I use. Where SUBVOL is the subvolume to mount" (string-join `(,@btrfs-common-options ,(format #f "subvol=~a" subvol)) ",")) (define fs-root (file-system (mount-point "/") (type "btrfs") (device (file-system-label "root")) (options (btrfs-mount-options "@")) (needed-for-boot? #t) (dependencies `(,mapped-root (define fs-home (file-system (mount-point "/home") (type "btrfs") (device (file-system-label "root")) (options (btrfs-mount-options "@home")) (needed-for-boot? #t) (dependencies `(,fs-root (define nfs-valhalla (file-system (device "fafner:/srv/nfs4/Valhalla") (mount-point "/media/Valhalla") (type "nfs4") (mount? #f) (check? #f))) (operating-system (host-name "heimdal") (timezone "Canada/Pacific") (locale "en_US.utf8") (locale-definitions (list (locale-definition (name "en_US.utf8") (source "en_US") (charset "UTF-8")) (locale-definition (name "sv_SE.utf8") (source "sv_SE") (charset "UTF-8" ;; Assuming /dev/sda is the target hard disk, and "root" ;; is the label of the target root file system. (bootloader (grub-configuration (target "/dev/sda"))) ;; Kernel arguments