My adventurous rebuild of my home server continues.
I made a mistake when rebuilding my VMWare Server virtual machine, I used the default 8GB partition size, which is too small, even though it only holds work files for a couple of users.
I had most things back up and running, so it was time to fix my disk space error. This turned into a crash course in Logical Volume Manager (LVM).
DISCLAIMER: I take no responsibility for any actions that you take on your own systems. As I mentioned, this is all new to me, and it is very possible that I have made mistakes. Follow at your own risk. I’m not even sure that I have all the terminology correct.
The following are somewhat edited notes that I took as I went along.
First, some terminology, mostly from: http://www.linux-tutorial.info/modules.php?name=Howto&pagename=LVM-HOWTO/vg.html
- LVM abstracts disk space as seen by the operating system from physical disks.
- A Volume Group is the highest level abstraction used within the LVM. It gathers together a collection of Logical Volumes and Physical Volumes into one administrative unit.
- A physical volume is typically a hard disk, though it may well just be a device that ‘looks’ like a hard disk (eg. a software raid device).
- Equivalent of a disk partition in a non-LVM system. The LV is visible as a standard block device; as such the LV can contain a file system (eg. /home).
General overview: Create disk space in VMWare (or add physical disk space in a non virtualized environment). Create a new partition. Join that partition to a Logical Volume to make the Logical Volume larger. Expand the Linux partition to fill it’s now bigger Logical Volume.
The steps that I took:
- Expand the VMWare virtual disk with the VMWare tool (Google for it). The non-VM equivalent would be to clone an old, smaller drive onto a new, larger drive.
- create a new disk partition on the VMWare “physical” disk.
- /sbin/fdisk /dev/sda
- n [new]
- p [primary – I wonder if E would have been a better long term choice]
- 3 [I think there are two already]
- defaults for size
- w [write]
- /sbin/shutdown -r now
- create the physical partition (LVM)
- /sbin/pvcreate /dev/sda3
- that worked:
- Now, I add the physical volume to the Volume Group (this was helpful: http://www.gentoo.org/doc/en/lvm2.xml). I have a volume group “main” already. I have to add the physical partition to it.
- Now, add I have to extend the Logical Volume to use up all the new space in the Volume Group (see: http://wiki.contribs.org/Raid#Upgrading_the_Hard_Drive_Size).
- # /usr/sbin/lvresize -l +100%FREE main/root
- Ugh. I still have to resize the EXT3 partition.
- #/usr/sbin/ext2online -d -v /dev/main/root
- Phew. It looks like I have a 20G root volume that works.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/main-root20G 6.3G 12G 35% /
/dev/md1 99M 16M 78M 18% /bootnone 125M 0 125M 0% /dev/shm