Auto-mounting is something that doesn’t happen automatically in recent Linux distros. This can be irritating for a number of reasons if there is content on a partition that you use frequently. In my case I use a NTFS partition to create a shared space for my Linux Mint and Windows 7 operating systems; storing things like photos, music and downloads.
The problem occurs when you open your music player and try to play a song or playlist: the files cannot be found. Every time you reboot you need to use Files (the file manager or explorer for Linux Mint) to mount the partition before everything will work.
Fortunately there a number of ways you can auto-mount your partitions when your operating system boots. First I will quote some GUI methods (which are not necessary and may not work properly) taken from altair4
“It’s my [altir4] understanding that ntfs-config no longer works. In any event the very first thing it does when you used to lauch the program is ask you if you want to “enable write support” for your ntfs partitions. NTFS (via ntfs-3g) has had write support enabled by default for a very long time so I’m not exactly sure what it’s enabling.”
“For something that’s supposed to be a tool for new users to use it has to be the most confusing application I’ve ever seen. The developer basically codified “man mount”. The user is presented with every possible parameter available and has to figure out which are applicable and which are not. The irony here is that rather than being something for the new user; to use it requires a knowledge of mounting parameters that an experienced user would [already] have. And I’m guessing an experienced user would use gedit [anyway].”
“Probably the most benign of the group as it’s more conversational than the “check what obscure parameter you want to use” method of mountmanager. But even here it can produce unexpected results and depending on what you want want to do still requires you knowing more about what a given parameter actually does that one might expect.”
CLI (Manual Setup)
My understanding from altair4’s review was that is good to understand how it all works, and once you understand it’s just as straight forward to set up auto-mounting manually (Fred offers a detailed introduction to doing this here
“In order to auto mount a partition on boot, two criteria must be met. First, you must have a folder somewhere in the Linux file system to be used as a mount point. It can be named anything you wish. By convention, it should be located in /media and/or /home, but it could be placed almost anywhere you wish. I would urge you to refrain from putting it in other places as it is almost always better to stick with the assumptions that time has proven to be the most practical and serviceable.”
The second criteria is you must put the appropriate mounting lines in your /etc/fstab file to bind or mount the partition to the folder you have chosen to be the mount point. The fstab file is run on system boot and does the mounting operation automatically as defined therein.
There are currently three partition identifiers in common usage:
- The legacy /dev/sdxx identifier
- The Label partition identifier
- The UUID Identifier (the default used by Ubuntu and Mint)
“The legacy /dev/sdxx identifier has been around since dirt was still clean. This is the identifier you see on the far left of the Gparted partition table screen. With the mixed use of multiple types of storage media this type of identifier can present some problems so other unique identifiers have been developed.”
Example: /dev/sda3 /home/fred/data ext3 …
“Label is an alternative partition identifier that I personally favor that uses readable text as the unique identifier. The easiest way to assign text labels to partitions is probably to use one of the later versions of Gparted. There is an option to assign a text label to a selected partition in the GUI.”
Example: LABEL=Data1 /home/fred/data ext3 …
“The third method, which is the default used by Ubuntu and Mint, is UUID. UUID is a string of characters, letters numbers, generated by the computer to uniquely identify a partition.”
In the instructions below I will use the legacy partition identifiers and place the mounting folder in my home folder or in the /media folder.
Be sure to modify the parts in bold to match your system.
First use the following command to get a listing of all the UUIDs, Labels and legacy identifiers for your system.
Remember that in order to mount a partition we need a folder to use as a mount point:
sudo mkdir /media/Dowloads
We then need to edit the fstab file in order to point/mount the partition to the mount point we created:
sudo su [Switch to the root user]
echo “/dev/sda6 /media/Downloads ntfs defaults,umask=007,gid=46 0 0″ >> /etc/fstab [Insert “*” into “*”]
If everything was entered correctly that is pretty much the end of it. You can check if it worked using the following (or restarting):
sudo mount -a
If you are like me you won’t get it right the first time round. To correct the faulty line (or even just do it this way in the first place), edit fstab using gedit:
sudo gedit /etc/fstab
On Linux file systems partition permissions are set after you mount it (using chmod and chown); these changes are persistent (i.e. once you change ownership and/or permissions you don’t have to do it again). On Windows file systems permissions and ownership need to be specified during the mount process. This is done by setting the umask, uid and gid parameters in fstab.
Reproducing the the line inserted into fstab (for reference):
/dev/sda6 /media/Downloads ntfs defaults,umask=007,gid=46 0 0
/dev/sda6 /media/mpoint ntfs-3g default 0 0
/dev/sda6 /media/sda6 ntfs nls=iso8859-1, ro, umask=000, user 0 0
“umask=007 allows owner (first digit) and group (second digit) to have full read write access. All others (the third digit) will have no access.” Setting “umask=000 will make the mount point read/write accessible by everyone.”
“gid=46 is the group id. 46 is plugdev and all local login users are in group plugdev.” Using user instead of gid=46 “allows the user to mount and unmount the partition. That’s great except it doesn’t work because the only user at the time fstab is executed is root.” “What’s not explicit is that the owner is root.”
“Fred could have added one more option: uid=1000. That would have changed the default owner of root to fred (1000). But since fred is also in plugdev it is not needed.”
Adding “ro” will make the mount point read only.
Other File Systems:
Note that depending no the filesystem used by the partition the line you write to fstab will differ, for example:
fat32 data partition
echo “/dev/sdxx /media/Data vfat umask=0000,uid=1000,gid=1000,auto,rw,users 0 0″ >> /etc/fstab
ext3 data partition
echo “/dev/sdxx /media/Data ext3 defaults,noatime 0 2″ >> /etc/fstab
Hopefully this information I have collated makes it easier for others to auto-mount partitions in the future.