Wednesday, July 27th, 2011 at 10:43am

Linux, LVM, and the ongoing quest for more storage

Posted by Jordan Erickson

Our home system had beenLogical Volume Management running low on space, so I decided to take that second 1TB hard drive that was collecting dust and throw it in the mix. Previously, it had been used as a separate drive, which had an older install of Fedora, as well as a Windows XP partition on it. I opted to take the ~875GB Fedora LVM partition, reformat it and assign it to my Debian logical volume (which was currently sitting full at 1TB).

I mainly used a howto to brush up on LVM. As it shows, there are several layers of abstraction when it comes to LVM. First, you have your physical volumes (PVs), which are the actual partitions/filesystems on your hard disks. From the PVs come what you call “Volume Groups”. VGs are groupings of “Logical Volumes” (LVs). Logical Volumes are the meat of what we’re trying to do – groupings of disks/partitions into one large usable volume, which you see after everything is said and done.

I won’t repeat the many other LVM HOWTOs out there. Instead, I’ll just tell you the process. I was lucky enough in my quest for more storage that I had already opted to use LVM when installing Debian, even though I was only using one disk at that point. If I hadn’t, it would have been much harder to convert my existing OS to it. I would highly recommend, if you are ever anticipating running out of room, to install your fresh OS with LVM (even if you don’t have more than one disk). This provides for easy expansion later on, without the headache of dealing with moving data back and forth.

Anyway, since my root partition had already been assigned as LVM, I was able to take the Fedora partitions on the second disk, wipe them off the drive, and assign all of the free space to a toasty new LVM partition. I prepped that partition for LVM with ‘pvcreate’, then formatted it with ext3 (which matched my Debian filesystem).

At this point I assigned the PV to my LV with ‘lvextend’. This tied the new partition into my existing logical volume, which essentially expanded the storage space of my system without having to worry about which files go on which partition (I really appreciate that freedom). At this point, I had thought that I was home free, but I was wrong. I saw that I still only had about 15GB free on my root filesystem (which was what I had before I started). I had read a post about possibly having to reboot after doing this, so after a failed “mount -o remount /” I decided to reboot. Still only had ~15GB free.

I scratched my head for a bit, read some more, and found out I had to use ‘resize2fs’ to resize the partition (which at this point is just a layer of abstraction). Knowing I shouldn’t EVER resize a mounted filesystem, I booted into my Debian install CD ala “Rescue Mode”, chose not to mount a root filesystem when prompted, and then executed a shell in the installer environment. I proceeded to use ‘resize2fs’, which told me to run ‘e2fsck’ first on the logical volume. I did that, went to sleep for the night, then woke up. I saw it had (finally) finished, ran ‘resize2fs’ on the LV, and after completion I rebooted, crossing my fingers…

After I logged in, ran a gnome-terminal and ran ‘df -h’, I saw that I had 875GB free on my root filesystem. Woohoo!

Now, I’m eying a 500GB hard drive that’s been sitting on my desk for a while…why not? =)

© 2011 Logical Networking Solutions: Lake and Sonoma County Computer Repair