We help IT Professionals succeed at work.

Mount a new directory on root for RHEL 7

Flex Tron
Flex Tron asked
on
Medium Priority
168 Views
Last Modified: 2019-07-23
Dear Unix Gurus,
I got a new server which the below in the root directories.
Now I need to mount a new directory '/data/inout' here .
IS there a way we can do this.
ls -la
drwxr-xr-x.   2 root    root       6 Dec 14  2017 srv
drwxr-xr-x.   2 root    root       6 Dec 14  2017 mnt
drwxr-xr-x.   2 root    root       6 Dec 14  2017 media
drwxr-xr-x.   3 root    root      18 Sep 27  2018 export
lrwxrwxrwx.   1 root    root       7 Sep 27  2018 bin -> usr/bin
lrwxrwxrwx.   1 root    root       9 Sep 27  2018 lib64 -> usr/lib64
lrwxrwxrwx.   1 root    root       7 Sep 27  2018 lib -> usr/lib
lrwxrwxrwx.   1 root    root       8 Sep 27  2018 sbin -> usr/sbin
drwxr-xr-x.  13 root    root     155 Sep 27  2018 usr
drwxr-xr-x.   2 root    root       6 Sep 27  2018 tmproot
lrwxrwxrwx.   1 root    root      10 Sep 27  2018 esm -> /opt/DBesm
drwxr-xr-x.   4 root    root      33 Sep 27  2018 SSH_Keys
drwxr-xr-x.  11 root    root     128 Sep 27  2018 opt
drwxr-xr-x.  21 root    root    4.0K Oct  8  2018 var
dr-xr-xr-x.   4 root    root    4.0K Oct  8  2018 boot
drwxr-xr-x.   4 root    root      38 Apr 17 07:22 home
drwxr-xr-x. 105 root    root    8.0K Jul  1 02:00 etc
dr-xr-xr-x. 251 root    root       0 Jul  6 21:31 proc
dr-xr-xr-x.  13 root    root       0 Jul  6 21:31 sys
drwxr-xr-x.  19 root    root    3.3K Jul  6 21:31 dev
drwxr-xr-x.   2 root    root       0 Jul  6 21:31 misc
drwxr-xr-x.   2 root    root       0 Jul  6 21:31 net
drwxr-xr-x.  28 root    root    1000 Jul  6 21:32 run
drwx------.   3 root    root    4.0K Jul 18 02:06 root
drwxrwxrwt.   8 root    root     160 Jul 18 16:20 tmp

Open in new window

Comment
Watch Question

David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Provide the output of the mount command as a first step.

Your question requires more clarification, for a good answer.

As you asked your question, how you mount /data/inout depends on the /data/inout filesystem + device, which will be shown by output of the mount command.
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Tip: Enclose your command output by clicking CODE rather than QUOTE for better readability.
Scott SilvaNetwork Administrator
CERTIFIED EXPERT

Commented:
Are you MOUNTING a storage point or CREATING a directory?
They are different things...
Flex TronDeveloper

Author

Commented:
This is what I have. I need to add mounted on :'/data/inout'
df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv      8.0G  2.2G  5.9G  27% /
devtmpfs                       7.8G     0  7.8G   0% /dev
tmpfs                          7.8G     0  7.8G   0% /dev/shm
tmpfs                          7.8G   25M  7.8G   1% /run
tmpfs                          7.8G     0  7.8G   0% /sys/fs/cgroup
swap                           2.0G  8.0K  2.0G   1% /tmp
/dev/mapper/rootvg-homelv       97M  5.4M   92M   6% /export/home
/dev/mapper/rootvg-ulocallv     97M  5.3M   92M   6% /usr/local
/dev/mapper/rootvg-optlv       4.0G  285M  3.8G   7% /opt
/dev/mapper/rootvg-securitylv   20G   33M   20G   1% /opt/security
/dev/mapper/rootvg-dbtoolslv   4.0G   33M  4.0G   1% /opt/dbtools
/dev/sda1                      509M  161M  349M  32% /boot
/dev/mapper/rootvg-varlv       8.0G  361M  7.7G   5% /var
/dev/mapper/rootvg-dbpatchlv  1014M   33M  982M   4% /var/adm/db/dbpatchv2
/dev/mapper/rootvg-crashlv      10G   33M   10G   1% /var/crash
tmpfs                          1.6G     0  1.6G   0% /run/user/40039
tmpfs                          1.6G     0  1.6G   0% /run/user/64002

