You are not logged in.

#1 2023-11-02 17:13:48

spartan
Member
Registered: 2016-04-07
Posts: 3

[SOLVED] Add new subvolume to existing btrfs setup

Hi,
I'm very new with btrfs; I used archinstall to create a base system partitioned with btrfs. During installation were created a standard setup:

@ for /
@home for /home
@pkg for /vac/cache/pacman/pkg
@log for /var/log
@.snapshots for /.snapshots

Now, I want to add a new subvolume. First question: may I complete the operation with a running system?

I issued the following commands:

# cd /

# btrfs subvolume create @example
Create subvolume './@example'

# btrfs subvolume list .
ID 256 gen 205 top level 5 path @
ID 257 gen 205 top level 5 path @home
ID 258 gen 205 top level 5 path @log
ID 259 gen 171 top level 5 path @pkg
ID 260 gen 7 top level 5 path @.snapshots
ID 261 gen 16 top level 256 path var/lib/portables
ID 262 gen 16 top level 256 path var/lib/machines
ID 265 gen 185 top level 256 path @example          // <-------------------------------

# mount -o rw,relatime,space_cache=v2,subvolid=261,subvol=/@example /dev/sda2 /example
mount: /example: mount point does not exist.
       dmesg(1) may have more information after failed mount system call.

"/" contains "@example" folder.

I tried with and without "@" in the subvolume name, but no luck.

For mount options I have adapted to what is used in fstab.

Any tip? Very thanks.

Last edited by spartan (2023-11-04 08:16:24)

Offline

#2 2023-11-02 17:37:36

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,555
Website

Re: [SOLVED] Add new subvolume to existing btrfs setup

Mount is telling you that the mountpoint '/example' doesn't exist. Either create it manually, or tell mount to create it for you with the '--mkdir' flag.

https://man.archlinux.org/man/mount.8


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2023-11-02 17:50:23

just4arch
Member
Registered: 2023-01-07
Posts: 126

Re: [SOLVED] Add new subvolume to existing btrfs setup

spartan wrote:

Now, I want to add a new subvolume. First question: may I complete the operation with a running system?

Yes.

You opted for layout, where you create every subvolume in the root-volume and need to mount every subvolume separately to your system.

In your example you created a new subvolume /@/@example - probably not what you intended.

mount -o subvol=/ /dev/sda2 /mnt
btrfs subvolume create /mnt/@example
umount /mnt
mkdir /example
mount -o subvol=/@example /dev/sda2 /example

Subvolumes don't need to be on the top level, eg. systemd likes to create /var/lib/machines as a subvol.
So you could just create /home as a subvol (snapshots are not recursive and will stop at subvolumes).
Some mount options will be shared by all subvolumes (they're bind mounts under the hood).

Last edited by just4arch (2023-11-02 17:54:30)

Offline

#4 2023-11-03 15:39:17

spartan
Member
Registered: 2016-04-07
Posts: 3

Re: [SOLVED] Add new subvolume to existing btrfs setup

just4arch wrote:
mount -o subvol=/ /dev/sda2 /mnt
btrfs subvolume create /mnt/@example
umount /mnt
mkdir /example
mount -o subvol=/@example /dev/sda2 /example

Thank you,
my error was creating the subvolume in current "/" instead of first mounting the subvol in "/mnt".

My I ask another question? I see online two different ways to create a subvolume; for instance for /var/lib/flatpak:

$ findmnt -t btrfs -o SOURCE,TARGET
...
/dev/sdaX[/@flatpak]    ├─/var/lib/flatpak

or

$ findmnt -t btrfs -o SOURCE,TARGET
...
/dev/sdaX[/var/lib/@flatpak]    ├─/var/lib/flatpak

(creating a "root" @flatpak instead of /var/lib/@flatpak)

Which one is preferable? Are there specific cases for using one rather than the other?

Again, very thanks

Offline

#5 2023-11-03 18:14:50

just4arch
Member
Registered: 2023-01-07
Posts: 126

Re: [SOLVED] Add new subvolume to existing btrfs setup

/dev/sdaX[/@flatpak]    ├─/var/lib/flatpak

Would fit you current scheme.

/dev/sdaX[/var/lib/@flatpak]    ├─/var/lib/flatpak

Looks utterly pointless to me, but still depends on how you want to set this up.

There are (snapshot) tools that expect certain structures - if you don't intend to use them, do what suits you best, it's your system.
You should take into account how you want to organise your snapshots, ie. naming conventions (using the @ prefix is optional).
Just keep in mind, what you want to include and exclude in each snapshot.
https://btrfs.readthedocs.io/en/latest/ … ot-layouts

So in the end it all depends on your use case and how you want to handle subvols/snapshots.

Offline

#6 2023-11-04 08:15:54

spartan
Member
Registered: 2016-04-07
Posts: 3

Re: [SOLVED] Add new subvolume to existing btrfs setup

just4arch wrote:

So in the end it all depends on your use case and how you want to handle subvols/snapshots.

Thanks

Offline

Board footer

Powered by FluxBB