Auto Mount Partitions on Boot (also Windows partitions)

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
aelfinn
Level 3
Level 3
Posts: 193
Joined: Thu Dec 11, 2008 2:11 pm

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by aelfinn »

altair4 wrote:All entries in fstab mount as owned by root.
And that cannot be influenced with the "user(s)" or "group" mount options?

Would the chmod changes have to be applied every time I log in? Or is there a way to mount the partition other than via fstab, so that the appropriate permissions can be set at mount time?
altair4
Level 20
Level 20
Posts: 10265
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by altair4 »

On Windows file systems you can use umask, uid and gid to set the permissions and ownership at mount time in fstab.

EDIT: For example using freds template for ntfs:
/dev/sdxx /home/fred/Windows ntfs defaults,umask=007,gid=46 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.
gid=46 is the group id. 46 is plugdev and all local login users are in group plugdev.
What's not explicit is that the owner is root.
So if you combine them all you will mount an NTFS partition with owner = root, group = plugdev, with read / write permissions to owner and group and no one else.

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.


On Linux file systems they are done after you mount it with chmod and chown and they are persistent. So once you change ownership and / or permissions you don't have to do it again.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
Fred
Level 10
Level 10
Posts: 3337
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by Fred »

altair4,

Nicely put sir. :-)

+1

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.
aelfinn
Level 3
Level 3
Posts: 193
Joined: Thu Dec 11, 2008 2:11 pm

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by aelfinn »

Thanks very much.
User avatar
Chacalo
Level 1
Level 1
Posts: 6
Joined: Sat Apr 24, 2010 9:25 pm
Location: Buenos Aires, Argentina.

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by Chacalo »

Thanks Fred! :)
User avatar
masoko
Level 1
Level 1
Posts: 16
Joined: Thu Mar 25, 2010 4:06 pm

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by masoko »

how to automount an ext4 partition?

masoko@masoko-desktop ~ $ sudo blkid
/dev/sda1: UUID="aa477409-4e71-42b9-9720-32d43956e57e" TYPE="ext4"
/dev/sda5: UUID="4375978c-7bcc-450f-8e8a-e1d4ccaf19c8" TYPE="swap"
/dev/sdb1: LABEL="Slave" UUID="0d9fdc27-c4bc-4523-8b48-480d1dde1a20" TYPE="ext4"[/b] this is

Thanks in advance!
User avatar
mick55
Level 6
Level 6
Posts: 1485
Joined: Fri Sep 25, 2009 2:47 am

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by mick55 »

Read the tutorial and where it says ext3 put ext4 instead.
Things are more like they are now than they ever were before.

Dwight D. Eisenhower (1890 - 1969)
User avatar
masoko
Level 1
Level 1
Posts: 16
Joined: Thu Mar 25, 2010 4:06 pm

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by masoko »

It worked very well,thanks! and how do I give permission to this hard drive, so I can give it format when I need to? when I try to change permissions it just says "The permissions of "..." could not be determined" :(
User avatar
mick55
Level 6
Level 6
Posts: 1485
Joined: Fri Sep 25, 2009 2:47 am

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by mick55 »

You don't need to change the drive permissions to format.

When you run a utility like the partition editor (gparted) you run it with elevated rights
so the permissions of the drive are irrelevant. You can format the drive/partition
in gparted as well as define partitiions.If you do not have gparted installed, you
can install it by running this command in a terminal

Code: Select all

sudo apt-get install gparted
After you install it, it will appear on your menu or press Alt+f2 and type gparted.
Things are more like they are now than they ever were before.

Dwight D. Eisenhower (1890 - 1969)
User avatar
Luposz
Level 1
Level 1
Posts: 9
Joined: Wed Jan 26, 2011 8:16 pm

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by Luposz »

Hello =3
Thanks for this little tuto
My question is... How do you undo that?
I mess up the first time and everytime I restart it says that the device it's not ready to be mounted >_<
altair4
Level 20
Level 20
Posts: 10265
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by altair4 »

If you can still login into your Mint system edit the fstab file and comment out the line by placing a # sign in front of it:
gksu gedit /etc/fstab
And change something like this:
/dev/sda1 /media/WinC ntfs defaults,nls=utf8,umask=007,uid=1000,gid=46 0 0
To this:
#/dev/sda1 /media/WinC ntfs defaults,nls=utf8,umask=007,uid=1000,gid=46 0 0
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
Luposz
Level 1
Level 1
Posts: 9
Joined: Wed Jan 26, 2011 8:16 pm

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by Luposz »

Thanks a lot =D!!
It worked =3
I can delete those lines, right?
altair4
Level 20
Level 20
Posts: 10265
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by altair4 »

Luposz wrote:Thanks a lot =D!!
It worked =3
I can delete those lines, right?
Yes, the only reason for the # was to "comment out" the offending line so it wouldn't execute on boot. Wasn't sure if you wanted to go back and fix the error or start over again.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
intoxicant1
Level 1
Level 1
Posts: 5
Joined: Tue Sep 22, 2009 9:38 pm

re: messed up fstab

Post by intoxicant1 »

I messed up fstab, now mint will not boot. error message says partition not ready or not found. It asks if I want to Skip or Manually repair. Either option nets endless boot loader dots, never boots. I have been using mint for awhile but am not very adept at command line, use gui mostly. Any help would be greatly appreciated, I really don't want to reload O.S.
altair4
Level 20
Level 20
Posts: 10265
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by altair4 »

Boot into your Mint Install DVD and use it as a rescue DVD:

Select "Computer" from the desktop
Select the "Hard Disk" that holds your Mint OS.
Right click on /etc/fstab and select "Open as Administrator"
Edit fstab by placing a # sign in front of the offending line like I described above.
Save fstab, remove the Install DVD, and reboot your system.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
intoxicant1
Level 1
Level 1
Posts: 5
Joined: Tue Sep 22, 2009 9:38 pm

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by intoxicant1 »

Thanks very much altair4,
should have thought of that myself.
corrected the fstab and got my partition to auto mount correctly.

very much appreciated!
User avatar
Fandangio
Level 4
Level 4
Posts: 368
Joined: Fri Dec 10, 2010 2:20 am
Location: Manchester, UK

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by Fandangio »

Thank you Fred,

a very useful and easy to follow guide!
AMD Phenom (tm) II x4 965 | 4GB DDR3 | NVIDIA GTS 450 4GB DDR3 | ASUS M4A88T-M
impressme
Level 1
Level 1
Posts: 1
Joined: Tue Apr 12, 2011 4:47 am

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by impressme »

What would be the best method to auto mount SMB shares on boot? There appear to be two options, either 'smbfs' or 'cifs'. My concern though is that authentication is required when accessing my SMB shares, and it looks like I have to enter my required username and password in plain text in the fstab file! That's a big concern. Is there a way to do this securely?

An example SMB share I'd like to auto mount:

smb://WHS/Common

Thanks for any suggestions, great thread!

Regards.
altair4
Level 20
Level 20
Posts: 10265
Joined: Tue Feb 03, 2009 10:27 am

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by altair4 »

@impressme, this HowTo does not cover remote Samba shares. You really should start your own thread for this. I can offer you some things to consider though.
There appear to be two options, either 'smbfs' or 'cifs'.
THe "smbfs" thing is kind of complicated. Once upon a time there used to be a filesystem / protocol named smbfs and if you are looking at very old howto's they will use that in their fstab entries. It has been replaced by cifs. The confusing part is that in the repositories there is a package named smbfs which is a meta-package that contains a lot of stuff that makes cifs work and should be installed. Like I said it's confusing.
My concern though is that authentication is required when accessing my SMB shares, and it looks like I have to enter my required username and password in plain text in the fstab file!
Yes and no. You could for example have a statement like this:
//WHS/Common /media/Common cifs username=altair,password=secret,uid=1000 0 0
You're right, the credentials are in plain text in fstab.
But you could also do it this way:
//WHS/Common /media/Common cifs credentials=/path_to/.creds,uid=1000 0 0
The "/path_to/.creds" would be set up first as a hidden file accessible only to root and contain the username and password. It will have more security but it will still be in plain text - just not in fstab.

The other method which is the most secure is gvfs. With that the password is kept in an encrypted file ( Gnome Keyring ) by the OS itself. Here's two HowTo's on that method:
Auto Mount Samba Shares on Boot ( GVFS Method ): http://forums.linuxmint.com/viewtopic.php?f=42&t=42713
HowTo: Using Gigolo to Mount Remote Samba Shares: http://forums.linuxmint.com/viewtopic.php?f=42&t=52144
Gigolo is the easiest to use since it's all graphical and has other benefits.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
AlbertP
Level 16
Level 16
Posts: 6714
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: Auto Mount Partitions on Boot (also Windows partitions)

Post by AlbertP »

An NTFS partition on the same harddisk failed to mount during boot using its UUID, but when mounting with /dev/sda3 instead of UUID was no problem.
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.
Locked

Return to “Tutorials”