Linux Disc Partitioning on CentOS 7 / RHEL 7

Linux Basic and Advanced Disc Partitioning for CentOS / RHEL 7/6

View Disk Information

To view available free space of a disk
[[email protected]]# hwbrowser &
To view the free space in a partition
[[email protected]]# df –h
To view the total amount of used space in a partition / directory
[[email protected]]# du –sh
To know the block size of a partition
[[email protected]]# blockdev –getbsz <partition>


To assign label to a partition
[[email protected]]# e2label <partition> <label name>
To view the existing labels
[[email protected]]# e2label <partition>
To see a mounted partition with its label
[[email protected]]# mount –l

Swap Partition

Create a new Partition
[[email protected]]# fdisk <device>
Format the partition as swap
[[email protected]]# mkswap <partition>
Turn on Swap
[[email protected]]# swapon <partition>
Check the status of swap used
[[email protected]]# swapon –s <partition>
Turn off swap
[[email protected]]# swapoff <partition>

Mounting a Partition Permanently

To mount a partition Permanently
[[email protected]]# vl /etc/fstab

Mounting Removable Devices

To mount cdrom drive
[[email protected]]# mount /dev/cdrom mnt
To mount a pen drive
[[email protected]]# mount /dev sda1 /mnt

What is Logical Volume Manager (LVM)?

  • LVM is a method of allocating hard drive space into logical volumes that can be easily resized.
  • With LVM, the hard drive or set of hard drives is allocated to one or more physical volumes.
  • The physical volumes are then combined into volumes groups.
  • Each volumes group is divided into logical volumes, which are formatted with a file system like ext3 and are then mounted.

Creating Partitions

Make Multiple Partitions
[[email protected]]# fdisk <device>
Update the partition table
[[email protected]]# partprobe <device>

Physical Volume

Create a physical volume from the previously created partitions
[[email protected]]# pvcreate <partition1> <partition2> <partition3>
To see the physical volume details
[[email protected]]# pvdisplay |less

Volume Group

Create a volume group
[[email protected]]# vgcreate <volume group name> <physical volume 1> <physical volume 2>
To see the volume group details
[[email protected]]# vgdisplay <volume group name>

Logical volume

Create logical volume
[[email protected]]# lvcreate –L <size> <volume group name> -n <volume name>
Format the logical volume
[[email protected]]# mkfs.ext3 < volume name>
Create a mount point
[[email protected]]# mkdir <directory name>
Mounting a logical volume
[[email protected]]# mount <volume name > <mount point>
Re-sizing a logical volume
[[email protected]]# lvresize –L <+sizeM> <logical volume name>
To update the re-sized logical volume
[[email protected]]# resize2fs <logical volume name>
Removing logical volume
[[email protected]]# lvremove <logical volume name>
Extending the size of a volume group
[[email protected]]#vgextend <volume group name ><physical volume name>

Congratulations now you have created and managed the basic and advanced partitioning.

Hot Right Now

Related Post