Auto Mount Partitions on Boot (also Windows partitions)

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

Auto Mount Partitions on Boot (also Windows partitions)

Postby Fred on Fri Feb 13, 2009 12:06 am

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.
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Linux Mint is funded by ads and donations.
 

Re: Auto Mount Partitions on Boot

Postby revdjenk on Tue Mar 10, 2009 8:32 am

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!
Malachi 3:10 NRSV
...says the LORD of hosts... I will not open...windows...for you...

Linux user since 2001 pda; 2006 lappy
revdjenk
Level 4
Level 4
 
Posts: 338
Joined: Sat Nov 15, 2008 2:51 pm

Re: Auto Mount Partitions on Boot

Postby Fred on Tue Mar 10, 2009 8:44 am

You are welcome sir. :-)

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

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Auto Mount Partitions on Boot

Postby altair4 on Tue Mar 10, 2009 9:51 am

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.
altair4
Level 15
Level 15
 
Posts: 5508
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot

Postby proxima_centauri on Tue Mar 10, 2009 9:56 am

Fred,

Is there any difference that you know of using "ntfs" or "ntfs-3g" in fstab under filesystem type?
User avatar
proxima_centauri
Level 11
Level 11
 
Posts: 3968
Joined: Tue Dec 25, 2007 3:24 pm
Location: NB, Canada

Re: Auto Mount Partitions on Boot

Postby altair4 on Tue Mar 10, 2009 10:19 am

I had that question to and as always Fred had the answer:
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.
altair4
Level 15
Level 15
 
Posts: 5508
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot

Postby Fred on Tue Mar 10, 2009 11:07 am

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Auto Mount Partitions on Boot

Postby sontom115 on Fri May 15, 2009 11:03 pm

Hi all :D
Can i help you? :o


Edit by Husse - spam post with the link hidden - link removed, user banned
sontom115
Level 1
Level 1
 
Posts: 1
Joined: Fri May 15, 2009 11:01 pm

Re: Auto Mount Partitions on Boot

Postby Fred on Sat May 16, 2009 2:26 am

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Auto Mount Partitions on Boot

Postby smac on Thu May 21, 2009 6:57 pm

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?
smac
Level 1
Level 1
 
Posts: 34
Joined: Wed Apr 29, 2009 4:49 pm

Re: Auto Mount Partitions on Boot

Postby Fred on Tue May 26, 2009 5:26 am

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Auto Mount Partitions on Boot

Postby flaminglemon on Thu May 28, 2009 9:30 pm

Question. Why doesn't Ubuntu/Mint auto mount drives anymore? Is there a reason why they took it out?

Also, hi! I'm new here. Also new to using Linux as a personal OS. :mrgreen:
flaminglemon
Level 1
Level 1
 
Posts: 12
Joined: Wed May 27, 2009 7:30 pm

Re: Auto Mount Partitions on Boot

Postby martinson on Thu May 28, 2009 11:48 pm

Hi smac.
You asked about whether you need "exec rights" to use a mount point, i.e. a folder that a partition had been mounted to.
Did you mean rights to execute a file in that partition? Or did you mean that you might need to be root to use that partition?

Possibly the problem is due to a typing error in the instructions, from Fred, concerning the word "users". I read elsewhere that the word in fstab should be "user", without an "s". I'm not sure if this is the problem.

I found out a bit about fstab from this webpage: http://www.tuxfiles.org/linuxhelp/fstab.html .
It says this:
> About "user" and "nouser". These are very useful options.
> The user option allows normal users to mount the device,
> whereas nouser lets only the root to mount the device.
> nouser is the default, which is a major cause of headache for new Linux users.
> If you're not able to mount your cdrom, floppy, Windows partition,
> or something else as a normal user, add the user option into /etc/fstab.

This word "user" may not be needed, I don't know.
If this device is mounted automatically, during boot up, which happens when "fstab" contains "auto", then maybe thus word "user" has no effect, because the partition is being mounted automatically at boot up time, not mounted by a user.

In my experience of putting "auto, user" in "fstab", the folder which is the mount point becomes owned by root, not user. This means that the user, (me or you), will only be able to read from the disk, not write to it. But I'm using Kubuntu 9.04, not Mint, so you may have better luck.

This may be harder than Fred thought. If anyone gets this to work, please let us know here.
martinson
Level 1
Level 1
 
Posts: 2
Joined: Thu May 28, 2009 11:03 pm

Re: Auto Mount Partitions on Boot

Postby Fred on Fri May 29, 2009 1:13 am

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Auto Mount Partitions on Boot

Postby smac on Sun May 31, 2009 11:27 pm

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
smac
Level 1
Level 1
 
Posts: 34
Joined: Wed Apr 29, 2009 4:49 pm

Re: Auto Mount Partitions on Boot

Postby linuxviolin on Mon Jun 01, 2009 9:11 pm

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)
User avatar
linuxviolin
Level 8
Level 8
 
Posts: 2055
Joined: Tue Feb 27, 2007 6:55 pm
Location: France

Re: Auto Mount Partitions on Boot

Postby Fred on Mon Jun 01, 2009 11:32 pm

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Auto Mount Partitions on Boot

Postby swsetiadi on Sat Jul 04, 2009 11:08 am

Thank you for the instructions, very easy to follow and works like a charm. Somehow I needed to do an extra step, taking ownership of the partition by using this command: sudo chown fred:fred /home/fred/Data.

(I am very new to Linux, so it took me a while to figure this out).

Again, THANK YOU!
swsetiadi
Level 1
Level 1
 
Posts: 2
Joined: Mon Jun 29, 2009 11:58 pm

Re: Auto Mount Partitions on Boot

Postby moshari on Sun Aug 02, 2009 7:44 am

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
moshari
Level 1
Level 1
 
Posts: 8
Joined: Sun Jun 14, 2009 1:13 am
Location: Melbourne, Australia

Re: Auto Mount Partitions on Boot

Postby linuxviolin on Mon Aug 24, 2009 11:19 pm

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)
User avatar
linuxviolin
Level 8
Level 8
 
Posts: 2055
Joined: Tue Feb 27, 2007 6:55 pm
Location: France

Linux Mint is funded by ads and donations.
 
Next

Return to Tutorials / Howtos

Who is online

Users browsing this forum: No registered users and 24 guests