01.03
!! Create a snapshot or a full-backup before you start !!
!! any mistake will destroy your system !!
1. Resize the virtual HD to new size
2. Start fdisk
# fdisk /dev/sda
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
3. Show Partitions
Command (m for help): p
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0xa8cb592
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 999424 41940991 40941568 19.5G 8e Linux LVM
Remember the partition start: 999424
4. Delete the old partition
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
5. Recreate partition
The new partition must start at the same sector where the old started. In this case at 999424
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (999424-83886079, default 999424):
Last sector, +sectors or +size{K,M,G,T,P} (999424-83886079, default 83886079):
Created a new partition 2 of type 'Linux' and of size 39.5 GiB.
6. Set Partition type
Command (m for help): t
Partition number (1,2, default 2):
Partition type (type L to list all types): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
7. Check created Partition
Command (m for help): p
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0xa8cb592e
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 999424 83886079 82886656 39.5G 8e Linux LVM
8. Write new partition to disk
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: 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).
9. Inform the OS of partition table changes
# partprobe
10. Resize the physical volume
# pvresize /dev/sda2
Physical volume "/dev/sda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
11. Check LVM Volume group
# vgdisplay
--- Volume group ---
VG Name sysvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 10
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 5
Open LV 5
Max PV 0
Cur PV 1
Act PV 1
VG Size 39.52 GiB
PE Size 4.00 MiB
Total PE 10117
Alloc PE / Size 4755 / 18.57 GiB
Free PE / Size 5362 / 20.95 GiB
VG UUID 6LlZ7P-M6by-7ISL-C9CP-iNFH-fo16-gBsclg
No Comment.
Add Your Comment