BTRFS - Problem adding new sub-volumes

Hello,

I’ve read through a bunch of threads here and on other forums + the BTRFS manual but I still need assistance.

I want to create new subvolumes and mount existing folders to them (such as /run, /tmp & my own /scripts), but I can’t quite grasp how to do that.

Here is the current subvolume setup from installing Manjaro:

ID 256 gen 1718 top level 5 path @
ID 257 gen 1768 top level 5 path @home
ID 258 gen 1408 top level 5 path @cache
ID 259 gen 1768 top level 5 path @log

Here is my fstab:

UUID=0094-6C92                            /boot/efi      vfat    umask=0077 0 2
UUID=a651d5d2-ac20-40ae-a8ba-1b25be4e117d /              btrfs   subvol=/@,defaults,space_cache=v2,compress=zstd:3,discard=async,ssd 0 0
UUID=a651d5d2-ac20-40ae-a8ba-1b25be4e117d /home          btrfs   subvol=/@home,defaults,space_cache=v2,compress=zstd:3,discard=async,ssd 0 0
UUID=a651d5d2-ac20-40ae-a8ba-1b25be4e117d /var/cache     btrfs   subvol=/@cache,defaults,space_cache=v2,compress=zstd:3,discard=async,ssd 0 0
UUID=a651d5d2-ac20-40ae-a8ba-1b25be4e117d /var/log       btrfs   subvol=/@log,defaults,space_cache=v2,compress=zstd:3,discard=async,ssd 0 0
UUID=9579c81f-26f1-4874-b611-675b878f2633 swap           swap    defaults,noatime 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0

If I go to / and create a new sub-volume via “btrfs subvolume create scripts”(for example), it creates a new sub-volume and also adds a directory with the same name (scripts). If I create a sub-volume with the name [at]scripts…it’ll also add a directory with the name [at]scripts. Yet, I can’t find a folder called [at]home, [at]cache, or [at]log and I’m not able to figure out why that is (I get that they’re mounted at real directories per fstab layout though). I think they’re sub-volumes under the [at] sub-volume, so how do I create a new sub-volume that falls under [at]?

Additionally, if I want to mount a directory to a subvolume, do I need to copy the contents over from the original folder to the sub-volume created directory (via cp --ref-link=always) and then rename it to the same?

Mount the partition without targeting a subvolume:

sudo mount -m -U a651d5d2-ac20-40ae-a8ba-1b25be4e117d /mnt/fstree

And create then the subvolume on the fs-tree.

sudo btrfs subvolume create /mnt/fstree/@scripts

Just for understanding:

sudo btrfs subvolume show /mnt/fstree 

will show Name: <FS_TREE>, while

sudo btrfs subvolume show /

will show Name: @

What? :dizzy_face: You want to mount a dir to a subvol ? Shouldn’t it be the way around? What do you try to accomplish here?

/run and /tmp are both tmpfs, i.e. filesystems in virtual memory. They do not contain anything unless the system is running, and their contents do not exist on any physical drive.

The @ signifies the root subvolume of the btrfs filesystem — note: this is not necessarily the same thing as the root directory — and need not be specified when creating a subvolume.

sudo btrfs subvolume create /path/to/name

Rename the original directory (“folder”), create the subvolume with the name it should have and where it needs to go, mount the subvolume to its own directory — created when the subvolume itself is created — and move over the contents of the original directory to the mountpoint.

Also make sure that the new mountpoint is listed in /etc/fstab.

Thanks! I couldn’t figure out that I needed to mount the partition directly. Problem’s solved! I just created a new sub-volume and set the mount point to /scripts - everything is working fine :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.