Set Up LVM/LVM2 Using Webmin

Error message

  • Notice: unserialize(): Error at offset 2 of 8 bytes in variable_initialize() (line 1189 of /home/stevenmcmurry/public_html/includes/bootstrap.inc).
  • Notice: unserialize(): Error at offset 2 of 8 bytes in variable_initialize() (line 1189 of /home/stevenmcmurry/public_html/includes/bootstrap.inc).

First off, what is Logical Volume Management and why do you need it? LVM is basically a set of hard drives grouped into being seen by the system as one hard drive. It is different than RAID, because there is no redundancy. In addition, the drives that are "grouped" can be of any size or any interface. You can have SATA, SAS, and IDE all in the same LVM. I wouldn't recommend it, but you could.

But what is it used for? Gigantic volumes, of course! Right now the largest hard drive you can buy is 3TB. What happens when you need a volume larger than that? You can use a RAID setup that will add redundancy, but you will also need a better controller and a lot more drives. But a simpler, quicker solution is to use LVM.

Here's the overview to get LVM going within Webmin:

  • Install LVM
  • Refresh Webmin Modules
  • Add a Volume Group
  • Add drives to the Volume Group
  • Add a Logical Volume within the Volume Group
  • Create the file system within the Logical Volume
  • Mount the newlycreated file system

Now for the nitty-gritty:

  • From the command line, install LVM
  • sudo apt-get install lvm2

  • Once LVM is installed, refresh the modules within Webmin
  • With Logical Volume Management selected under the Hardware menu, click on the Add new volume group link

  • Give your new Volume Group a name and an initial drive to use. I chose archive and my first drive is /dev/sdb.
  • Now that the Volume Group has one drive, it's time to add any additional drives. Click on the Physical Volumes link to add more drives.
  • Under the Physical Volumes tab, click on the Add a physical volume to [volume group] link
  • Enter the next drive that you wish to use and then select the Add to volume group button. Mine was /dev/sdc, but yours may be different.
  • With both drives in the Volume Group, we are now ready to add a Logical Volume
  • Under the Logical Volumes tab, click on the Create a logical volume in [volume group] button
  • Give your Logical Volume a name. This can be different from your Volume Group name, but if you only have one LVM on the system it might as well be the same.
  • With your Logical Volume created, we are now ready to add the file system and mount it. Click on the icon for the Logical Volume to start this process.
  • If you wish to rename the Logical Volume, you can do it here. If not, select the type of file system you wish to create from the drop-down list and click on the Create Filesystem of Type: button. I chose ext4 for its journaling and speed capabilities.
  • If you wish to choose different options for your filesystem than the default, change them here. If you don't know what these mean, don't change them!
  • The command to create the file system will now be run, and it will take quite some time to create. For my 4TB volume it was about 20-30 minutes.
  • Success! We now have a working volume and are ready to mount!
  • Now we're ready to mount the Logical Volume. Create a folder on your computer. I chose /newdata/archive, but /media/[volume] or /home/[user]/[volume] works just as well. Under the Logical Volume tab, click on the icon for your LV. Just below the file system creation button you will see a button labeled Mount LV on:. In the box next to that, type the path that you want to mount on.
  • That's it- you should now have an LVM mounted that spans multiple drives and ready to house any large amount of data!

    Share this

    Tags: 

    Comments

    hi perfect totorial how to add more disk and resize the lvm2 partition with webmin thanks leandro

    Webmin | Partitions on Local Disks Select drive | Add primary Partition | Type: Linux If there is an error of: "unrecognised disk label" first Wipe Partitions | type MS-DOS then create partition

    I used Webmin but on the command line have to do "apt-get install lvm2" and "Refresh Modules" on Webmin. I used two USB Flash drives 128GB each and made them look like one drive. It worked very good. Thank you. -Raymond Day

    I did this all on a HDMI stick with PicUntu on it. A MK802IV with 4 cores and 2GB RAM. It works very good as a server and I can still hook up a HDMI cable to it and get on it's desktop if I want to. It's nice to have this ARM CPU that don't take a lot of power so I keep it as a server on 24/7. The hard drives will go to sleep when not being used. -Raymond Day

    I have two hard drives: sda (250GB) and sdb (250GB). If I want to extend sda by adding sdb to sda, is this possible? All of my files are stored in sda. Will I lose them in the process?

    Hello, great tutorial. Before I start I would like to know if I'll lose data from first volume. Thank you!