Auto Mount Partitions on Boot (also Windows partitions)

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Fred

Auto Mount Partitions on Boot (also Windows partitions)

Post by Fred »

Introduction:

Lately I have seen a number of people trying to get partitions to mount on boot. This is understandable since Ubuntu, hence Mint, does not auto mount all partitions by default anymore. There is good information on this subject in the wiki but I still see lots of questions so either people aren't understanding or they are not searching the wiki for answers before posting. My purpose here is to give you a quick reference for auto mounting on boot, the three most common partition types.


Discussion:

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 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. The UUID of a partition can be found by typing in a terminal:

sudo vol_id -u /dev/sdxx

To get a listing of all the UUIDs in the system type in a terminal:

sudo blkid

Example: UUID=010619e3-7c2f-43c3-b71f-133f736c8bff /home/fred/data ext3 ...


Instructions:

I will use the CLI to do this as it is faster, and more universal to the various flavors of Mint. If you look at the line you will be pasting into the terminal you can probably figure out what it is doing. 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. You can of course modify the instructions for your own purposes if you wish. Be sure to substitute your user name in place of mine and put the right partition designator in the command.

Be sure to modify the parts in bold to match your system.

To auto mount an ntfs Windows partition in your /home open a terminal and type:

mkdir /home/fred/Windows

sudo su

echo "/dev/sdxx /home/fred/Windows ntfs defaults,umask=007,gid=46 0 0" >> /etc/fstab


To auto mount an ntfs Windows partition in /media open a terminal and type:

sudo mkdir /media/Windows

sudo su

echo "/dev/sdxx /media/Windows ntfs defaults,umask=007,gid=46 0 0" >> /etc/fstab


To auto mount a fat32 data partition in your /home open a terminal and type:

mkdir /home/fred/Data

sudo su

echo "/dev/sdxx /home/fred/Data vfat umask=0000,uid=1000,gid=1000,auto,rw,users 0 0" >> /etc/fstab


To auto mount a fat32 data partition in /media open a terminal and type:

sudo mkdir /media/Data

sudo su

echo "/dev/sdxx /media/Data vfat umask=0000,uid=1000,gid=1000,auto,rw,users 0 0" >> /etc/fstab


To auto mount an ext3 data partition in your /home open a terminal and type:

mkdir /home/fred/Data

sudo su

echo "/dev/sdxx /home/fred/Data ext3 defaults,noatime 0 2" >> /etc/fstab


To auto mount an ext3 data partition in /media open a terminal and type:

sudo mkdir /media/Data

sudo su

echo "/dev/sdxx /media/Data ext3 defaults,noatime 0 2" >> /etc/fstab


The mounting options I used above are typical and can be changed to meet your needs, if you so choose and know what you are doing. Be careful transcribing the above commands. Typos are not allowed. All the spaces and punctuation are required. There are no returns in the above lines.

I hope this is helpful to you and will take some of the mystery out of auto mounting partitions on boot.

Fred
Last edited by Fred on Sat Mar 28, 2009 9:45 am, edited 1 time in total.
revdjenk

Re: Auto Mount Partitions on Boot

Post by revdjenk »

Thanks for the "wiki" on mounting partitions!!


BTW... you were lucky to have logs! and a hut!!
I had to live in a shoebox in the middle of the road!
Fred

Re: Auto Mount Partitions on Boot

Post by Fred »

You are welcome sir. :-)

lol... I will send you the other end of my crying towel. The end that is still dry. :-)

Fred
altair4
Level 20
Level 20
Posts: 11419
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot

Post by altair4 »

Oh great and powerful Fred, I seek guidance and wisdom. Would you happen to know if the LABEL= parameter in fstab can handle things like:

My Book or my personal favorite (E)DI8:H7R :?:

I don't think fstab can handle the space in My Book and I don't know what to make of the "(", ")" and ":" in (E)DI8:H7R. At first I thought that I'd just through quotes around them but I don't think that will work. These aren't on my system or else I'd just remove the spaces and other characters, they're for a .. er.. ah .. friend :wink:
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
proxima_centauri

Re: Auto Mount Partitions on Boot

Post by proxima_centauri »

Fred,

Is there any difference that you know of using "ntfs" or "ntfs-3g" in fstab under filesystem type?
altair4
Level 20
Level 20
Posts: 11419
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot

Post by altair4 »

I had that question to and as always Fred had the answer:
http://forums.linuxmint.com/viewtopic.php?f=90&t=22073
Fred wrote:altair4,
In the later versions of Mint, ntfs-3g is called automatically when using ntfs mounting in fstab. ntfs-3g has improved tremendously in the past year or so. Very few problems are now popping up when reading and writing to ntfs partitions these days.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
Fred

Re: Auto Mount Partitions on Boot

Post by Fred »

altair4 wrote:
Oh great and powerful Fred, I seek guidance and wisdom.
lol... A worthy and admirable goal, no doubt. Not sure you will find much of it here however. Please send me some of whatever you are smoking or drinking, ASAP. By-the-way, you need to partake of either more or less of it. Don't really know which. :-)

Looks like Theo's fstab labels. The best advice is to get rid of them, but I already gave that advice 6 - 8 months ago. :-)

I have found the hard way that labels should be composed of text characters only, no symbols or spaces. You can get other combinations to work in fstab but some routines won't play nice with anything but text. rsync immediately comes to mind as an example.

Having said that, almost anything will work in fstab if you enclose it in quotes as long as it doesn't exceed 15 places and doesn't begin or end with a space or comma. "My (E)DI8:H7R B" works in fstab, but don't expect anything else that might need to read a label to be able to use it.

If I guessed right and you are asking about Theo's fstab, look closely at his mounting stanzas. Sometimes he has a problem constructing them. After all, fstab isn't the easiest config file to build from scratch.

@proxima_centauri

What altair4 said. :-)

Fred
Fred

Re: Auto Mount Partitions on Boot

Post by Fred »

sontom115,

Well, since you offered. I am old, ugly, poor, not particularly smart and not very nice. Any assistance you can offer on any of these issues would be greatly appreciated. :-)

Fred
smac

Re: Auto Mount Partitions on Boot

Post by smac »

Hi there, hoping this thread still has the attention of some fstab gurus....

I am auto mounting a fat32 partition to use as a location for Firefox and Thunderbird/Lightning profiles I want to share with the occasional WinXP session.

I followed the instructions above and have the partition happily booting, mounted on /home/user/Boot (Boot is just a dummy directory solely for this prurpose). After a lot of messing about with it I now also mostly understand what the hell fstab is doing....an added bonus!

All good so far. Moved the Firefox profile in there, all good. Move the Thunderbird profile in there, mostly good. The email functions are fine, but the calendar (Lightning) dies a horrible messy death. After many hours trolling the net I found a comment that for Lightning to work from another partition in must have 'exec' rights. Now I'm getting soemwhere I thought....I thought I had firgured that this was a simple change to the fstab line that mounts the fat32 partition, but now I think I am still having problems because the point I am mounting it to ("Boot")doesn't have exec rights.....maybe.

Am I on track? Can anyone help out with the fstab configuration needed to make my auto mounting fat32 partition, and the point I mount it to, have exec rights?
Fred

Re: Auto Mount Partitions on Boot

Post by Fred »

smac,

Let me try to understand what you have done. You have successfully mounted your fat32 data partition as "Boot" in your home and moved the hidden config files to that folder. Is that correct?

Now, how are you using them? Do you have symlinks in your home folder pointing to them or are you doing it some other way?


@ranmori and elena01

You are both quite welcome here. :-)

Fred
Fred

Re: Auto Mount Partitions on Boot

Post by Fred »

