LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-01-2015, 05:56 AM   #1
slayme40
LQ Newbie
 
Registered: Oct 2015
Posts: 16

Rep: Reputation: Disabled
Adding mount point to fstab


Hi everybody,
I've learnt the hard way never mark as solved until u've tested it.
Say my user name is bill and I'm trying to mount sdb1 to /home/bill/data and I have typed "mkdir /home/bill/data" while logged in as bill and then typed "sudo mount dev/sdb1 /home/bill/data" shouldn't bill be able to access the folder "data"?
I've tried to add /home/bill/data to fstab and it just boots in to emergency mode. The only thing I can't think of is because bill can't access data would that be correct? How do I make bill able to access this mount point?
 
Old 12-01-2015, 06:05 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Depends on the ownership specified within the filesystem.

Normally, users do not have mountpoints within their directory - it can cause issues:

First, most filesystems have "lost+found" directory owned by root, group root.
Second, the root directory is by default owned by root, group root.

This is so that filesystem repair can be done when systems crash. It IS possible to give the root directory to a user... But doing so tends to cause repair problems when/if the lost+found directory is removed/renamed. But to do so first requires the filesystem to be mounted, then the ownership changed.

The usual method of mounting users directories is to mount /home. Then create a directory in the mounted filesystem for the user that is owned by the user and has the users default group access.
 
Old 12-01-2015, 06:34 AM   #3
slayme40
LQ Newbie
 
Registered: Oct 2015
Posts: 16

Original Poster
Rep: Reputation: Disabled
so, if i understand you correctly i create a folder called /home/data and type "mount "sudo mount /dev/sdb1 /home/data" is that correct?
 
Old 12-01-2015, 07:33 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Usually works - depends on the filesystem as to what you actually get. Not sure with Fat16/32/NTFS since there is no owner/access specifications.


what you were describing was a /home/user/data as mountpoint. Based on that you would get /home/user/data/.lost+found after mounting.

If you are referring to a /home mount what you get instead is a /home/.lost+found (with possible other directories - usually the users home directory).
 
Old 12-01-2015, 07:56 AM   #5
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
Quote:
I've tried to add /home/bill/data to fstab and it just boots in to emergency mode.
Someone might be able to suggest a solution if you posted the actual entry you have in the /etc/fstab file.
If you open a terminal and run: ls -ld /home/bill/data it will show the owner:group and permissions for that mount point.
Generally, additional disk partitions are mounted under /mnt or /media directories and then to give a user access use the chown command.
 
Old 12-01-2015, 08:36 AM   #6
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by slayme40 View Post
Say my user name is bill and I'm trying to mount sdb1 to /home/bill/data and I have typed "mkdir /home/bill/data" while logged in as bill and then typed "sudo mount dev/sdb1 /home/bill/data" shouldn't bill be able to access the folder "data"?
I've tried to add /home/bill/data to fstab and it just boots in to emergency mode. The only thing I can't think of is because bill can't access data would that be correct? How do I make bill able to access this mount point?
OK, let me describe how I am doing it, which is virtually identical to what you want to do.
I created the mount point with "mkdir /home/dan/sdb2_data" - yours is "/home/bill/data" - no problem.
You did mention that you were logged in as bill, so ownership of the mount point is no problem...
I list the UUID's of my partitions with "sudo blkid -o list"
Then I enter the mount lines in /etc/fstab:
Code:
# mount sdb2 on /home/dan/sdb2_data
UUID=a299e544-0371-4856-912b-70458aa37ee1   /home/dan/sdb2_data   ext4   defaults,noatime   0   2
I make sure the partition is not mounted with "sudo umount /dev/sdb2"
Then run the fstab commands with "sudo mount -a"

Is your sdb1 ext format or NTFS?

Quote:
Originally Posted by jpollard View Post
Normally, users do not have mountpoints within their directory - it can cause issues:
Please clarify. I have had my mount point in /home/dan for more than 10 years, and have not encountered issues.
 
Old 12-01-2015, 09:00 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by TxLonghorn View Post
OK, let me describe how I am doing it, which is virtually identical to what you want to do.
I created the mount point with "mkdir /home/dan/sdb2_data" - yours is "/home/bill/data" - no problem.
You did mention that you were logged in as bill, so ownership of the mount point is no problem...
I list the UUID's of my partitions with "sudo blkid -o list"
Then I enter the mount lines in /etc/fstab:
Code:
# mount sdb2 on /home/dan/sdb2_data
UUID=a299e544-0371-4856-912b-70458aa37ee1   /home/dan/sdb2_data   ext4   defaults,noatime   0   2
I make sure the partition is not mounted with "sudo umount /dev/sdb2"
Then run the fstab commands with "sudo mount -a"

Is your sdb1 ext format or NTFS?

Please clarify. I have had my mount point in /home/dan for more than 10 years, and have not encountered issues.
I listed some of the problems that can happen. filesystem repair can fail when the lost+found directory gets monkeyed with. Some don't even like the root filesystem not owned by root...

Can it work? sure. Can the be additional problems? sure. They may rarely happen though - it depends on the knowlege of the admin and user.
 
1 members found this post helpful.
Old 12-01-2015, 09:10 AM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Ownership of the mount point directory is irrelevant**. That inode gets overlaid by the root inode of the mounted filesystem. For filesystems like FAT and NTFS that do not support Unix permissions and ownership, that is a simulated inode built from mount options, but it still replaces the ownership and permissions of that mount point directory.

If you are mounting a Linux native filesystem and want your non-root UID to have permissions there, you need to go in (as root) while the filesystem is mounted and set those the way you want them. That change will be permanent in that filesystem.

** There could be some issues with the mount point's SELinux context allowing a mount there, but once the mount succeeds you are past that point.
 
1 members found this post helpful.
Old 12-01-2015, 09:22 AM   #9
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by jpollard View Post
filesystem repair can fail when the lost+found directory gets monkeyed with.
Actually, there is a lost+found directory on sdb2 and it is owned by root.
Why would that not be the case?
Maybe you are thinking of the case where someone creates a mount point and then does "sudo chown -R $USER:$USER /mountpoint" ?
THAT would change the ownership of lost+found, true. But that is not what is being done here.
 
1 members found this post helpful.
Old 12-01-2015, 09:26 AM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by TxLonghorn View Post
Actually, there is a lost+found directory on sdb2 and it is owned by root.
Why would that not be the case?
Maybe you are thinking of the case where someone creates a mount point and then does "sudo chown -R $USER:$USER /mountpoint" ?
THAT would change the ownership of lost+found, true. But that is not what is being done here.
True - but it can also be renamed and moved around... and deleted if the root directory is owned by the user.
 
1 members found this post helpful.
Old 12-02-2015, 12:31 AM   #11
slayme40
LQ Newbie
 
Registered: Oct 2015
Posts: 16

Original Poster
Rep: Reputation: Disabled
Ok maybe I should clarify what I'm trying to do.
At the Moment I have a partition entirely devoted to /home. It is running low on hard drive space so I want to mount sdb1 so I can use this for my data files. In another thread I was told to mount sdb1 and create the folder "data" on sdb1 and mount it to /home/bill/data . Is this the best way of doing this?
 
Old 12-02-2015, 12:54 AM   #12
slayme40
LQ Newbie
 
Registered: Oct 2015
Posts: 16

Original Poster
Rep: Reputation: Disabled
On second thoughts should I create a sub directory in data called bill. and type sudo mount sdb1 /home/bill/data/bill?
 
Old 12-02-2015, 05:00 AM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Actually, you create the dir 'data' under /home/bill ie /home/bill/data and mount sdb1 there.
 
1 members found this post helpful.
Old 12-02-2015, 06:36 AM   #14
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
remove duplicate - sorry
tried something that did not work.
My apologies.

Last edited by TxLonghorn; 12-02-2015 at 07:09 AM.
 
Old 12-02-2015, 06:42 AM   #15
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
remove duplicate - sorry
tried something that did not work.
My applogies.

Last edited by TxLonghorn; 12-02-2015 at 07:08 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] editing fstab - mount point with spaces vincix Linux - Newbie 5 11-23-2012 04:09 AM
Redhat Linux 4.8 error -mount: mount point /oracle does not exist for new /etc/fstab entries bellnarm Linux - Server 1 11-23-2011 05:09 AM
[SOLVED] fstab, space in mount point/directory names? batfastad Linux - Newbie 2 11-25-2010 02:42 AM
redirecting folders to a separate mount point in /etc/fstab etortola Linux - Server 1 06-20-2009 09:47 AM
problems with smbfs mount-point in /etc/fstab - "mount -a" works, but not at boottime MarkSide Linux - Software 4 11-20-2005 03:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration