Mount a storage device / drive.

With Linux, to use a storage device, you must mount it.

For this tutorial I use a USB stick of 32GB, with a partition formatted in NTFS.

1 : Before connecting the storage device, run the following command : sudo blkid you should see something like that :

2 : Connect your storage device (USB Stick, HDD etc.) to your Raspberry Pi and run the following command again : sudo blkid you should have a new line that tells us that the device is called “sda1” and is formatted as “NTFS”.

Take note of the path “/dev/sda1”, at your place it will be may be “/dev/sdb1″ ou “/dev/sdc1″… and UUID which is a hexadecimal suite for example : 0A84BF770A84BF77.

3 : Create a mount point for your storage device with the command : sudo mkdir -p /mnt/mymedia. Here our mount point is called “mymedia” but you can call it as you wish, exemple “mkdir /mnt/abcd”.

4 : To be sure to not having problems with access to the mounted directory, we will assign it to the user “pi” with the following commands :

sudo chown -R pi:pi /mnt/mymedia

5 : As our storage device is formatted in NTFS, we will instill the “ntfs-3g” with the command : sudo apt-get install ntfs-3g -y

6 : To mount your device on every start of the Raspberry Pi, we will add a line in the file “fstab”, to do it :

6.1 : Type the following command : sudo nano /etc/fstab

6.2 : Add the following line before the comments : UUID=0A84BF770A84BF77  /mnt/mymedia  ntfs-3g  defaults  0  0 . Your “fstab” file should look like this :

Type ctrl+o then ENTER to save the changes, type ctrl+x to exit the editor.

The advantage of mounting with the “UUID” is that if you plug your storage device into another USB port, it will always be mounted.

7 : We will mount our device for the first time with the following command : sudo mount -o uid=pi -o gid=pi -t ntfs-3g /dev/sda1 /mnt/mymedia

8 : We rebooted with the command : sudo reboot now

9 : Once rebooted, log in with SSH and type the command ls /mnt/mymedia to see if the contents of your device are listed.

It’s not more complicated than that 🙂

2 Replies to “Mount a storage device / drive.”

  1. Mount is denied because the NTFS volume is already exclusively opened.
    The volume may be already mounted, or another software may use it which
    could be identified for example by the help of the ‘fuser’ command.

    i get this error what should i do?

    1. 1. At what stage does it happen exactly?
      2. Is there anything in your “/etc/fstab” file that refers to your volume?
      3. When you execute the command “sudo blkid” you see your mounted volume?
      4. When you execute the “fuser” command do you see which application uses this volume?

Leave a Reply

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