Acces /file partition, mount in home with fstab?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
asedt
Level 1
Level 1
Posts: 15
Joined: Sat Oct 10, 2009 12:25 pm

Acces /file partition, mount in home with fstab?

Post by asedt »

Hi all

I'm quite new to Linux and when I got a laptop on my hand I decided to test Linux Mint, works very well so far.

However when I made the install I made a partition for files mounted in /files, tough that would be nice, but now I need to be root to access it. From some use of Google I have read about solutions including use of chown or to mount to folder in home by editing fstab.

So my problem is what to do? editing fstab seems to be best option. but what should I change or add?

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# / was on /dev/sda2 during installation
UUID=ed0dd4cb-75b2-4b89-9996-732dc9d50952 / ext3 relatime,errors=remount-ro 0 1
# /files was on /dev/sda5 during installation
UUID=0cdea019-6092-4199-addf-45aa9a4fc54e /files ext3 relatime 0 2
# /win was on /dev/sda1 during installation
UUID=660C851C0C84E7FF /win ntfs defaults,nls=utf8,umask=007,gid=46 0 1
# swap was on /dev/sda6 during installation
UUID=c2a922c8-0d9a-4565-ab12-823ab3afe81e none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0

Thanks in advance from a beginner.
nadir
Level 3
Level 3
Posts: 142
Joined: Fri Oct 02, 2009 2:25 pm

Re: Acces /file partition, mount in home with fstab?

Post by nadir »

i think if you add your user to the group plugdev he/she should be able to access the partition on /files.

Code: Select all

$ sudo addgroup username plugdev
on how to edit fstab: i would add either and <defaults> or <users> as an option for /dev/sda5 mounted on /files (after relatime) . To check if it worked you dont need to reboot. Umount it and run

Code: Select all

$sudo mount -a
yours looks like this:

Code: Select all

# /files was on /dev/sda5 during installation
UUID=0cdea019-6092-4199-addf-45aa9a4fc54e /files ext3 relatime 0 2
so i would try to replace it with the following, for examplge with the editor gedit:

Code: Select all

UUID=0cdea019-6092-4199-addf-45aa9a4fc54e /files ext3 relatime,defaults 0 2
or:

Code: Select all

UUID=0cdea019-6092-4199-addf-45aa9a4fc54e /files ext3 relatime,users 0 2
and if you wanna mount it in your home, create a mount-point

Code: Select all

$ mkdir /home/username/files
(you may also do it from nautilus) and add it to /etc/fstab

Code: Select all

UUID=0cdea019-6092-4199-addf-45aa9a4fc54e /home/username/files ext3 relatime,users 0 2


the option <0 2 > at the end of line im not sure about (in all of mine i got <0 0 >, but i dont understand why).
greetings

ps: how come this post has got a white background, or is it just for me?
User avatar
pluraldave
Level 5
Level 5
Posts: 705
Joined: Mon Sep 01, 2008 8:05 am

Re: Acces /file partition, mount in home with fstab?

Post by pluraldave »

It is an ext3 partition so you have to set owner through chown and permissions via chmod. Editing fstab will just move the mountpoint, not allow you to do anything with the partition as a normal user.

Step 1. Change yourself to the owner. In a terminal)

Code: Select all

sudo chown -R <username> /files
Change <username> to whatever your username is (the one you log in to your computer with).

Step 2. Change permissions

Code: Select all

sudo chmod -R 644 /files
This gives you read and write ability and everyone else read only.

Chmod uses octal permissions
4 = read
2 = write
1 = execute

Add up whatever you want to be able to do, i.e. read + write = 4 + 2 = 6. No permissions = 0.

The first number is for the owner (you), the second for users in the group that the file/folder is assigned to and the third for any other user.
deadguy
Level 5
Level 5
Posts: 707
Joined: Wed Aug 15, 2007 9:41 pm
Location: Illinois USA

Re: Acces /file partition, mount in home with fstab?

Post by deadguy »

Hi,

