Raspberry Pi : Automount USB

Raspberry Pi  : Automount an USB stick or an HDD for data

Since the Pi boots off an SD card, It is a good idea to store data on a USB connected drive.  This arrangement is vital when using your Pi as a file server to back up data . It also gives you an option to use several storages to expand your NAS with minimal disturbance to the SD card of the Pi.

Overview :

  • Make a folder as a reference point to mount your drive.
  • Plug in and Indentify your drive and drive format.
  • Edit Fstab to automout drive.

Time and Difficulty :

  • Time : 10 to 15 mins  once you have the Pi running on Raspbian.
  • Newbie Difficulty level : Easy ; Will need to use terminal and type in commands.


  1. Plugin your drive into the USB port of the Pi.
  2. type in sudo mkdir /mnt/data  (Create a folder called data inside the folder /media)
  3. type in sudo mount /dev/sda1 /mnt/data  (mount the drive at sda1 at the data folder inside media)
  4. type in sudo fdisk -l  (to see the list of drives and where each drive is mounted at)
  5. You can also use sudo blkid to see the UUID for each of the drives.
  6. type in sudo nano /etc/fstab  (use nano the file editor to edit the file fstab is the file that has a list of drives that automount during startup)

At the bottom of the fstab file add the following line

/dev/sda1      /mnt/data    vfat      defaults      0      0   (if your drive is fat32 format.)


/dev/sda1      /mnt/data    ntfs-3g      defaults      0      0  (if your drive is ntfs format)


/dev/sda1      /mnt/data    ext4      defaults      0      0  (if your drive is ext4 format)

your fstab file should look something similar to this :


Press ctrl + x to exit and save the fstab file.

Now at every boot, the drive will automount at /mnt/data folder .

Note : Ext4 format is native for Linux. For NTFS,  you will need to install ntfs-3g using apt-get . For Apple’s HFS, you will need to install hfsplus, hfsutils and hfsprogs.

7 thoughts on “Raspberry Pi : Automount USB”

  1. My external HDD is in NTFS, so when I type the command
    “sudo mount /dev/sda1 /mnt/data”, I get the following message :

    “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.”

    What should I do ? Can I go on with the rest of the tutorial or do I have to do something else before ?

    I hope someone can answer…

  2. Help ! I am trying to set up a Pi Raspian NAS. First steps went fine, to get “permanent” USB HDD in place and auto-mounted. But i want to spin down the HDD when not in use. I got hd-idle to work. But then the problem. The spun down drive magically starts back up – on its own. hd-idle -t /dev/sda spins it down immediately. Then with the system completely idle (no keyboard, no mouse inputs, no programs), the drive spins back up. /proc/diskstats shows no sda accesses. The down interval can be as short as 15 seconds, or as long as 10 minutes. But it always spins back up. I don’t know linux. I’ve tried dbus-monitor, and systemctl monitor, but they show nothing useful for this issue. How do i find out what is what is waking up the drive ?

Leave a Reply