LVM Series – ReiserFS filesystem management

LVM series continues. If you want to start from the beginning, check our first post. You can review our last post, about XFS Management.
In this post we are going to review how to manage a ReiserFS filesystem over LVM.
For the exercises we will start with an LV called lv_rfssample in VG vg_storage1.

Formatting LV with ReiserFS

Let’s format this LV with ReiserFS filesystem.

mkfs.reiserfs /dev/vg_storage1/lv_rfssample

Mounting the filesystem

We will work with the filesystem mounted whenever is possible.
Usually it will be configured in fstab, but we are going to mount our filesystem manually in /mnt/temp.

mkdir /mnt/temp
mount /dev/vg_storage1/lv_rfssample /mnt/temp

Increasing the size of the filesystem

This is one of the most important reasons to use LVM, to be able to modify the size of our volumes.
It is important to note that this process depends on the filesystem.
This is what we are about to do and the order we will follow:

  • Make sure the VG has space enough.
  • Increase the size of the LV.
  • Resize the filesystem.

Checking VG free space

If you don’t know what VG you need to check, use tools such as df, lvdisplay or vgdisplay, as we saw in some of the last posts.
In our examples, our VG is vg_storage1, so you can check how much free space is available like this:

vgdisplay vg_storage1 | grep Free

If there is a free amount of space equal or bigger than the amount we want to increase, we can keep going with the process.
If there is not, you have to raise the storage in that VG or reduce some other LV to release space.

Increasing the size of the LV

The next step is to raise the size of the logical volume, we will do that with “lvextend”.
In this example, we will increase the size of lv_rfssample in 1 GB. Let’s remember that our filesystem is mounted in /mnt/temp, so no need to unmount it, we can do this without affecting service.

lvextend -L+1G /dev/vg_storage1/lv_rfssample

Resizing the filesystem

At this moment, you can take a few minutes to check the size of the filesystem and the size of the LV. You will see that LV is 1 GB bigger than the filesystem.
So now we have to resize the filesystem to be able to use all the space available in the LV.
This can be done using “resize_reiserfs” tool.
Remember that we didn’t umount the filesystem, so we can do this online.

resize2fs -f /dev/vg_storage1/lv_rfssample

You can do it offline as well.

resize2fs /dev/vg_storage1/lv_rfssample

Now we have the filesystem using all available space in LV.

Decreasing the size of the filesystem

Working with storage is always risky, but this kind of operations are specially dangerous.
I’m sure it is not necessary to remind this, your backups are all working as expected and in shape. But at this point, it would be worth checking it.
The order we are going to follow to decrease the size is more or less the opposite we did in the last section.

  • Check the space occupation in the filesytem.
  • Unmount filesystem.
  • Resize the filesystem.
  • Decrease the size of the logical volume.

You must reduce the filesystem BEFORE you reduce the logical volume.

Checking the space occupation in the filesytem

Review the amount of space available in the filesystem and make sure there is more free space that the amount of space you want to reduce.
If you don’t have enough free space, you will have to delete some data or reduce the filesystem less than expected.

Unmounting the filesystem

Unfortunately, reducing the filesystem size in ReiserFS is not implemented. So, we will have to unmount it.
Remember this to plan this tasks if you are working on a production environment.
Just unmount it, in our case /mnt/temp:

umount /mnt/temp

Resizing the filesystem

It is time to reduce the filesystem. We will do it by using “resize_reiserfs”, the same tool we used before.
In our example, we are setting the new total size of the LV to 1 GB in lv_rfssample:

resize_reiserfs -s-1G /dev/vg_storage1/lv_rfssample

Decreasing the size of the logical volume

Now we can reduce the size of our logical volume. As you have already guessed, we can reduce less or equal space than the reduced in the last step.
We are using “lvreduce” to do this.
In our example, we are reducing 1 GB our LV lv_rfssample:

lvreduce -L-1G /dev/vg_storage1/lv_rfssample

It is only left to mount the volume again and we will see the new size.
We can also check the volume group vg_storage1. It will now have the free space released from lv.

We will continue our LVM series with JFS filesystem management.

Leave a Reply

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