Partition the disk, formation and manage the LVM in RHEL7

1. Disk partition

1. Tools for partitioning

  1. fdisk
  2. gdisk
  3. parted

2. Difference between the MBR and GPT

MBR (Master Boot Record) and GPT (GUID Partition Table) are two different ways of storing the partitioning information on a drive. Including the which partitions for starting and beginning. So the operating system knows which sectors is bootable.

1. MBR (Master Boot Record)

MBR is a special boot sector located at the beginning of a drive. The partitioning and boot data is stored in one place. If this data is overwritten or corrupted, you’re in trouble.

1. Limitations
  1. Only works within the 2TB disk.
  2. Only supports up to 4 primary partitions.
  3. If you want more that 4 primary partitions, you have to make one of your primary partitions as an “extended partition” and create the logical partitions inside it.
2. Composition

Bootloader(446 bytes) + Partition Table (64 bytes, 16 bytes for each partition, so only supports 4 partitions including primary and logic partitions) + Magic Number(2 bytes)= 512 bytes


2. GPT (GUID Partition Table)

GPT stands for GUID Partition Table. It’s a new standard that’s gradually replacing MBR. It’s associated with UEFI, which replaces the clunky old BIOS with something more modern. It’s called GUID Partition Table because every partition on your drive has a “globally unique identifier,” or GUID—a random string so long that every GPT partition on earth likely has its own unique identifier.


  1. GPT stores multiple copies of this data across the disk, so it’s much more robust and can recover if the data is corrupted.

GPT also stores cyclic redundancy check (CRC) values to check that its data is intact. If the data is corrupted, GPT can notice the problem and attempt to recover the damaged data from another location on the disk.

1. Protective MBR (LBA 0)

For limited backward compatibility, the space of the legacy MBR is still reserved in the GPT specification, but it is now used in a way that prevents MBR-based disk utilities from misrecognizing and possibly overwriting GPT disks. This is referred to as a protective MBR.

2. Hybrid MBR (LBA 0 + GPT)

In operating systems that support GPT-based boot through BIOS services rather than EFI, the first sector is also still used to store the first stage of the bootloader code, but modified to recognize GPT partitions. The bootloader in the MBR must not assume a sector size of 512 bytes.

3. Partition table header (LBA 1)

The partition table header defines the usable blocks on the disk. It also defines the number and size of the partition entries that make up the partition table.

4. Partition entries (LBA 2-33)

After the header, the Partition Entry Array describes partitions, using a minimum size of 128 bytes for each entry block. The starting location of the array on disk, and the size of each entry, are given in the GPT header. The first 16 bytes of each entry designate the partition type’s globally unique identifier (GUID). For example, the GUID for an EFI system partition is C12A7328-F81F-11D2-BA4B-00A0C93EC93B. The second 16 bytes are a GUID unique to the partition. Then follow the starting and ending 64 bit LBAs, partition attributes, and the 36 character (max). Unicode partition name. As is the nature and purpose of GUIDs, no central registry is needed to ensure the uniqueness of the GUID partition type designators.[citation needed]

3. Checking the partitions’ information

‘# sudo su’

‘# gdisk’ //starting the gdisk

2. LVM

  1. The physical media – assume it to be a simple hard disk, or a partition

  2. PV: Physical Volume – assume it to be a simple hard disk, or a partition

  3. PE: Physical Extents – like really big blocks, often with a size of megabytes

  4. VG: Volume Group – A Logical Volume is the end result of our work, and it’s there that we store our information. This is equivalent to the historic idea of partitions.

  5. LV: Logical Volume – A Logical Volume is the end result of our work, and it’s there that we store our information. This is equivalent to the historic idea of partitions.



1. Enlarge the /root

In the disk, in the LVM partition we have /root, /home and /swap in the logical volume. Due to ifs file system, it can not be shrink. If we want to change the size between /root and /home. We must destory the /home and enlarge the size of /root and rebuild the /home systems.

2. Proscedure

  1. ‘# df -h’ // show the detail of the partitions

  2. ‘# vgdisplay’ // show the detail of the Volume group

  3. ‘# lvdisplay’ // show the detail of the Logical volume

  4. ‘# tar -czvf /root/home.tgz -C /home .’ //Backup the contents of /home

  5. ‘# tar -tvf /root/home.tgz’ //Test the backup

  6. ‘# umount -fl /dev/mapper/rhel-home’ //forcing unmount the /rhel-home

  7. ‘# lsof | grep rhel-home’ // check is there open files

  8. ‘fuser -kuc /dev/mapper/rhel-home’ // And after that identify processes using files on this volume

  9. ‘# lvremove /dev/mapper/rhel-home’ //Remove home logical volume

  10. ‘# lvcreate -L 100GB -n home rhel’ //Now need to recreate new /home LV (lets say of 100GB), format and mount it

  11. ‘# mkfs.xfs /dev/rhel/home’

  12. ‘# mount /dev/mapper/rhel-home’

  13. ‘# lvextend -r -l +100%FREE /dev/mapper/home-root’ //Now extend your /root volume with all the remaining space

  14. ‘# tar -xzvf /root/home.tgz -C /home’ //Restore your backup

  15. ‘# blkid /dev/mapper/rhel-home’ //Check /etc/fstab entry of /home. Update the UUID of /home directory

  16. ‘# vim /etc/fstab’ (and update UUID of /home)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.