[SATLUG] How can I reclaim unused space?

Tweeks tweeksjunk2 at theweeks.org
Fri Jun 27 23:15:39 CDT 2008

On Friday 27 June 2008 10:12:42 pm pixelnate at gmail.com wrote:
> On Fri, 2008-06-27 at 22:07 -0500, Todd W. Bucy wrote:
> > LVM = Logical Volume Manager.  It basically lets you do what it is your
> > trying to do...that is add or subrtact disk space on partitions.
> How would I know?

This disk layout shows a non-LVM based system:
# fdisk -l
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1246    10008463+  83  Linux
/dev/sda2            1247        1380     1076355   82  Linux swap / Solaris
/dev/sda3            1381        9729    67063342+  83  Linux

While this is what a system might look like that's running LVM based filesystems:

# fdisk -l

Disk /dev/hda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 106928 83 Linux
/dev/hda2 14 14023 115227947 b W95 FAT32
/dev/hda3 14024 21672 61440592+ 8e Linux LVM <------------ 60GB LVM partition

If the partition layout above was your system, then your first linux 
partition would be a 100MB ext3 boot partition, your windows filesystem 
a 115GB Windows Fat32 filesystem, and your last filesystem looks like 
the other linux filesystems (/, /home, /var, swap, etc...) within a single LVM 
volume group (probably).  You could see more with the "df -h" command couple 
with vgdisplay and lvdisplay.

If this is kind of what your Win/Lin system looks like, then you can simply 
run fdisk, change the second partition type to "type 8e" (Linux LVM) too.. 
then run the commands:

# partprobe
# pvcreate /dev/hda2  <------- To mark the second partition as a usable "physical volume" for the existing 
volume group
  Physical volume "/dev/hda2" successfully created

# vgextend VolGroup00 /dev/hda2 <----use the name of the volumegroup that "vgdisplay" shows
  Volume group "VolGroup00" successfully extended
Then use "lvdisplay" and "df -h" to show the name of the Logical Volume filesystem that 
you wish to "grow"...

If it is (for example) /dev/VolGroup00/LogVol00.. then you would use the 
command "lvextend /dev/VolGroup00/LogVol00" (IIRC) to put the new space 
we just added to the volume group into the LogVol00 logical volume.  
After that's done.. the LVM logical volume "LogVol00" has just grown by 
the amount of space that you just gave the volume group.  Now.. you can't 
use that extra LV space until you also grow your filesystem.  If it's ext3, 
then you simply type "ext2online /dev/VolGroup00/LogVol00" to grow your 
of your live, mounted filesystem!  And when complete, that filesystem will
be using all that new logical volume space you freed up.. and you're done.. 
Without even so much as a reboot! :)

Sorry if this is confusing.. I can't give you exact commands without seeing 
your system. (and really, I shouldn't be giving such dangerous directions 
this late at night anyway.. ;)

Here... Here's a fairly good set of directions for Fedora based systems..

Also.. if you feel safer doing this on a non-live system, you can also do this booted from a live CD like 
Knoppix so that you're not operating on yourself (as it were).  Just be sure to use a current version of 
boot CD.. You want to try to stay away from mixing LVM1 and LVM2 systems and tools IIRC.


More information about the SATLUG mailing list