How to create a bind-mount on Rocky Linux 9.3
To Create Bind-Mount On Rocky Linux 9.3
Introduction:
A bind mount allows us to mount a file system or a subset of a file system in two places at once. They can be used for different reasons when parts of the file system need to be made available in various locations.
Procedure:
Step 1: Check the OS version by using the below Command
[root@linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.3 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.3 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.3"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.3"
Step 2: Navigate to a directory where you want to create a bind-mount by using the below Command
[root@linuxhelp ~]# cd /mnt/
Step 3: Create two directories as dir1 and dir2, Where use dir1 as source and dir2 as a bind-mount by using the below Command
[root@linuxhelp mnt]# mkdir dir1 dir2
[root@linuxhelp mnt]# ll
total 0
drwxr-xr-x. 2 root root 6 May 8 22:31 dir1
drwxr-xr-x. 2 root root 6 May 8 22:31 dir2
drwxr-xr-x. 2 root root 6 Mar 15 13:56 hgfs
Step 4: Change the directory to directory 1 and Create multiple files by using the below Commands
[root@linuxhelp mnt]# cd dir1
[root@linuxhelp dir1]# touch files{1..4}
[root@linuxhelp dir1]# ll
total 0
-rw-r--r--. 1 root root 0 May 8 22:32 files1
-rw-r--r--. 1 root root 0 May 8 22:32 files2
-rw-r--r--. 1 root root 0 May 8 22:32 files3
-rw-r--r--. 1 root root 0 May 8 22:32 files4
Step 5: Create the bind-mount by using the below Command
[root@linuxhelp dir1]# mount --bind /mnt/dir1 /mnt/dir2/
Step 6: Navigate to the destination directory and list the contents in the directory by using the below Command
[root@linuxhelp dir1]# cd ../dir2/
[root@linuxhelp dir2]# ll
total 0
-rw-r--r--. 1 root root 0 May 8 22:32 files1
-rw-r--r--. 1 root root 0 May 8 22:32 files2
-rw-r--r--. 1 root root 0 May 8 22:32 files3
-rw-r--r--. 1 root root 0 May 8 22:32 files4
Step 7: To Check the bind-mounts entry, navigate to the following location by using the below Command
[root@linuxhelp dir2]# vim /etc/mtab
Step 8: Unbind the mount by using the below Command
[root@linuxhelp dir2]# cd ..
[root@linuxhelp mnt]# umount -l /mnt/dir2
Step 9: Verify the bind-mount directory where the contents of the source directory is removed by using the below Command
[root@linuxhelp mnt]# cd dir2/
[root@linuxhelp dir2]# ls -la
total 0
drwxr-xr-x. 2 root root 6 May 8 22:31 .
drwxr-xr-x. 5 root root 42 May 8 22:31 ..
Step 10: Finally verify the bind-mount entry in mtab by using the below Command
[root@linuxhelp dir2]# cat /etc/mtab
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=4096k,nr_inodes=456687,mode=755,inode64 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev,inode64 0 0
devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,size=743064k,nr_inodes=819200,mode=755,inode64 0 0
cgroup2 /sys/fs/cgroup cgroup2 rw,seclabel,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot 0 0
pstore /sys/fs/pstore pstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
/dev/mapper/rl-root / xfs rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,nosuid,noexec,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=29,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=21644 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=2M 0 0
mqueue /dev/mqueue mqueue rw,seclabel,nosuid,nodev,noexec,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
tracefs /sys/kernel/tracing tracefs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0
none /run/credentials/systemd-sysctl.service ramfs ro,seclabel,nosuid,nodev,noexec,relatime,mode=700 0 0
none /run/credentials/systemd-tmpfiles-setup-dev.service ramfs ro,seclabel,nosuid,nodev,noexec,relatime,mode=700 0 0
vmware-vmblock /run/vmblock-fuse fuse.vmware-vmblock rw,relatime,user_id=0,group_id=0,default_permissions,allow_other 0 0
/dev/nvme0n1p1 /boot xfs rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 0
none /run/credentials/systemd-tmpfiles-setup.service ramfs ro,seclabel,nosuid,nodev,noexec,relatime,mode=700 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
tmpfs /run/user/42 tmpfs rw,seclabel,nosuid,nodev,relatime,size=371528k,nr_inodes=92882,mode=700,uid=42,gid=42,inode64 0 0
tmpfs /run/user/0 tmpfs rw,seclabel,nosuid,nodev,relatime,size=371528k,nr_inodes=92882,mode=700,inode64 0 0
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to create a Bind-Mount on Rocky Linux 9.3. Your feedback is much welcome.
Comments ( 0 )
No comments available