You are not logged in.

#1 2024-08-10 07:09:53

OhKay_Bet
Member
Registered: 2023-11-16
Posts: 35

[SOLVED]BTRFS no subvol clean chroot

So I did an oopsie, didnt fully grasp creating a clean chroot when i decided to follow the guide. only after making the chroot (only got up to 3.1) did I read it creates a btrfs subvolume. decided to fully read and saw at the end its possible to make it as a tempfs, which is what id like to switch to.

Issue is right now, when i listed out subvolumes for my /home dir the only one is the chroot.

sudo btrfs subvolume list -p /home 
ID 256 gen 422809 parent 5 top level 5 path user/chroot/root

After switching to BTRFS i never made any snapshots or subvolumes, I was expecting to see 2 one for the home directory and the chroot. I was mistakenly under the impression that my /home was also a subvolume

my  fstab looks like this

# /dev/nvme1n1p3
UUID=ec0d4321-8d09-4bf8-a3fa-6045032da5e7   /           btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=5,subvol=/    0 0

# /dev/nvme1n1p1
UUID=70B2-4744          /boot       vfat        rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro   0 2
 
# /dev/nvme1n1p4
UUID=c0aced61-b41b-49f0-93bb-324cedd49e15   /home       btrfs       rw,relatime,ssd,discard=async,space_cache=v2,subvolid=5,subvol=/    0 0

# /dev/nvme1n1p2
15   │ UUID=b68a5437-8b05-474b-b0df-6c5d7ebc5c8f   none        swap        defaults    0 0

I havent done anything else to the chroot, my concern is if I delete the subvolume ill brick my system and lose data, as a few months ago I bricked my laptop by deleting what i thought were unneeded folders that ended up being the subvolumes my system was running on. also concerned that if i reboot mysystem will boot into the chroot as the  fstab says subvolid=5 and the chroot subvolume lists 5 as its top level and parent.

Trying to turn lemons into lemonaid, is it possible to have that chroot/subvol mount as a tempfs where the subvol can be used as a clean image of the chroot. Im thinking in lines of amnesic/ declarative that way I can have a clean chroot whenever needed and any files added for development or testing can get wiped on shutdown?

Last edited by OhKay_Bet (2024-08-10 21:46:37)

Offline

#2 2024-08-10 09:56:11

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,339
Website

Re: [SOLVED]BTRFS no subvol clean chroot

I'm not completely sure what you're trying to do here but for a testing area that gets wiped when you're done I use

~$ alias scratch
scratch='doas systemd-nspawn --ephemeral --boot --directory=/'
~$

In respect of your installation, the system should boot fine with that fstab but using two separate partitions on the same disk makes little sense under btrfs. I would have a single partition with separate subvolumes where needed, it's _much_ easier to manage.


Para todos todo, para nosotros nada

Offline

#3 2024-08-10 11:40:12

OhKay_Bet
Member
Registered: 2023-11-16
Posts: 35

Re: [SOLVED]BTRFS no subvol clean chroot

@Head_on_a_Stick the partitions were there from before i used btrfs and havent really thought about removing the partition. My main concern is since the chroot subvol lives under my /home partition and has a subvolid of 5, that deleteing it and rebooting, would wipe my system. Im inclined to not think it would since no files are stored there, but messing around with subvolumes on my laptop ended up me redownloading arch.

I like your implementation of a testing area. safe to assume doas is just the sudo replacement?

Offline

#4 2024-08-10 12:03:38

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,339
Website

Re: [SOLVED]BTRFS no subvol clean chroot

A subvolid of 5 just indicates it is a top-level subvolume, which cannot be removed or replaced by another subvolume, as detailed in btrfs-subvolume(8). Just remember to remove the /home/ line in /etc/fstab if you delete the /home/ subvolume on /dev/nvme1n1p4 so that /home/ on the root partition is used instead.

What exactly do you mean by "chroot subvol"? I don't understand that term.

EDIT: and yes, doas is my preferred sudo alternative.

Last edited by Head_on_a_Stick (2024-08-10 12:15:45)


Para todos todo, para nosotros nada

Offline

#5 2024-08-10 19:27:20

OhKay_Bet
Member
Registered: 2023-11-16
Posts: 35

Re: [SOLVED]BTRFS no subvol clean chroot

@Head_on_a_Stick creating the chroot made the subvolume and its linked to the chroot
https://wiki.archlinux.org/title/Develo … ean_chroot

sudo btrfs subvolume list -p /home 
ID 256 gen 422809 parent 5 top level 5 path user/chroot/root

my dir is /home/user/ , but the subvolume was made in pointing to /home/user/chroot/root. meaning if i were to reboot, id be locked into the chroot losing access to my regular working directory. Thats my cause for concern rightnow, as im not sure how to remove the subvol so i can maintain access to the home dir. there is not /home subvol listed

Last edited by OhKay_Bet (2024-08-10 19:32:19)

Offline

#6 2024-08-10 21:36:27

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,339
Website

Re: [SOLVED]BTRFS no subvol clean chroot

Removing the subvolume should be fine. I don't understand why you think it would be a problem.


Para todos todo, para nosotros nada

Offline

#7 2024-08-10 21:40:35

OhKay_Bet
Member
Registered: 2023-11-16
Posts: 35

Re: [SOLVED]BTRFS no subvol clean chroot

@Head_on_a_Stick comes from being burnt due to my ignorance with btrfs in the past. thought i was good to do that on my laptop and i was wrong. i appreciate your help

Offline

Board footer

Powered by FluxBB