Written on Saturday, 25 March 2017 at 21:14. Last Modified on Wednesday, 19 January 2022 at 19:12.
Tags: Linux, raspbian.
What’s the best way to auto mount a usb drive or hard disk? What if the filesystem is ntfs? If you want to (permanently) mount a hard disk or usb drive to your debian based system, keep on reading!
To get a list of connected usb disks you can:
sudo blkid
In the screenshot above you can see there are two usb devices:
To be able to use these devices, you have to mount them in a folder. Let’s create two folders:
sudo mkdir /mnt/usb1 sudo mkdir /mnt/hd1
The usb1 folder I’ve created for my usb stick. The hd1 folder for my external hard drive.
We need to take ownership of these folders:
sudo chown -R pi:pi /mnt/usb1 sudo chown -R pi:pi /mnt/hd1
If any of the usb devices is formatted in ntfs, you best install ntfs-3g:
sudo apt-get install ntfs-3g
You best test if mounting is successful, this is the easy way:
sudo mount -o uid=pi -o gid=pi -t ntfs-3g /dev/sda1 /mnt/hd1
I once had a problem with ntfs-3g that was solved by updating everything:
apt-get update apt-get dist-upgrade apt-get rpi-update rpi-update
sudo nano /etc/fstab
As you can see in the screenshot above I’ve used the disk UUID as name to find it. This way, if you unplug your usb flash drive and put it in another usb port, it still works. As type, make sure to use ntfs-3g.
Now you just need to reboot and the disks are both mounted!
sudo reboot
Sources
Site with 💕 made by Eliaslecomte.be