How to Create bind-mounts On CentOS 7.6
Creation of Bind-Mounts On CentOS 7.6
Procedure:
Check the version of CentOS 7.6
[root@linuxhelp1 ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
Navigate to a directory to which you want to create a bind-mount.
[root@linuxhelp1 ~]# cd /mnt
Create two directories where use one as source and two as a bind-mount
[root@linuxhelp1 mnt]# mkdir one two
Change the directory to one and Create files
[root@linuxhelp1 mnt]# cd one
[root@linuxhelp1 one]# touch files{1..6}
Create the bind-mount as follows
[root@linuxhelp1 one]# mount --bind /mnt/one /mnt/two
List the contents In the one directory
[root@linuxhelp1 one]# ls -la
total 0
drwxr-xr-x 2 root root 90 Dec 27 08:47 .
drwxr-xr-x. 4 root root 28 Dec 27 08:47 ..
-rw-r--r-- 1 root root 0 Dec 27 08:47 files1
-rw-r--r-- 1 root root 0 Dec 27 08:47 files2
-rw-r--r-- 1 root root 0 Dec 27 08:47 files3
-rw-r--r-- 1 root root 0 Dec 27 08:47 files4
-rw-r--r-- 1 root root 0 Dec 27 08:47 files5
-rw-r--r-- 1 root root 0 Dec 27 08:47 files6
Verify the bind-mount directory where it has source content
[root@linuxhelp1 one]# cd /mnt/two
[root@linuxhelp1 two]# ls -la
total 0
drwxr-xr-x 2 root root 90 Dec 27 08:47 .
drwxr-xr-x. 4 root root 28 Dec 27 08:47 ..
-rw-r--r-- 1 root root 0 Dec 27 08:47 files1
-rw-r--r-- 1 root root 0 Dec 27 08:47 files2
-rw-r--r-- 1 root root 0 Dec 27 08:47 files3
-rw-r--r-- 1 root root 0 Dec 27 08:47 files4
-rw-r--r-- 1 root root 0 Dec 27 08:47 files5
-rw-r--r-- 1 root root 0 Dec 27 08:47 files6
To check the bind-mounts,navigate to the following location
[root@linuxhelp1 two]# vim /etc/mtab
/dev/sda3 /mnt/two xfs rw,relatime,attr2,inode64,noquota 0 0
Unbind the mount as follows
[root@linuxhelp1 two]# cd ..
[root@linuxhelp1 mnt]# umount -l /mnt/two
Verify the bind-mount directory where the contents of the source directory is removed
[root@linuxhelp1 mnt]# cd two
[root@linuxhelp1 two]# ls -la
total 0
drwxr-xr-x 2 root root 6 Dec 27 08:47 .
drwxr-xr-x. 4 root root 28 Dec 27 08:47 ..
Verify the bind-mount entry in mtab
[root@linuxhelp1 two]# cat /etc/mtab | tail -2
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
/dev/sr0 /run/media/root/CentOS\0407\040x86_64 iso9660 ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500 0 0
From the above result,the bind-mount has been successfully detached.
With this,the method to create a bind-mount on CentOS 7.6 comes to an end
Comments ( 0 )
No comments available