If your storage device uses an NTFS file system, you will have read-only access to it. If you want to write to the device, you can install the ntfs-3g driver:

sudo apt-get update
sudo apt-get install ntfs-3g

Run the following command to get the location of the disk partition:

sudo blkid

For example, /dev/sda1.

Create a target folder to be the mount point of the storage device.
The mount point name used in this case is mydisk. You can specify a name of your choice:

sudo mkdir /mnt/mydisk

Mount the storage device at the mount point you created:

sudo mount /dev/sda1 /mnt/mydisk

Verify that the storage device is mounted successfully by listing the contents:

ls /mnt/mydisk

Setting up automatic mounting

You can modify the fstab file to define the location where the storage device will be automatically mounted when the Raspberry Pi starts up. In the fstab file, the disk partition is identified by the universally unique identifier (UUID).

Get the UUID of the disk partition:

sudo blkid

Find the disk partition from the list and note the UUID. For example, 5C24-1453.

Replace FSTYPE with the type of your file system, which you found in step 2 of 'Mounting a storage device' above.

Now that you have set an entry in fstab, you can start up your Raspberry Pi with or without the storage device attached. Before you unplug the device you must either shut down the Pi, or manually unmount it using the steps in 'Unmounting a storage device' below.

Note: if you do not have the storage device attached when the Pi starts, the Pi will take an extra 90 seconds to start up. You can shorten this by adding ,x-systemd.device-timeout=30 immediately after nofail in step 4. This will change the timeout to 30 seconds, meaning the system will only wait 30 seconds before giving up trying to mount the disk.

For more information on each Linux command, refer to the specific manual page using the man command. For example, man fstab.

Unmounting a storage device

When the Raspberry Pi shuts down, the system takes care of unmounting the storage device so that it is safe to unplug it. If you want to manually unmount a device, you can use the following command:

sudo umount /mnt/mydisk

If you receive an error that the 'target is busy', this means that the storage device was not unmounted. If no error was displayed, you can now safely unplug the device.

Dealing with 'target is busy'

The 'target is busy' message means there are files on the storage device that are in use by a program. To close the files, use the following procedure.

Close any program which has open files on the storage device.

If you have a terminal open, make sure that you are not in the folder where the storage device is mounted, or in a sub-folder of it.

If you are still unable to unmount the storage device, you can use the lsof tool to check which program has files open on the device. You need to first install lsof using apt-get: