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
aelfinn

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: 11425
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.
Fred

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

Post by Fred »

altair4,

Nicely put sir. :-)

+1

Fred
aelfinn

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

Post by aelfinn »

Thanks very much.
Chacalo

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

Post by Chacalo »

Thanks Fred! :)
masoko

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!
mick55

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

Post by mick55 »

Read the tutorial and where it says ext3 put ext4 instead.
masoko

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" :(
mick55

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.
Luposz

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: 11425
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.
Luposz

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: 11425
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

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: 11425
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

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!
Fandangio

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

Post by Fandangio »

Thank you Fred,

a very useful and easy to follow guide!
impressme

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: 11425
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: 6701
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”