Auto-mount USB on a raspberry pi

Auto-mount USB on a raspberry pi

How to setup mount / auto-mount USB Hard Drive

Follow the simple steps in the order mentioned below to have your USB drive mounted on e.g.
your Raspberry Pi every time you boot it.

These steps are required especially if your are setting up a Samba share,

or a 24×7 torrent downloader,
or alike where your Raspberry Pi must have your external storage already mounted and ready for
access by the services / daemons.

Step 0.

Plug in your USB HDD / Drive to Raspberry Pi.

If you are using a NTFS formatted drive,

install the following:

sudo apt-get install ntfs-3g

Stsudo raspi-config, onlyep 1.

Log on RasPi using SSH terminal and execute:

ls -l /dev/disk/by-uuid/

You will see something like the following:

lrwxrwxrwx 1 root root 10 Jan 1 1970 0AC4D607C4D5F543 -> ../../sda1

Note down the value of the UUID –> 0AC4D607C4D5F543

Step 2.

Create a location for mount point:

sudo mkdir /media/NASDRIVE

Give proper permission:

sudo chmod 775 /media/NASDRIVE

advertentie :

Step 3.

Mount the USB Drive and then check if it is accessible at /media/NASDRIVE

sudo mount -t ntfs-3g -o uid=,gid= /dev/sda1 /media/NASDRIVE

Note:
ntfs-3g for NTFS Drives = e.g. pi
vfat for FAT32 Drives
ext4 for ext4 Drives

Step 4.

Now, we will configure RasPi to do this after every reboot:

Take a backup of current fstab

sudo cp /etc/fstab /etc/fstab.backup

Add the mount information in the fstab file (sudo nano /etc/fstab):
UUID=0AC4D607C4D5F543 /media/NASDRIVE ntfs-3g rw,defaults 0 0

Step 5.

Reboot

Turn on the GUI mode by

sudo raspi-config,

only if required.

You should see your USB drive automatically mounted at /media/NASDRIVE

Huizebruin.nl

Oprichter van huizebruin.nl
Abonneer
Abonneren op
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Reacties
Inline feedback
Bekijk alle reacties