Open in new window

Flex TronDeveloper

Author

Commented:
Something like :
/dev/mapper/gcs1vg-datalv      200G  176G   25G  88% /data/inout

Open in new window

David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Refer to Scott's question.

Sounds like you're just adding a directory, in which case you'll do this...

mkdir -p /data/inout

Open in new window


If you're mounting a storage point (existing data somewhere remote or on another device) then how you do this will relate to your exact type of storage. For example, say you'd like to mount some data via SSH over the top of /data/inout, then you'd do something like this...

mkdir -p /data/inout
sshfs root@$host:/data /data/inout -o IdentityFile=~/.ssh/keyfile.rsa -o StrictHostKeyChecking=no -o ServerAliveInterval=5 -o workaround=rename

Open in new window


So as Scott mentioned, 2x different things - creating a local filesystem verses connecting remote data as a local mount point.
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
In your case, likely something like this...

mkdir -p /data/inout
mount --bind /dev/mapper/gcs1vg-datalv /data/inout

Open in new window


As with all things Linux, there are many ways to accomplish what you're asking + the above is one way.

Another way is to simply do this...

mkdir /data
ln -s /dev/mapper/gcs1vg-datalv /data/inout

Open in new window

Flex TronDeveloper

Author

Commented:
Actually we need to have a Application Account : wma whose home directory needs to be /data/inout
When I assign the task to a UNIX team, they come back saying there is no '/data/inout' existing.
If I ask them that do
mkdir -p /data/inout...I believe it will mount on root.
How is the space allocated to it ? Will it not run out of space
In other servers , I see
1:/dev/mapper/gcs1vg-datalv      200G  176G   25G  88% /data/inout

Open in new window

Sorry, I am not a UNIX expert like you all.
Scott SilvaNetwork Administrator
CERTIFIED EXPERT

Commented:
If you just create the directory, it will be in the root mounted filesystem
so
mkdir -p /data/inout

Open in new window

will leave a directory under the /root mounted system

If you are trying to mount another storage point, you first need to know the device id of that storage. It isn't just sitting there, and it doesn't create itself... If you want separate storage, you will need to create it.
And any storage can run out. It doesn't matter where it comes from. All storage is finite and can fill up.
Fractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
Best to limit a single question to a single topic, else the question becomes muddled.

First ensure you determine how best to accomplish your mount point or directory setup, then close this question, then open additional questions related to other topics... like... managing disk space...

Tip: About disk space. When you use up all your disk space, it's gone. That's the simple bit about disk space usage. There is no magic to this. Same for every OS. When disk space is used, there is no more.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
David has your info.
The path where you want it mounted has to exist.

Edit /etc/fstab
The list you can replicate the entries.

Lvmdiskscan
Pvdisplay
Vgdisplay
Lvdisplay
Df -k
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Arnold brings up a good point.

In the 2x ways I listed above, for the first way (mount --bind) you'll require an /etc/fstab entry or CRON @reboot entry.

For the 2nd way listed (ln -s), this approach persists across boots + requires no boot actions to be taken.

Something to keep in mind - symlinks live across boots, mounts require some sort of boot time work to create the mount.
Flex TronDeveloper

Author

Commented:
Thanks for the help Gurus. Will take a deeper look into Linux.
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You're welcome!

Keep digging deeper into Linux!
Flex TronDeveloper

Author

Commented:
Sure...Its an ocean.
Scott SilvaNetwork Administrator
CERTIFIED EXPERT

Commented:
It is more of a sea than an ocean... And each sea has slightly different water...  ;)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.