Bug 1130526

Summary: Can't delete btrfs subvolume
Product: [openSUSE] openSUSE Distribution Reporter: Steffen Sledz <sledz>
Component: KernelAssignee: E-mail List <kernel-maintainers>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: Leap 15.0   
Target Milestone: ---   
Hardware: x86-64   
OS: Other   
See Also: https://bugzilla.opensuse.org/show_bug.cgi?id=957198
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Steffen Sledz 2019-03-26 12:45:10 UTC
# btrfs subvolume list /
ID 257 gen 34 top level 5 path @
ID 258 gen 257743 top level 257 path @/var
ID 259 gen 257498 top level 257 path @/usr/local
ID 260 gen 257743 top level 257 path @/tmp
ID 261 gen 186732 top level 257 path @/srv
ID 262 gen 257736 top level 257 path @/root
ID 263 gen 257616 top level 257 path @/opt
ID 264 gen 257286 top level 257 path @/home
ID 265 gen 28 top level 257 path @/boot/grub2/x86_64-efi
ID 266 gen 224143 top level 257 path @/boot/grub2/i386-pc
ID 267 gen 257708 top level 257 path @/.snapshots
ID 268 gen 257743 top level 267 path @/.snapshots/1/snapshot
ID 400 gen 62349 top level 258 path @/var/lib/machines
ID 568 gen 253867 top level 267 path @/.snapshots/191/snapshot
...
# mount | grep /home
/dev/sda1 on /home type btrfs (rw,relatime,ssd,space_cache,subvolid=264,subvol=/@/home)
# btrfs subvolume delete @/home
ERROR: cannot access subvolume @/home: No such file or directory
# umount /home
# mount | grep /home
# btrfs subvolume delete @/home
ERROR: cannot access subvolume @/home: No such file or directory
Comment 1 Jeff Mahoney 2019-03-26 12:47:25 UTC
The @ is the root of the file system.

You'll want:

# btrfs subvolume delete /home
Comment 2 Steffen Sledz 2019-03-26 12:50:10 UTC
# btrfs subvolume delete /home
ERROR: not a subvolume: /home

:(
Comment 3 Steffen Sledz 2019-03-26 12:50:56 UTC
Does also not work.
Comment 4 Jeff Mahoney 2019-03-26 12:51:24 UTC
Ah, right.  It's in use as a mount point.  You need to unmount it first.
Comment 5 Steffen Sledz 2019-03-26 12:53:10 UTC
Nope! It was unmounted before.

# umount /home
umount: /home: not mounted.
# btrfs subvolume delete /home
ERROR: not a subvolume: /home
Comment 6 Jeff Mahoney 2019-03-26 12:56:34 UTC
Sorry, haven't had my coffee yet this morning.

# mount -osubvolid=0 /dev/sda1 /mnt
# btrfs subvolume delete /mnt/@/home

should do it.

The -o subvolid=0 mounts the "true" root of the file system instead of the default subvolume, so you can see the entire namespace.
Comment 7 Steffen Sledz 2019-03-26 12:59:05 UTC
Thank God for the coffee!

;-)