Create a File system

Device recognition

First, when we add a new disk, we should be able to see it with the following command:

Partition Creation

After that we have to create a partition for that device using the same command, a device can have 4 primary partitions and many more extended partitions. Here we will create a primary partition for device /dev/sdh

We can see now that the partition has been created

Volume Group Creation

After we have physical partition, we can create a volume group (e.g. group of physical volumes)

Logical Volume and File system creation

After we have the physical Volume we can start slicing it into pieces called Logical Volumes as follows:

Logical Volume

We can also display the stats of the newly created logical volume with:

File System

Once the logical volume is created, we can create a file system on it. There are two main types of file systems:

Journal File systems: ext3, ex4

Non-Journal: ext2

We will create a journal file system to prevent from corruption in case of a power outage.

Once the file system is created we can mount, but before that we have to edit the /etc/fstab, indificated what and where we mount it:

Mount of the file system

Once the file system is created and the /etc/fstab file edited as mentioned above, we can MOUNT the file system as follows:

Extend File system

To extend a file system we need several things:

Check if the new raw disk has been added

Format the disk

Create Physical Volume from the partition

Add the disk to the volume group

Extend the logical volume to which the file system (which we want to increase) is mounted

Resize the file system

So let's get started :)

Check the disk

In order to check the disk, we can simply use the “fdisk command”

Now the disks' partition, will be visible from OS side:

After a partition is created we can create a physical volume on that partition:

Create physical Volume

That volume can be seen as follows:

Now, it is time to finally associate our Physical volume with a volume group:

Add the disk to a volume group

Firstly, we have to partition the new bare metal :)

Then, we have to check, which is the volume group which we want to extend> Please BE SURE, you know the volume group of the logical volume on which your File system is mounted and which you wish to extend. This can be seen from the “df” command:

Once we find the logical volume, we can find the associated logical group, using the lvdispaly command:

After we are 1000% sure, we can extend the Volume group as follows:

After, we have added the physical volume to the volume group, we can see that the amount of our FREE sectors increased from 0 → 18172

Since we are sure that the logical volume, on which our filesystem is mounted is: “ORATEST_DATA_VG01-lvol0”, we can extend the logical volume as follows:

Finally we can resize the File system as follows:

Phew! That was something :) This is how you extend filesystem in Linux, to have more space for useless data :) Cheers :)

Refresh the SCSI-Disk information

If you add a disk on VM, it MIGHT not be there IMMEDIATELY so you have two options:

Restart the server

Rescan the disks

So since restarting of the server isn't always possible to restart the server. Luckly we have a command for that:

After that the disk should be available using fdisk: