How to mount btrfs system as user?

This maybe a noob question. But I have formatted my HDD with btrfs. But I can’t automount the partition on boot with user permission.
Partition only works with sudo parmission.

This fstab settings I have tried.

This fstab worked with ext4 and with user permission.

$ sudo vim /etc/fstab 

UUID=4208875b-ffea-4376-afd8-b0bbd6bcb0e3    /run/media/mnt/LocalDisk    btrfs    auto,users,exec    0    0 

I also tried with defaults. Still doesn’t work without root permission.

UUID=4208875b-ffea-4376-afd8-b0bbd6bcb0e3    /run/media/mnt/LocalDisk    btrfs    defaults,users    0    0 

How can I automount btrfs with user permission?

Do you have the btfrs hook set in /etc/mkinitcpio.conf? If not then:

Add btrfs and save it afterwards:

sudo nano /etc/mkinitcpio.conf
HOOKS="... btrfs ..."

The dots stay for the other existing entries - do not delete any, only add btrfs to that line!

Afterwards do

sudo mkinitcpio -P
sudo update-grub

and reboot.

1 Like

I have added ‘btrfs’ in mkinitcpio.conf.
Still the same problem. Disk only mount with root permission.
Can’t figure a way to use the partition as user. The same entry used to work with ext4

I would try to set up a path in /etc/fstab at /home/<your user name>/data or similar as this mounts this disk in a folder with user permissions.

Check ls -l /run/media/mnt/LocalDisk

What do you mean? Can you further describe what you want to happen and what happens instead?

Yes, that’s exactly how it’s supposed to work. Partitions are not user-mountable unless the user mount option is supplied among the mount options for the partition’s entry in /etc/fstab.

That said, /run/media/mnt/Localdisk is a mountpoint on what is itself a tmpfs that gets mounted by systemd. It is most certainly not the correct place to mount a partition. If you want that partition available under your home directory, then create a mountpoint ─ i.e. a “folder” ─ for it in your $HOME and tell /etc/fstab to mount the partition to that folder at boot time.

I plan on doing a tutorial on UNIX/POSIX filesystems and permissions later ─ I haven’t had the time yet ─ but for now, I’ll just give you the advice to stop thinking of storage devices along the paradigm of Microsoft Windows or Apple macOS. UNIX systems treat storage not as individual volumes but as a transparent uniform directory hierarchy, regardless of whether something resides on a separate partition (or even another computer in the network) or not.

check ‘users’ group
$ awk -F':' '/users/{print $4}' /etc/group

if user doesn’t exist to users group add user to ‘users’ group
$ sudo usermod -a -G users pulsar

if ‘users’ group doesn’t exist create it and check again.

Check UUID of the drive-
$ sudo blkid

add mount location if doesn’t exist. I will mount in /run/media/user_name/LocalDisk. Since this is the Manjaro’s default mount location.

create folder if doesn’t exist. example-
$ sudo mkdir /run/media/user_name
$ sudo mkdir /run/media/user_name/LocalDisk

give permission to user for this folder
$ sudo chown user_name:users -R /run/media/user_name/LocalDisk

add drive to fstab to autologin in startup
$ sudo vim /etc/fstab

add this line at the end.
UUID=YOUR_UUID /run/media/user_name/LocalDisk btrfs auto,users,exec 0 0

Chekckout what this flags does in here.

NOTE: Same steps can be taken to mount ext4 as user. Edit btrfs to ext4 in fstab.

2 Likes

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