top of page
Writer's pictureMukesh Chanderia

Linux Commands Part 18 - Mount Partition (fstab)

Updated: Aug 21, 2021

[root@RedHat adminji]# lsblk (list block) -⇾ This will show hard disk


NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 4G 0 disk

sdb 8:16 0 64G 0 disk

sdc 8:32 0 1T 0 disk


[root@RedHat adminji]# blkid (block id) -⇾ This will show partition

/dev/mapper/rootvg-varlv: UUID="83266738-232f-4daa-b442-a3e0bdbc1979" TYPE="xfs"

/dev/sdb2: UUID="nqwdS4-Gvs3-eccT-l4w6-e0fd-yFan-73oea9" TYPE="LVM2_member" PARTUUID="88262e85-6ced-4c85-a844-181f2963c3d6"

/dev/sdb1: UUID="58e5db49-8935-4325-80c1-6628c0d61820" TYPE="xfs" PARTUUID="dbc4d454-142c-4c6b-b847-7c3a45697ce2"

/dev/sdb14: PARTUUID="15f2ea65-e018-497e-b63b-8f2feacbadfe"

/dev/sdb15: SEC_TYPE="msdos" UUID="F3D4-BA52" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="9a17795a-c9fe-43d3-948d-b8478d7f1bea"

/dev/sda1: UUID="c09e4b4d-5930-477d-a6c3-41a510fff618" TYPE="ext4" PARTUUID="27d11b8e-01"


To check to which directory partition is mounted -⇾ "df -h"


[root@RedHat thisisnewpart6]# df -h | grep /dev/sdc6


/dev/sdc6 8.9G 45M 8.4G 1% /root/thisisnewpart6


[root@RedHat ~]# du -sh * | grep thisisnewpart6

25M thisisnewpart6

[root@RedHat ~]# umount thisisnewpart6

[root@RedHat ~]# du -sh * | grep thisisnewpart6

0 thisisnewpart6


Now create a new directory "thisis6" and mount it there


[root@RedHat ~]# mkdir thisis6

[root@RedHat ~]# mount /dev/sdc6 thisis6

[root@RedHat ~]# df -h | grep sdc6

/dev/sdc6 8.9G 45M 8.4G 1% /root/thisis6


To Check amount of data stored in partition -⇾ "du -sh"


[root@RedHat ~]# du -sh thisis6


25M thisis6


Note : Please note this mounting is temporary and will be removed once the device is rebooted.


So reboot the device and see if we found our /sdc* partitions.


[adminji@RedHat ~]$ df -h | grep /dev/sdc

/dev/sdc1 496M 148M 349M 30% /boot

/dev/sdc15 495M 6.9M 488M 2% /boot/efi


So we didn't found our partition "/dev/sdc6"


Now lets edit /etc/fstab


To make it mount permanent create an entry in /etc/fstab


[root@RedHat adminji]# vim /etc/fstab


# /etc/fstab

/dev/mapper/rootvg-varlv /var xfs defaults 0 0

/dev/disk/cloud/azure_resource-part1 /mnt auto defaults,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig 0 2

/dev/sdc6 /thisisnewpart ext2 defaults 0 0 ⇽- This entry is what we created


Now run command "mount -a" to update entries in /etc/fstab & reboot the device.


[root@RedHat adminji]# df -h | grep sdc6

/dev/sdc6 1008M 1.3M 956M 1% /thisisnewpart


So we can see /dev/sdc6 appears


Now inspite of defining /dev/sdc6 we can use it's UUID also

[root@RedHat adminji]# blkid | grep sdc6

/dev/sdc6: UUID="689a741b-36f6-4154-983c-83697b8880eb" TYPE="ext2" PARTUUID="b6158727-06"

[root@RedHat adminji]# vim /etc/fstab

/dev/sdc1 /thisisnewpart ext2 defaults 0 0

UUID=689a741b-36f6-4154-983c-83697b8880eb /root/thisisnewpart3 ext2 defaults 0 0


[root@RedHat adminji]# mount -a (to forcefully make kernel read file "fstab")


[root@RedHat adminji]# df -h | grep sdc6

/dev/sdc6 8.9G 45M 8.4G 1% /root/thisisnewpart3






19 views0 comments

Comments


bottom of page