Changes between Initial Version and Version 1 of extend-disk-on-kvm-guest


Ignore:
Timestamp:
Jan 18, 2011, 3:28:26 PM (15 years ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • extend-disk-on-kvm-guest

    v1 v1  
     1= How do I extend the disk space for a KVM guest? =
     2
     3Our KVM guests are each allocated a single logical volume from the KVM host's volume group (typically named after the host).
     4
     5The first and easiest step is to login to the host, check available disk space, and then run the lvextend command:
     6
     7{{{
     80 ken:~# vgs
     9  VG      #PV #LV #SN Attr   VSize VFree
     10  vg_ken0   1  16   0 wz--n- 1.82t 1.29t
     110 ken:~# lvs | grep mirabal
     12  mirabal  vg_ken0 -wi-ao  20.00g                                     
     130 ken:~# lvextend --size 35G vg_ken0/mirabal
     14  Extending logical volume mirabal to 35.00 GiB
     15  Logical volume mirabal successfully resized
     160 ken:~#
     17}}}
     18
     19Next, you will need to reboot the guest before the change in disk space is recognized by the guest (is there a way around this??).
     20
     21After rebooting, you can confirm the new size by running:
     22
     23{{{
     24cat /proc/partitions
     25}}}
     26
     27You should see that the base disk (e.g. /dev/sda), although all of the partitions are the same size.
     28
     29Next, run parted and print the current partition table. It's often easier to manage if you look at units in sectors:
     30
     31{{{
     32parted /dev/sda
     33unit s
     34p
     35}}}
     36
     37You can optionally create a new partition with the remaining space:
     38
     39{{{
     40mkpart primary STARTSECTOR ENDSECTOR
     41}}}
     42
     43Or, you can delete the last partition, and re-create it with a higher end sector (yes, you can do this without destroying the data on the disk):
     44
     45{{{
     46rm 2
     47mkpart primary STARTSECTOR ENDSECTOR
     48}}}
     49
     50When creating new partitions, it's a good idea to ensure that the total size of the sector is divisible by 4096.