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
[root@techbrown.com]# hwbrowser &
To view the free space in a partition
[root@techbrown.com]# df –h
To view the total amount of used space in a partition / directory
[root@techbrown.com]# du –sh
To know the block size of a partition
[root@techbrown.com]# blockdev –getbsz <partition>

Label

To assign label to a partition
[root@techbrown.com]# e2label <partition> <label name>
To view the existing labels
[root@techbrown.com]# e2label <partition>
To see a mounted partition with its label
[root@techbrown.com]# mount –l

Swap Partition

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

Mounting a Partition Permanently

To mount a partition Permanently
[root@techbrown.com]# vl /etc/fstab

Mounting Removable Devices

To mount cdrom drive
[root@techbrown.com]# mount /dev/cdrom mnt
To mount a pen drive
[root@techbrown.com]# 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
[root@techbrown.com]# fdisk <device>
Update the partition table
[root@techbrown.com]# partprobe <device>

Physical Volume

Create a physical volume from the previously created partitions
[root@techbrown.com]# pvcreate <partition1> <partition2> <partition3>
To see the physical volume details
[root@techbrown.com]# pvdisplay |less

Volume Group

Create a volume group
[root@techbrown.com]# vgcreate <volume group name> <physical volume 1> <physical volume 2>
To see the volume group details
[root@techbrown.com]# vgdisplay <volume group name>

Logical volume

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

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

Hot Right Now

Related Post

COMMENTS