Beginners Guide: Adding USB Storage, Linux Formatting and Permissions
#3
Mounting the Partition/FileSystem



In order for the filesystem to be written to and read off, linux needs to "mount" the filesystem. Most Distros mount partitions automatically on boot, so if you reboot your board, you should see your new partition mounted after the next boot. 

Code:
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/rock64/8ed85af6-dc70-42a5-ba49-c5bdda0a426e
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 /


it is mounted here according to its partition UUID. However if you want more granularity, you can mount the filesystem/partition manually. 

Firstly, unmount the mounted FS: 


Code:
sudo umount /dev/sda1 

You can also use the mountpoint as the argument to unmount it, I just find using /dev/ easier to type or remember

Code:
sudo umount /media/rock64/8ed85af6-dc70-42a5-ba49-c5bdda0a426e

Confirm its been unmounted: 

Code:
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
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 /




For manually mounting and unmounting, there are two tools that can be used: mount and pmount. 

pmount is a wrapper for the standard mount program and simplifies mounting and unmounting and allows a normal user to mount and unmount without root privileges. 

Make sure you have internet connection and install pmount with the following command: 

Code:
sudo apt install pmount

Confirm by typing in "y" followed by the enter key to install pmount. 

After it is installed, invoke it to show current mounts and confirm that it is installed: 

Code:
rock64@rock64:~$ pmount
Printing mounted removable devices:
/dev/mmcblk1p7 on / type ext4 (rw,relatime)
/dev/mmcblk1p6 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
To get a short help, run pmount -h

Mounting using pmount is exceptionally easy, you simply invoke the command with the first argument being the partition, and the second one being the mount location. In this case, lets say we want to mount it in a directory in /media/ . 


Code:
rock64@rock64:~$ pmount /dev/sda1 /media/USB-test


.... And thats it! The filesystem on /dev/sda1 has been mounted on /media/USB-test. I didnt have to make a "USB-test" directory or anything, pmount did everything for me.


We can confirm it's been mounted using the lsblk tool: 

Code:
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-test

Unmounting is done using the pumount command: 

Code:
sudo pumount /dev/sda1



If you want to use the standard "mount" command that comes with almost all linux distributions, you'll need to do some preparation before mounting the partition. 


Before you mount the partition, you will need to make sure that the mount directory exists. Create a new directory inside /media/ 


Code:
sudo mkdir /media/USB-test2 


Use "ls" to confirm creation: 


Code:
rock64@rock64:~$ sudo mkdir /media/USB-test2
rock64@rock64:~$ ls /media/
pm1  rock64  USB-test2


Mount the FS to the mount point ( "-t auto" means that we will let the mount tool automatically sort out the filesystem complexities) with the Partition as the first argument and the mount point as the second argument: 


Code:
rock64@rock64:~$ sudo mount -t auto -o rw /dev/sda1 /media/USB-test2/ 
sudo mount -t auto /dev/sda1 /media/USB-test2/ 
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-test2
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 /


You can unmount the FS using the unmount tool: 


Code:
rock64@rock64:~$ sudo umount /dev/sda1
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
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 /



Mounting using fstab will be covered in another guide, later on, I will link it back here.



  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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginners Guide: Migrating to SSD rontant 18 40,111 01-19-2022, 09:30 AM
Last Post: Ellesar Dragon
  Step by step guide PXE diskless configuration. burglar_ot 13 35,943 11-01-2020, 11:26 PM
Last Post: michael.gruner
Thumbs Up A guide for how I made RetroPie, RetroArch, and EmulationStation Work on the Rock64 Mrfixit2001 4 16,155 12-17-2018, 03:52 AM
Last Post: va88
  Guide - XRDP - Debian Stretch / Ubuntu Xenial / OMV S3phi40T 3 14,029 05-05-2018, 06:08 AM
Last Post: S3phi40T
Information Guide - Raid Array (Raid 0) Ptheven 0 4,849 10-07-2017, 09:22 AM
Last Post: Ptheven
Information Guide - Setting up a NFS Share Ptheven 0 5,519 09-26-2017, 04:44 AM
Last Post: Ptheven
  Guide - Setting up a SMB(Windows) file server Ptheven 0 12,634 08-21-2017, 08:54 AM
Last Post: Ptheven
Information Beginners Guide: Locating your board, connecting to it. Ptheven 5 15,996 08-21-2017, 04:12 AM
Last Post: Ptheven

Forum Jump:


Users browsing this thread: 1 Guest(s)