0

I followed a tutorial on creating a btrfs filesystem. Filesystem was created using:

sudo mkfs.btrfs /dev/sdb /dev/sdc

Seems that the new btrfs filesystem was successfully created:

$ sudo btrfs filesystem show /dev/sdb 
[sudo] password for dwayne:  
Label: none  uuid: ada8b4f3-f4a8-4a9d-a078-2149f5d7fd0c     
Total devices 2 FS bytes used 896.00KiB     
devid    1 size 4.55TiB used 2.01GiB path /dev/sdb  
devid    2 size 4.55TiB used 2.01GiB path /dev/sdc

Mounted it using (as shown in the article)

sudo mount /dev/sdb /mnt

But I cannot write to it:

$ cd /mnt   
$ touch helloworld.txt  
touch: cannot touch 'helloworld.txt': Permission denied  
$ sudo touch helloworld.txt  
$ ls -al  
total 20  
drwxr-xr-x  1 root root   28 Mar  1 00:27 .  
drwxr-xr-x 24 root root 4096 Feb 27 21:27 ..
-rw-r--r--  1 root root    0 Mar  1 00:27 helloworld.txt  
$ df -h .  
Filesystem      Size  Used Avail Use% Mounted on  
/dev/sdb        9.1T 17M  9.1T   1% /mnt

Why does root have permission to write, but no one else does? What have I done wrong?

1

That's the normal state of affairs after creating a new partition and mounting it as root. You have to grant permissions and ownerships using chowm, chmod, setfacl, etc. before anybody other than root can write to it.

When you mount a partition which supports POSIX permissions and ownerships, the mount point is set to be owned by whoever mounted it - usually, root (sudo mount). GUI mounting, which uses udisks, takes care of setting you as the owner of the mountpoint itself.

  • So theres no such thing as mounting a filesystem automatically at boot time by listing it in /etc/fstab 'cause one always has to go and change permissions/ownership on the mount point after the boot (and therefore the mounting) has completed? – Dwayne Moore Mar 1 '17 at 6:40
  • @DwayneMoore not always - if you set the ownership once, the filesystem will remember it. – muru Mar 1 '17 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.