Beginners Guide: Adding USB Storage, Linux Formatting and Permissions
#4
Information 
Setting appropriate directory and file permissions



We are almost done! 

Since the mkfs.ext4 ran under superuser privileges, the permissions in the filesystem needs to be modified if you wish to write to it with any user other than root. 

Mount the ext4 filesystem using any of the means mentioned above. 

Code:
Code:
rock64@rock64:~$ pmount /dev/sda1 /media/USB-test3
rock64@rock64:~$ lsblk 
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    1 14.9G  0 disk 
└─sda1        8:1    1 14.9G  0 part /media/USB-test3
mmcblk1     179:0    0 29.8G  0 disk 
├─mmcblk1p1 179:1    0  3.9M  0 part 
├─mmcblk1p2 179:2    0   64K  0 part 
├─mmcblk1p3 179:3    0    4M  0 part 
├─mmcblk1p4 179:4    0    4M  0 part 
├─mmcblk1p5 179:5    0    4M  0 part 
├─mmcblk1p6 179:6    0  112M  0 part /boot/efi
└─mmcblk1p7 179:7    0 29.7G  0 part /



Navigate to the mount point using cd: 

Code:
Code:
rock64@rock64:~$ cd /media/USB-test3/



We will try making a file using the current user (rock64). Use the touch command to try to make a file with that user: 

Code:
Code:
touch test




You will see that you will be unable to make a file. However if you try again using the root user, it should work, showing you need to address the permissions. 

[Image: Rciuk5h.png]

Navigate up a directory 

Code:
Code:
cd ..

To give permission to the current user (rock64 in this case), you will need to use the chown command: 
Code:
Code:
chown -R user:user directory/

"-R" stands for recursive, it means the mountpoint and all directories/files within it. We need root privileges to change permissions so in our case, the command would be: 
Code:
Code:
sudo chown -R rock64:rock64 USB-test3/


[Image: 6VXZVae.png]
After changing the permissions, you should be able to navigate back into the mounted filesystem and write to files. 
Code:
Code:
rock64@rock64:/media$ cd USB-test3/
rock64@rock64:/media/USB-test3$ touch test
rock64@rock64:/media/USB-test3$ ls
lost+found  test
rock64@rock64:/media/USB-test3$ touch test2
rock64@rock64:/media/USB-test3$ ls
lost+found  test  test2



If you want to give full permissions to ANY user to that directory, you need to use the chmod command to do that: 
Code:
Code:
chmod -R a+rwX directory/


We need to invoke superuser for that command, and after navigating out of the directory, in our case it would look like: 
Code:
Code:
rock64@rock64:/media$ sudo chmod -R a+rwX USB-test3/


Its absolutely not required at this level, but if you'd like to learn more about linux file permissions, I've found the following writeups quite handy: 
https://www.digitalocean.com/community/t...ermissions
https://www.linux.com/learn/understandin...ermissions
  Reply


Messages In This Thread
Formatting the drive for Linux use - by Ptheven - 08-15-2017, 08:23 AM
Mounting the Partition/Filesystem - by Ptheven - 08-15-2017, 09:30 AM
Setting appropriate directory and file permissions - by Ptheven - 08-16-2017, 01:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Step by step guide PXE diskless configuration. burglar_ot 13 12,116 11-01-2020, 11:26 PM
Last Post: michael.gruner
  Beginners Guide: Migrating to SSD rontant 17 19,796 05-24-2019, 12:23 PM
Last Post: thatchunkylad1989
Thumbs Up A guide for how I made RetroPie, RetroArch, and EmulationStation Work on the Rock64 Mrfixit2001 4 9,496 12-17-2018, 03:52 AM
Last Post: va88
  Guide - XRDP - Debian Stretch / Ubuntu Xenial / OMV S3phi40T 3 9,518 05-05-2018, 06:08 AM
Last Post: S3phi40T
Information Guide - Raid Array (Raid 0) Ptheven 0 2,803 10-07-2017, 09:22 AM
Last Post: Ptheven
Information Guide - Setting up a NFS Share Ptheven 0 3,386 09-26-2017, 04:44 AM
Last Post: Ptheven
  Guide - Setting up a SMB(Windows) file server Ptheven 0 9,907 08-21-2017, 08:54 AM
Last Post: Ptheven
Information Beginners Guide: Locating your board, connecting to it. Ptheven 5 8,776 08-21-2017, 04:12 AM
Last Post: Ptheven

Forum Jump:


Users browsing this thread: 1 Guest(s)