File System & Disks

Collection of commands to check file system formatting and create new partitions.

Confirm which filesystem a disk is formatted with
file -sL /dev/<disk-or-partition>

You have the option to forgo using LVM or making partitions and just formatting using EXT4
mkfs.ext4 /dev/<disk-or-partition>

When adding disks in VMware -or equivalent- avoid rebooting by scanning for new drives
echo "- - -" > /sys/class/scsi_host/host0/scan
Check if more than one hosts exist and scan each
ls /sys/class/scsi_host

Create a disk partition with FDisk
fdisk /dev/<disk-or-partition>

Within FDisk menu print list of current partitions

Create new partition

Choose the defaults for the rest of the commands to use the entirity of the available disk space for your partition. To give a specific size for the partition be sure to provide size unit

To use LVM change the partition ID

Change the hex code

Save all changes

Exit fdisk with control+c

If you have an existing disk that is full, and you want to add space to the logical volume group we can add and expand the logical volume and volume group using LVM.

LVM allows us to use multiple disks as though it were one, we also have the availability to creat RAID like mirrors and more. This is a very powerful too.

#The most common case is I have a directory, like /VAR, that becomes full and I want to increase space without moving/deleting or effecting current files. We would extend the logical group and potentially the volume group.

Check if there is disk space available
–In basic configurations there is a single root volume group called rootvg which all the disks get added to. The second line from the bottom “Free PE /Size” is what will tell you the available disk space you can use.

#Say we are out of disk space at the volume group level.

To add the new disk space to the volume group
pvcreate /dev/<disk-or-partition>

Show physical volume, notice lacking volume group name

Add physical volume to specific volume group
vgextend /dev/<volume-group> /dev/<disk-or-partition>

Check to see if space has been added

#If you had the appropriate space in your volume group you can skip to extending the logical volume.

Find the name of the logical volume group you need to expand

Extend the space for logical volume group varlv under root volume rootvg by 30GB
lvextend -L+30GB /dev/rootvg/varlv

Resize the logical volume for changes to take effect
resize2fs /dev/rootvg/varlv

Check the new space in your /var directory.
df -h /var

Leave a Reply

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