nadir wrote:the option <0 2 > at the end of line im not sure about (in all of mine i got <0 0 >, but i dont understand why).
the 2 enables fsck checking of non-root partitions at boot. root partition uses 1. 0 disables the checking.


Cheers,

Deadguy
nadir
Level 3
Level 3
Posts: 142
Joined: Fri Oct 02, 2009 2:25 pm

Re: Acces /file partition, mount in home with fstab?

Post by nadir »

deadguy wrote:Hi,

nadir wrote:the option <0 2 > at the end of line im not sure about (in all of mine i got <0 0 >, but i dont understand why).
the 2 enables fsck checking of non-root partitions at boot. root partition uses 1. 0 disables the checking.


Cheers,

Deadguy
thanks, good info.
Husse
Level 23
Level 23
Posts: 18677
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: Acces /file partition, mount in home with fstab?

Post by Husse »

Editing fstab will just move the mountpoint, not allow you to do anything with the partition as a normal user.
Not quite I think - if you mount in /home it should be yours, but that's not for sure
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
asedt
Level 1
Level 1
Posts: 15
Joined: Sat Oct 10, 2009 12:25 pm

Re: Acces /file partition, mount in home with fstab?

Post by asedt »

Husse wrote:Not quite I think - if you mount in /home it should be yours, but that's not for sure
I did mount in home with:

UUID=0cdea019-6092-4199-addf-45aa9a4fc54e /home/username/files ext3 relatime,users 0 2

It's correctly mounted in home but no permission to write if not root. (is it because its ext3?)

I will use chown/chmod then, seems to be only "easy" way to go.
deadguy
Level 5
Level 5
Posts: 707
Joined: Wed Aug 15, 2007 9:41 pm
Location: Illinois USA

Re: Acces /file partition, mount in home with fstab?

Post by deadguy »

asedt wrote:
Husse wrote:Not quite I think - if you mount in /home it should be yours, but that's not for sure
I did mount in home with:

UUID=0cdea019-6092-4199-addf-45aa9a4fc54e /home/username/files ext3 relatime,users 0 2

It's correctly mounted in home but no permission to write if not root. (is it because its ext3?)

I will use chown/chmod then, seems to be only "easy" way to go.
that is probably because it was mounted as /files before.
chown and chmod should fix you up.

Deadguy
nadir
Level 3
Level 3
Posts: 142
Joined: Fri Oct 02, 2009 2:25 pm

Re: Acces /file partition, mount in home with fstab?

Post by nadir »

i can only tell you the way it is for me: on one OS i got an entry in fstab like the one you used, and i am able to write to it as user (i aint got the UUID-entry but a simple /dev/sda6 instead).
on another OS i mount it manually as root on /media/disk and too got write access as user (and thats the usual way i do it)

as said: i dont know how it comes to be that way ( i thought about it and i think the group plugdev might be usefull to be able to mount partitions as user but thats it ... well: im not sure on that, as it works i dont think that much about it)

if you did create directories in /files beforehand they might belong to root now, that way you wont be able to write to them as user. if i got ownership screwed i run:
chown -R <useraname> <directory>
chgrp -R username <directory>
to make the user able to write again.
I cant remember i had to edit permissions sometimes, but it sure is a good idea too.

im curious how this will end/get solved
greetings
User avatar
pluraldave
Level 5
Level 5
Posts: 705
Joined: Mon Sep 01, 2008 8:05 am

Re: Acces /file partition, mount in home with fstab?

Post by pluraldave »

Husse wrote:
Editing fstab will just move the mountpoint, not allow you to do anything with the partition as a normal user.
Not quite I think - if you mount in /home it should be yours, but that's not for sure
No, I mount my data partitions inside /home and they are still owned by root until I chown them. I've just tried making a test ext3 partition and playing with the fstab mount parameters but if there is an option that assigns ownership to the user I cannot find it.
Husse
Level 23
Level 23
Posts: 18677
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: Acces /file partition, mount in home with fstab?

