Featured

CachyOS Automount BTRFS partition

   

I recently started running CachyOS with a BTRFS file system.
BTRFS works a little differently.
After shrinking my main partition using “KDE Partition Manager,” I now have an extra 20GB partition, which I hope will be enough for my automated backups.

However, after making the change, I ran into a problem: even though I had selected the “accessible to everyone” option, the new partition was still only available to Root.
As a result, my backup software setup “Borg & Vorta” couldn’t perform an automatic backup after a reboot because Root had to mount the drive first.

Because a additional partition has now been added, will we first mount it manually with the correct BTRFS options, rather than immediately editing “fstab.”

*note: prior i did dive straight into the fstab, and after the reboot I ended up in “Emergency mode,” where I could log in to the root console to restore fstab.

With “sudo blkid” we can view the necessary information for all of our partitions.
For convenience, I’ve included only the relevant partition here.
“It may go without saying that your partition’s data will look different, even as your partition label, every partition has unique data.”

/dev/nvme0n1p3:
LABEL="MSI_Backups"
UUID="cf2082c2-0089-4c7b-be0c-ef0a612a13d2"
UUID_SUB=“5f3dc900-5689-4250-aea5-93bf440c7891”
BLOCK_SIZE="4096"
TYPE="btrfs"
PARTUUID=“fc20ae76-bad2-47be-a801-b860fba85b5c”

Now we have exactly what we need.

The partition is:
UUID = cf2082c2-0089-4c7b-be0c-ef0a612a13d2
Type = btrfs
Label = MSI_Backups

Now we’re going to add this safely without messing up your system 😊

1. First, create a mount point
Run: sudo mkdir -p /mnt/MSI_Backups

2. Test mounting manually
sudo mount -t btrfs UUID=cf2082c2-0089-4c7b-be0c-ef0a612a13d2 /mnt/MSI_Backups
Then check if you see your files with: ls /mnt/MSI_Backups

3. Set ownership correctly
Since Btrfs uses Linux permissions, we do not use uid= or gid= in fstab. That is for FAT/NTFS.

So: sudo chown -R anousjka:anousjka /mnt/MSI_Backups
(use your exact username in lowercase)

*”Note: these permissions can also be set more strictly”

4. Test whether a regular user can access it
Without sudo: touch /mnt/MSI_Backups/testfile

5. Only then edit /etc/fstab
Open: sudo nano /etc/fstab

*Note: fstab is keyboard-driven, so be very careful not to make any unintended changes to the existing lines.

Add the following at the very bottom:
UUID=cf2082c2-0089-4c7b-be0c-ef0a612a13d2 /mnt/MSI_Backups btrfs defaults,noatime 0 0









6. Test safely without rebooting
DO NOT reboot immediately!! 😄

With CachyOS, I first had to run sudo systemctl daemon-reload to load the new fstab.

First: sudo umount /mnt/MSI_Backups Then: sudo mount -a
If everything is okay, you shouldn’t get any error messages now, right?

mount -a returned no errors, so your /etc/fstab rule is valid and Btrfs is mounting correctly.

That’s exactly the test that prevents you from ending up in emergency mode 😊 
You can now safely reboot.
 After the reboot, you can do one quick check if you like: 
mount|grep MSI_Backups 
Then you’ll see right away if it’s mounted automatically. 

Output:
mount|grep MSI_Backups /dev/nvme0n1p3 on /mnt/MSI_Backups type btrfs (rw,noatime,ssd,discard=async,space_cache=v2,subvolid=5,subvol=/)

 
I hope this will help others in the Linux community 

By: Anousjka https://www.girlonlinux.nl


Comments

Popular Posts