Ubuntu – How to resize an active LVM partition

filesystemlvmpartitioning

I am quite new to LVM and I'm uncertain about what is happening here. I was not the one to initially setup this machine.

There is a harddrive of 1tb in size and an LVM partition of only 50gb in size. I can not figure out how I can use the remaining space of the harddrive.

output of command df -h:

Filesystem              Size  Used Avail Use% Mounted on
/dev/mapper/vg00-slash   46G  1.4G   42G   4% /
udev                    3.9G  4.0K  3.9G   1% /dev
tmpfs                   1.6G  236K  1.6G   1% /run
none                    5.0M     0  5.0M   0% /run/lock
none                    3.9G     0  3.9G   0% /run/shm
/dev/sda1               232M   29M  191M  14% /boot

output of command fdisk -l:

Disk /dev/sda: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders, total 2147483648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00038096

   Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *        2048      499711      248832   83  Linux
 /dev/sda2          501758   104855551    52176897    5  Extended
 /dev/sda5          501760   104855551    52176896   8e  Linux LVM

Disk /dev/mapper/vg00-swap: 3997 MB, 3997171712 bytes
255 heads, 63 sectors/track, 485 cylinders, total 7806976 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg00-swap doesn't contain a valid partition table

Disk /dev/mapper/vg00-slash: 49.4 GB, 49429872640 bytes
255 heads, 63 sectors/track, 6009 cylinders, total 96542720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg00-slash doesn't contain a valid partition table

What I assume I had to do, was create a new partition on /dev/sda to contain the remaining space but when trying to create a new primary partition I am told I can't.

Last sector, +sectors or +size{K,M,G} (499712-501757, default 501757): +800G
Value out of range.

I do not know what I can do now…


When trying to resize the logical volume I get:

# lvresize vg00/slash -L +800g
Extending logical volume slash to 846.04 GiB
Insufficient free space: 204800 extents needed, but only 0 available

# pvdisplay -m
--- Physical volume ---
PV Name               /dev/sda5
VG Name               vg00
PV Size               49.76 GiB / not usable 2.00 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              12738
Free PE               0
Allocated PE          12738
PV UUID               WNZba3-bCCs-NmqL-Bc9v-zusy-TtfQ-BpAj3e

--- Physical Segments ---
Physical extent 0 to 952:
  Logical volume      /dev/vg00/swap
  Logical extents     0 to 952
Physical extent 953 to 12737:
  Logical volume      /dev/vg00/slash
  Logical extents     0 to 11784

(parted) print free                                                       
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 1100GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
        32.3kB  1049kB  1016kB            Free Space
 1      1049kB  256MB   255MB   primary   ext4         boot
        256MB   257MB   1048kB            Free Space
 2      257MB   53.7GB  53.4GB  extended
 5      257MB   53.7GB  53.4GB  logical                lvm
        53.7GB  1100GB  1046GB            Free Space

Best Answer

It looks like you're trying to add a new primary partition in-between your current /dev/sda1 and /dev/sda2. (Evidence: fdisk is saying that the acceptable ranges of end points are 499712-501757, default 501757, which is between those two partitions.) There simply isn't enough space there to do that. Instead, tell fdisk to begin the partition at 104855552 (or later) and give it the default end value (unless you want to save some space for some other purpose). This should give you a partition that uses the rest of the available disk space, minus a bit of wastage near the beginning.

Alternatively, you could use cfdisk, GParted, or some other tool that provides a more visual approach to partitioning, which will make such an error less likely.

Related Question