Post by Husse »

Na - user is only to tell that a user can mount
But of course if you mount an empty partition in home then what ever ends up there will be "yours" unless you move something from outside home into it
A question of inheriting permissions
I had a vague memory of mounting in home and getting back permissions but maybe chown and chmod are so obvious to me that I use them without thinking about it :)
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
asedt
Level 1
Level 1
Posts: 15
Joined: Sat Oct 10, 2009 12:25 pm

Re: Acces /file partition, mount in home with fstab?

Post by asedt »

I changed back to original backup of /etc/fstab.

So now I have file disk mounted on /files as from beginning.

Then I did run

Code: Select all

sudo chown -R <username> /files
and

Code: Select all

sudo chmod -R 744 /files
Did not work with 644, I was not amble to open the folder.

Seems to work now, I do like this for now, if anyone know any more clever just tell me.

Tanks for all help, and for Linux Mint.
User avatar
Fred
Level 10
Level 10
Posts: 3337
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Acces /file partition, mount in home with fstab?

Post by Fred »

Maybe I can flesh this out a bit. When you create a partition, what you are doing is putting up two walls that encloses a given block of memory. At this point there is no ownership or permissions associated with the partition.

You then format this new partition with a file system. There is still no ownership or permissions associated with this partition. There are no files or folders on the partition. In ext3/4, only files and folders can have ownership or permissions.

A mount point has to be created in the file system to use the partition. If we create this mount point as a user, say in your /home, with "mkdir /home/fred/Data" that folder will be owned by the user and have the default user permissions. If you then mount the formatted partition you created to this folder with an appropriate fstab entry, you will then have user access, read/write, through that mount point. Any files and folders created through that mount point will inherent the user's ownership and permissions. Life is good! :-)

Now, here is where the complications come into play. If you mount the partition in a different place in the file system or in another system the ownership of any files or folders created through the original mount point will not be changed just because you decided to mount it somewhere else. The permissions of the existing files/folders will have to be adjusted to accommodate the new user accessing from a different mount point, to have full access to existing files/folders.

Lets say you have a data partition mounted in two different /homes. One user is fred and the other is bill. There is nothing on the partition. fred owns one mount point with 0644 permissions. bill owns the other mount point with 0644 permissions. Each user can create and use files and folders through their mount point. But will only have read access to the others files/folders.

Once you have played with a partition, mounted and tried to use it, and/or tried to change ownership/permissions through several mount points, that has existing files and folders on it, you probably have a mess. It is best to just start from scratch and set the ownership and permissions to known values. This usually solves the problem.

The link below may also be helpful in understanding Linux file/folder ownership and permissions better.

http://forums.linuxmint.com/viewtopic.p ... al#p158834

The link below may help you with auto mounting partitions.

http://forums.linuxmint.com/viewtopic.php?f=42&t=22093

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.
deadguy
Level 5
Level 5
Posts: 707
Joined: Wed Aug 15, 2007 9:41 pm
Location: Illinois USA

Re: Acces /file partition, mount in home with fstab?

Post by deadguy »

greetings Fred,

great explanation as always :)



Cheers,

Deadguy
User avatar
Fred
Level 10
Level 10
Posts: 3337
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Acces /file partition, mount in home with fstab?

Post by Fred »

deadguy,

Salutations sir.

Thank you sir.

I hope the world has been treating you well my friend. :-)

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.
deadguy
Level 5
Level 5
Posts: 707
Joined: Wed Aug 15, 2007 9:41 pm
Location: Illinois USA

Re: Acces /file partition, mount in home with fstab?

Post by deadguy »

Fred wrote:deadguy,

Salutations sir.

Thank you sir.

I hope the world has been treating you well my friend. :-)

Fred
Fred,

it has! I've been busy at work as of late, but I'm going to try and hang out here more often :D
always a pleasure to talk to you! and hope you are doing well also.

Cheers my friend,

Deadguy
Post Reply

Return to “Newbie Questions”