I have been doing some research and I understand that I need to create a subvolume

Hello Garuda users.

I want to do this:

have opt as a subvolume.
(etc/fstab)
UUID=5fbd1add-9f9f9f-492d-bf66-9f61355d7cdc /opt btrfs subvol=/@opt_,noatime,compress=zstd,discard=async,ssd 0 0

I have been doing some research and I understand that I need to create a subvolume
is this the correct way?
sudo btrfs subvolume create @opt

If I reboot in theory this should work fine?

Yes, except you have an underscore after the subvolume name in /etc/fstab which is not in the subvolume name you noted. The rest looks fine.

4 Likes

If there is already content in /opt you should first move it away and then move it into the subvolume, when it is mounted.

3 Likes

I think you would first have to mount your root partition, maybe at /mnt/data, cd to /mnt/data and the run sudo btrfs subvolume create @opt

1 Like

(etc/fstab)
UUID=5fbd1add-9f9f9f9f-492d-bf66-9f61355d7cdc /opt btrfs subvol=/@opt_,noatime,compress=zstd,discard=async,ssd 0 0

I have been doing some research and I understand that I need to create a subvolume
is this the correct way?
sudo btrfs subvolume create @opt

This way did not work for me it does not start the system

but I did it from the system itself, you are suggesting to do it with a liveusb?

what i want to achieve is that /opt is out of snapshot

It looks like you did not fix the extra underscore, that might be why you aren't able to boot.

If you want to make it a top-level subvolume (instead of a subvolume of /), you can either set it up from a live environment or--perhaps easier--mount subvolid=0 somewhere.

sudo mkdir /mnt/top-level_subvolume
sudo mount -o subvolid=0 /dev/sdx /mnt/top-level_subvolume
cd /mnt/top-level_subvolume

From here, ls should show you your highest-level subvolumes (@, @cache, @home, etc). Go ahead and make your new subvolume.

sudo btrfs subvolume create @opt

This is right. There are a few different ways you can do this, but one fairly simple way would be to mv your existing directory:

sudo mv /opt /opt_old

Make a new directory:

sudo mkdir /opt

Mount the subvolume there:

sudo mount -o subvol=@opt /dev/sdx /opt

Copy all the stuff into it:

sudo cp -ax --reflink=always /opt_old @opt 

When you are ready, you can delete opt_old. I would double-check the files are in the new directory and working as expected, everything survives a reboot, et cetera before you do.

Hopefully if I made a mistake someone will chime in with a correction before something gets broken. :grimacing: :crossed_fingers:

5 Likes

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