LinuxQuestions.org
Help answer threads with 0 replies.
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 11-30-2017, 02:31 PM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 757

Rep: Reputation: Disabled
Make mount folder permanent


I wish to mount a folder. I've done this and it works.

Code:
sudo mkdir /home/jail/home/public/repo
sudo mount --bind /home/michael/public/repo /home/jail/home/public/repo
# And give readonly access
sudo mount -o remount,ro,bind /home/jail/home/public/repo
Now I wish to make it permanent. I look at my /etc/fstab file:
Code:
[michael@virtualServer ~]$ cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Apr  8 14:15:42 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        1 1
UUID=362355d4-e5da-44de-bf5c-5ce92cf43888 /boot                   xfs     defaults        1 2
/dev/mapper/centos-swap swap                    swap    defaults        0 0
[michael@virtualServer ~]$ ls -l /dev/mapper
total 0
lrwxrwxrwx 1 root root       7 Nov 29 12:31 centos-root -> ../dm-1
lrwxrwxrwx 1 root root       7 Nov 29 12:31 centos-swap -> ../dm-0
crw------- 1 root root 10, 236 Nov 29 12:31 control
[michael@virtualServer ~]$ ls -l /dev/dm*
brw-rw---- 1 root disk 253, 0 Nov 29 12:31 /dev/dm-0
brw-rw---- 1 root disk 253, 1 Nov 29 12:31 /dev/dm-1
[michael@virtualServer ~]$
Okay, I think this is right.
1st column: Device to Mount is /home/michael/public/repo
2nd column: Mount Point is /home/jail/home/public/repo
3rd column: No file system
4th column: mount options are remount,ro,bind
5th column: Don't backup
6th column: fsck shouldn't check.

So, I should do this?
Code:
/home/michael/public/repo   /home/jail/home/public/repo   none   remount,ro,bind   0 0
 
Old 11-30-2017, 04:38 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 9,483

Rep: Reputation: 991Reputation: 991Reputation: 991Reputation: 991Reputation: 991Reputation: 991Reputation: 991Reputation: 991
Have you thought about a line in /etc/fstab? The only snag is /root mounts it, with consequent effects on user perms. Otherwise put the line in the relevant user's ~/.bash_profile or ~/.bashrc
 
Old 11-30-2017, 07:13 PM   #3
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 757

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by business_kid View Post
Have you thought about a line in /etc/fstab? The only snag is /root mounts it, with consequent effects on user perms. Otherwise put the line in the relevant user's ~/.bash_profile or ~/.bashrc
Yeah, a line in /etc/fstab was the plan. I always get worried when modifying this file and wanted to make sure the line I showed was correct. Also, didn't know if there was a systemd or centos 7 different way to do it.
 
Old 12-03-2017, 06:52 PM   #4
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,480

Rep: Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997
I don't know if bind is an option. It might be a switch.
 
Old 12-03-2017, 07:55 PM   #5
WFV
Member
 
Registered: Apr 2012
Location: CA
Distribution: Arch
Posts: 151

Rep: Reputation: Disabled
for fstab, you should me able to run
Code:
$ cat /etc/mtab
and find the line that you manually mounted the directory in, copy that line into fstab, save and reboot
 
Old 12-07-2017, 01:30 PM   #6
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 757

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by WFV View Post
for fstab, you should me able to run
Code:
$ cat /etc/mtab
and find the line that you manually mounted the directory in, copy that line into fstab, save and reboot
Thanks, It produced the following.

Thought I'd test it before rebooting, and did a sudo mount -a which didn't seem to complain. Then reboot, but no reply. My fears of fstab were confirmed! Any thoughts? I wasn't sure about some of the options, and that always seems to sting me.
Code:
/dev/mapper/centos-root /home/jail/home/public/repo xfs ro,relatime,attr2,inode64,noquota 0 0

Last edited by NotionCommotion; 12-07-2017 at 01:48 PM.
 
Old 12-07-2017, 01:53 PM   #7
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 757

Original Poster
Rep: Reputation: Disabled
Actually, more than just the options. The device should be /home/michael/public/repo and not /dev/mapper/centos-root.
 
Old 12-08-2017, 01:32 PM   #8
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec, CANADA
Distribution: Arch
Posts: 1,011

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Hey NotionCommotion,

Although it can obviously be done, I'm curious what your objective is in mounting / binding one local /home subdirectory to another local /home subdirectory on the same computer ?

Cheers.
 
Old 12-08-2017, 01:47 PM   #9
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 757

Original Poster
Rep: Reputation: Disabled
Hi Rickkkkkk, The repo is accessed via ssh by others and I will give them a common username/password, but I don't wish to give them too much access and thus jailed the account and symbolic links are not possible with jailed/chroot users. I "could" locate the content within the jailed user's home, however, this makes maintenance more difficult.
 
Old 12-13-2017, 10:29 AM   #10
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec, CANADA
Distribution: Arch
Posts: 1,011

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Quote:
Originally Posted by NotionCommotion View Post
Hi Rickkkkkk, The repo is accessed via ssh by others and I will give them a common username/password, but I don't wish to give them too much access and thus jailed the account and symbolic links are not possible with jailed/chroot users. I "could" locate the content within the jailed user's home, however, this makes maintenance more difficult.
Got it - thx for the explanation.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] How can I make a Raspbian shared HDD a permanent mount on Debian? nebelfrau Linux - Newbie 7 03-26-2014 12:06 PM
Way to make autofs mount to specific USB flash drive to specific folder? utahnix Linux - Software 2 11-24-2010 06:27 PM
why did I have to manually make a mount folder? newbiesforever Linux - General 1 01-28-2009 11:22 AM
Insert/remove USB disk leaves a permanent folder carbide Linux - General 3 03-25-2008 04:42 AM
permanent mount jerrod Linux - Newbie 4 04-14-2003 07:36 PM

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

All times are GMT -5. The time now is 11:59 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration