Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


kvm_grow_pv

This is an old revision of the document!


~~TOC~~

KVM grow PV

  • Current partition table:
    # fdisk -l /dev/sda
    
    Disk /dev/sda: 2000.3 GB, 2000341917696 bytes, 3906917808 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 262144 bytes / 524288 bytes
    Disk label type: dos
    Disk identifier: 0x000b9cd2
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        2048     1026047      512000   83  Linux
    /dev/sda2         1026048   592416767   295695360   8e  Linux LVM
  • Remove /dev/sda2 partition and create a new bigger one:
    # fdisk /dev/sda
    Welcome to fdisk (util-linux 2.23.2).
    
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): d
    Partition number (1,2, default 2): 2
    Partition 2 is deleted
    
    Command (m for help): n
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): p
    Partition number (2-4, default 2): 2
    First sector (1026048-3906917807, default 1026048): 
    Using default value 1026048
    Last sector, +sectors or +size{K,M,G} (1026048-3906917807, default 3906917807): +512G
    Partition 2 of type Linux and of size 512 GiB is set
    
    Command (m for help): p
    
    Disk /dev/sda: 2000.3 GB, 2000341917696 bytes, 3906917808 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 262144 bytes / 524288 bytes
    Disk label type: dos
    Disk identifier: 0x000b9cd2
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        2048     1026047      512000   83  Linux
    /dev/sda2         1026048  1074767871   536870912   83  Linux
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
  • If disk is in use, reboot. Else try partprobe or kpartx.
  • Resize PV:
    # pvresize /dev/sda2
      Physical volume "/dev/sda2" changed
      1 physical volume(s) resized / 0 physical volume(s) not resized
kvm_grow_pv.1434697632.txt.gz · Last modified: 2015/06/19 07:07 by admin