Friday, December 1, 2017

Complete guide for mounting drives in RHEL/CentOS

Complete guide for mounting drives in RHEL/ CentOS


In this tutorial, we are going to discuss how we can mount various devices on a RHEL/CentOS system using command line interface.

To view all the mounts on the system

If we want to see all the devices that are currently mounted on our machine, run
$ mount

To unmount a device

To unmount an already mounted device, run
$ umount mount_point
For example, if a device is mounted at /newdrive & needs to be unmounted, run
$ $ umount /newdrive

Mounting a NFS shared drive

To mount a NFS shared drive on the Linux machine, run
$ mount 192.168.1.100:/nfs_share /newdrive
Here, 192.168.1.100 is the IP address of the machine with NFS & /nfs_share in the name of the folder that has been shared. This again is a temporary mount & we will need to create an entyr in /etc/fstab for the permanent mount
$ vi /etc/fstab
192.168.1.100:/nfs_share /newdrive nfs defaults 0 0
here /newdir, is the mount point for drive that we created.

Mounting a Samba shared drive

There are many ways by which you can access samba shared device on your machine but we will be using mount command. Command to mount a samba share on Linux is ,
$ mount –t smbfs -o username=dan,workgroup=office,password=12345 192.168.1.100:/samba_share /newdir
Here, dan is username to access samba drive with a wotkgroup ‘office’ & password ‘12345’.
192.168.1.100:/samba_share is the samba device address.
To permanently mount a samba drive, open /etc/fstab & create an entry,
$ vi /etc/fstab
//192.168.1.100:/samba_share1 /newdir smbfs rw,user,username=dan,password=12345 0 0

Mount a new HDD partition

To mount a new HDD partition with ext4 filessytem on Linux, we will first create a mount point
$ mkdir /newdrive
& then will mount the freshly created partition onto our machine by running,
$ mount /dev/sdb2 /newdrive
Where, /dev/sdb2 is the newly created partition. However the mount will be a temporary mount & the partition will be un-mounted if the system reboots. To permanently a HDD partition, we need to make an entry in /etc/fstab file.
$ vi /etc/fstab
/dev/sdb2 /newdrive ext4 defaults 0 0

Mounting a FAT32 based USB drive or HDD

Mounting a USB based drive is similar to mounting a new partition with one exception that we will also need to mention the filesystem when mounting a usb drive. Command for mounting a USB drive is
$ mount –t vfat /dev/sdb1 /newdrive
To permanently mount a ntfs drive on the system, open /etc/fstab file & add
$ vi /etc/fstab
/dev/sdb2 /newdrive vfat defaults 0 0

Mounting a NTFS based usb drive or HDD

To mount a NTFS based drive, we need to install package named ‘ntfs-3g’ on our system. This package can be installed using yum by running the following command,
$ yum install ntfs-3g
Once install we can mount the drive,
$ mount –t ntfs /dev/sdb1 /newdrive
To permanently mount a ntfs drive on the system, open /etc/fstab file & add
$ vi /etc/fstab
/dev/sdb2 /newdrive ntfs-3g defaults 0 0

Mounting a CD/DVD

To mount a CD/DVD onto the system, run
$ mount -t iso9660 -o ro /dev/cdrom /mnt
Here, /mnt is mount point for CD-Rom. To permanently mount a CD/DVD-rom on the system, open /etc/fstab file & add
$ vi /etc/fstab
/dev/cdrom /mnt iso9660 defaults 0 0

Mounting an ISO to system

To mount an ISO to Linux system, run the following command
$ mount -t iso9660 -o loop rhel_X86-64_7.0.1.iso /mnt
To permanently mount an ISO file on the system, open /etc/fstab file & add
$ vi /etc/fstab
rhel_X86-64_7.0.1.iso /mnt iso9660 defaults 0 0

No comments: