Enter on the questions. Don’t quit out of fdisk yet as we have more to do !
www.linuxuser.co.uk
3209
Managing LVMs the GUI way There is actually a GUI tool, system-config-lvm. We purposely didn't mention this earlier because you need to understand how all the components of how the system fits together.Not only that but also not all systems, especially servers have a GUI installed. To install the package install system-config-lvm.noarch. This will install the graphical LVM tool.
To try it out, lets try with a basic server with an additional 1 GB drive.
Resize your disks on the fly with LVM
Tutorial
08
Generation gameAnd lastly we will need to extend the actual file system. There is a command called resizefs that we can use. As the name implies, it is used to resize the filesystem.
[root@localhost ~]# resize2fs /dev/
mapper/vg_data-lvdata
resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/mapper/
vg_data-lvdata to 2219008 (4k) blocks.
The filesystem on /dev/mapper/vg_data-lvdata is now 2219008 blocks long.
07
Expanding our volumesTo do this, it is a very similar method to creating an LVM; we need to in effect prepare the new disk as an LVM member. To do so, repeat the process we performed earlier to prepare the disks (with fdisk and pvcreate).
06
Making our volumesNow we can format the disk using the following command:
mkfs.ext4 /dev/mapper/vg_data-lvdata To test the partition, try mounting it.
Now this is where things get interesting. This could be a 60GB or 600GB disk. We just chose the 1GB as an example. Now, say we have filled this disk with all our our ISOs and such, how do we fix it and add that shiny new disk into the logical disk? This is where we see the joy of LVM.
We can expand our volume over the new disk and make our volume bigger!
Remember, a
Now that the partition is prepared, we can add it into the volume group we just created. To do this we use the vgextend command, as shown below. The syntax is quite straightforward with the first argument being the volume group you want to add the disk to and secondly, the disk you wish to add.
vgextend vg_data /dev/sdc1
Now that the VG is extended, we need to perform a similar process to increase the logical disk to use the underlying storage we expanded before. Below is a simple example to just expand our VG with a 1GB partition.
lvextend -L +1G /dev/mapper/vg_data /dev/sdc1
from the volume group we created. To clarify, lv_data is our new logical volume, while vg_data is the volume group to take it from. You can make the volume as small or large as you like, given a big enough volume group. We are using the entire volume group, rather than just a small portion of it. All the volume groups can be found under the /dev/mapper directory.
Now we can create a logical disk on top of it.
www.linuxuser.co.uk
3311
…And the volume groupOnce this has completed, you will see that the disk has moved from Uninitialized to Unallocated – so, basically, it is prepped to add to our volume group.
You will also notice that if you click on the unallocated volumes you will get a group of buttons below, each stating its purpose.
You could, if you wanted, create a new volume group with this disk – or, as we did before, add the disk to an existing volume. Remember, a VG is just a chunk of space that you can split up as you wish; so when you are presented with the sizing screen, carve up that space as you wish.
When creating a new volume group, you will get a selection, as shown below.
12
Creating a new volume group You can leave these options as they are as they’re reasonable defaults. At this point you will see the make-up of your new volume group, the physical disks and the logical make-up.10
Creating our physical volumes (again!)Start by loading the LVM tool. If you look to the left-hand side of the application you will see Volume Groups, Unallocated Volumes, and Uninitialized Entities. It shows the volume groups that we work with, volumes and raw devices that are not members of volume groups.
Doing it this way can be very useful in that it will set up the disk label and such automatically, so no terminal and fdisk are required.
Before you add your unused partition, you will need to initialise the partition, as you can see. Do this by clicking Initalize Entity. This is equivalent to preparing a volume using fdisk and pvcreate as we did before.
13
Carving out storage from our LVM The last stage is to carve up a chunk of space, so select the Logical view for the VG you want to carve data out of. Hit the Create Logical Volume button. Now you can specify the logical disks.So, it’s easy enough. Give it a good name.
Again for LV properties, just go with the defaults. Size is easy enough and obvious enough. If you want to use the entire disk (most people do), click Use Remaining.
Now we have set the size, we need to decide what file system to use. As we are using CentOS 6, our default file system is ext4. Unless you have a compelling reason to change to it, leave the default selection as it is.
All file systems need a mount point to access them, so let’s put in the mount points.