martinson wrote:
In my experience of putting "auto, user" in "fstab", the folder which is the mount point becomes owned by root, not user
No, not necessarily. It depends upon the ownership of the mount point. As an example: If you create a folder in /mnt or /media to mount to you must be root which gives root ownership of the mount point. You must then be root to have privileges over and above what root has set for you, the user, when accessing that mounted partition. If the mount point is created in the user's home by that user then the mount point will be owned by that user and s/he controls the privileges of any folder trees created through that mount point. The user ownership will automatically transfer to the newly created folder tree in the mounted partition.

Using "users" in fstab enables more than one user to access the partition at the same time, or any registered user, in a multi user setup. This is particularly useful when you have multiple users with a mount point in each user's home for the same Data partition.

As far as how difficult the answer to the thread starter's question is, you may be right. But right now I am not even sure exactly what the question is or the current state of his system. If you cyphered that information out, you are ahead of me. :-)

Fred
smac

Re: Auto Mount Partitions on Boot

Post by smac »

Geez I go away for a couple days and all sorts of helpfulness breaks out :wink:

Think I got things sorted. I think the permissions was a red herring and I was actually having some version conflicts between thunderbird and lightning. I did a little more reading and learned to query the permissions on my mount point, and was getting back rwxrwxrwx so it wasn't permissions. I did a clean install of the new Mint which I think gave me a new version of thunderbird and bingo, calendar is sweet running from the fat32 partition.

This is all without changes to fstab so the original instruction are all good. Of course.

I now have a new and different issue with my network but that's another thread :roll:

Thanks all
User avatar
linuxviolin
Level 8
Level 8
Posts: 2081
Joined: Tue Feb 27, 2007 6:55 pm
Location: France

Re: Auto Mount Partitions on Boot

Post by linuxviolin »

Hmm, "The legacy /dev/sdxx identifier" works quite well! Debian uses it and there is, and I have, no problems with it! But UUID is... crap! :roll:

About noatime, I guess there is not need of "defaults" with it, just noatime is/should be sufficient (and maybe also "errors=remount-ro" for /)

e.g. in my Debian Testing box and with JFS:
/dev/sda1 / jfs noatime,errors=remount-ro 0 1
/dev/sda5 /home jfs noatime 0 2
K.I.S.S. ===> "Keep It Simple, Stupid"
"Simplicity is the ultimate sophistication." (Leonardo da Vinci)
"Everything should be made as simple as possible, but no simpler." (Albert Einstein)
Fred

Re: Auto Mount Partitions on Boot

Post by Fred »

linuxviolin,

Sid is now using UUID, but I totally agree that it is, shall we say, less than optimal. :-) I use labels myself but as you can see I give the instructions for legacy.

Yes, "default" is probably not necessary in most cases, but the instructions are more or less generic for many versions and flavors of Mint. I never know if they are going to slip something into the default basket that might be necessary, so I threw it in. Using it first and then setting "noatime" should pretty much wipe out the default settings. It shouldn't cause any harm and it might be needed in some cases.

The root was not included in this post. It was for data partitions. :-)

Fred
moshari

Re: Auto Mount Partitions on Boot

Post by moshari »

Hi all!

Absolutely fantastic instructions, very easy to follow, thank you fred. I have used a few of you tips along the way.

Also works very well for Logical Volumes as well. Just have be careful to type the names correctly.

Yes I wasted an hour on that one. LOL
User avatar
linuxviolin
Level 8
Level 8
Posts: 2081
Joined: Tue Feb 27, 2007 6:55 pm
Location: France

Re: Auto Mount Partitions on Boot

Post by linuxviolin »

Fred, just en passant, this thread is quite good except rather: /dev/sdxx /media/Data ext3 defaults,noatime 0 2
like in one of your examples, maybe I would give: /dev/sdxx /media/Data ext3 defaults,noatime 1 2 (just for a partition of course, for floppy or cdrom it's 0 0)

And I guess I prefer mount in /mnt, I prefer to keep /media for the media which mount on the fly, like a USB stick for example.

For people who do not know the meaning of the last two columns of the line, the two last numbers:
<5th and 6th columns: Dump and fsck options >

dump is a backup utility and fsck is a filesystem check utility. (...).

The 5th column in /etc/fstab is the dump option. Dump checks it and uses the number to decide if a filesystem should be backed up. If it's zero, dump will ignore that filesystem.

The 6th column is a fsck option. fsck looks at the number in the 6th column to determine in which order the filesystems should be checked. If it's zero, fsck won't check the filesystem.
5. dump-freq adjusts the archiving schedule for the partition (used by dump).
6. pass-num indicates the order in which the fsck utility will scan the partitions for errors when the computer powers on. 0 = none, 1 = first, 2 = next (and all others in order)
K.I.S.S. ===> "Keep It Simple, Stupid"
"Simplicity is the ultimate sophistication." (Leonardo da Vinci)
"Everything should be made as simple as possible, but no simpler." (Albert Einstein)
Fred

Re: Auto Mount Partitions on Boot

Post by Fred »

I guess I prefer mount in /mnt, I prefer to keep /media for the media which mount on the fly, like a USB stick for example.
/mnt is the old time, traditional mount point. Then /media came along. In Ubuntu/Mint, unless it has changed in the last release, /media contains the default mount points for fixed, mount on boot, storage. /mnt is where the machine generated boot line for on-the-fly mounts go, ie. USB sticks. The mount point then gets placed in /media. I was just trying to stay with the Ubuntu/Mint convention.

I left the dump bit 0 because I don't know if the user is using that function. Most probably not. There are a number of ways to configure dump. I figured if anybody was using it, or decided to use it, they should know enough to know how and what partitions to change to meet their needs. Doing a dump by mistake of a 750 Gig. partition could have disastrous results on an install if not specified properly. So I just played it safe. :-) Granted, it was a somewhat arbitrary decision.

Fred
User avatar
linuxviolin
Level 8
Level 8
Posts: 2081
Joined: Tue Feb 27, 2007 6:55 pm
Location: France

Re: Auto Mount Partitions on Boot

Post by linuxviolin »

Hi Fred! Always clear, informative and full of knowledge, this is how we love the Fred :lol: (sorry for this little joke, but it's true! :P )

/mnt is the "historic" mount point we/I retain for file systems mounted manually. /media is where is mounted the removable devices managed by the system automatically. For cdrom/dvd and floppy, I use a fixed mount point, so defined in fstab, in /mnt. But the place of the mount point does not really matter if it is properly done. And ok about the Ubuntu/Mint convention... :-)

About dump, maybe I can be with you.
Fred wrote:I figured if anybody was using it, or decided to use it, they should know enough to know how and what partitions to change to meet their need
Yes, probably. :-)

Just for the record, Dump = 1 is the default for CentOS, and so for Red Hat, at least. But it's not the same kind of distro than Ubuntu/Mint... ;-)
Last edited by linuxviolin on Tue Aug 25, 2009 11:27 am, edited 1 time in total.
K.I.S.S. ===> "Keep It Simple, Stupid"
"Simplicity is the ultimate sophistication." (Leonardo da Vinci)
"Everything should be made as simple as possible, but no simpler." (Albert Einstein)
altair4
Level 20
Level 20
Posts: 11419
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot

Post by altair4 »

Since we're all voicing an opinion...........

The system will automatically mount all those external USB storage devices to /media and create a mount ICON on the desktop. That's fine with me. If I mount something through fstab I put the mountpoint in /mnt so that it doesn't create a mount icon on the desktop.

I also place Windows partitions defined in fstab in a /windows mount point ( which also does not add a mount icon to the desktop ). I have been told that that this should never be done but I've never been given an explanation as to why. Is it just an aesthetics thing in that it's not part of the linux hierarchy or is there an actual technical reason for this?
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
Fred

Re: Auto Mount Partitions on Boot

Post by Fred »

altair4 wrote:
Is it just an aesthetics thing in that it's not part of the linux hierarchy ... ?
For the most part, yes. :-)

Fred
Locked

Return to “Tutorials”