I need to mount an external hard drive, always with some given file permissions on files and directories. I know how to do this once but I do not know how to make these changes permanent so that these permissions stay the same. I do not want to mount the drive manually all the time.
-
https://help.ubuntu.com/community/Mount/USB may be helpful as can https://askubuntu.com/questions/958556/ubuntu-mounts-external-ntfs-drive-as-read-only – K7AAY Jul 19 '18 at 17:00
-
Apart from editing the config file /etc/fstab yourself, you can use the tool Disks that comes with Gnome Shell as explained here: https://askubuntu.com/questions/271516/is-there-a-program-to-mount-all-of-my-drives-automatically – vanadium Jul 19 '18 at 17:03
-
@K7AAY Your link refers to an AskUbuntu post where one-time mounting is done either by clicking or the command line. This user wants it permanently. The title of current question is not appropriate, though. – vanadium Jul 19 '18 at 17:19
1 Answers
To mount any partition automatically and permanently, it has to be included in the configuration file /etc/fstab.
The tool Disks that comes with Ubuntu allows to achieve this using a graphical user interface, See this post on how it works: Is there a program to mount all of my drives automatically?
An alternative - classical - approach is to edit the configuration file /etc/fstab yourself, and add a line that tells the system how and where to mount the partition.
- Determine the unique identifier of your disk. This is easiest with the command
lsblk -f
. You may recognize your ntfs partition because it has "ntfs" as file system type in the column FSTYPE. If not mounted, nothing will be listed under MOUNTPOINT. Take note of the UUID in the similarly named column, because it will be the first entry in the line you will add to /etc/fstab. - Decide on a mount point, i.e., a folder where your partition will be mounted, and where you will see the folders on that partition once it is mounted. As an example, I will assume you will mount it in a folder "windows" under /mnt. Now create that folder:
sudo mkdir -p /mnt/windows
- Open the configuration file /etc/fstab as administrator for editing in a text editor. For example, I use nano.
sudo nano /etc/fstab
Add the following line:
- Determine the unique identifier of your disk. This is easiest with the command
UUID=<UUID_you_found_in_step_1> /mnt/windows ntfs auto,dmask=007,fmask=117,utf8 0 0
This line presents 6 entries, separated by whitespace. 1) The partition you want to mount identified by its UUID; 2) the mount point, i.e. where you will mount it; 3) the file system type; 4) the mount options and 5) and 6) numbers both set to 0 (whether the system should be 'dumped' and whether the system should be checked on startup - the latter you will do regularly in MS Windows). Options set file and folder permissions for the entire drive, and indicate strange characters should be utf8 encoded.
- You can also set owners through fstab options (uid=...,gid=...), but I find it easier to set owners by setting these to the mount point. As such, if you are to be owner and group of the partition, you can set this with the command:
sudo chown $USER:$USER /mnt/windows
$USER will be replaced by the currently logged in user with root permissions (that will be you). You can substitute another login to give the partition to another user.
- Check whether all is good with the command
sudo mount -a
. If there is no output, all is good, and you will see the contents of your partition navigating to the root directory, then mnt and then windows.

- 88,010