$ cd ~/VirtualBox\ VMs/ubuntu1404-desktop/ $ VBoxManage.exe clonehd ubuntu1404-desktop-disk1.vmdk ubuntu1404-desktop-disk1.vdi --format VDI 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Clone hard disk created in format 'VDI'. UUID: 5e2ef773-98d7-43f1-8ffe-6e37273d17ce
$ sudo fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders, total 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 Disk identifier: 0x0005d213
Device Boot Start End Blocks Id System /dev/sda1 * 2048 499711 248832 83 Linux /dev/sda2 501758 20764671 10131457 5 Extended /dev/sda5 501760 20764671 10131456 8e Linux LVM
/dev/sda2と/dev/sda5のパーティションを一度削除して再定義します。
$ sudo fdisk /dev/sda
Command (m forhelp): d Partition number (1-5): 5
Command (m forhelp): d Partition number (1-5): 2
Command (m forhelp): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): e Partition number (1-4, default 2): Using default value 2 First sector (499712-83886079, default 499712): Using default value 499712 Last sector, +sectors or +size{K,M,G} (499712-83886079, default 83886079): Using default value 83886079
Command (m forhelp): n Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l Adding logical partition 5 First sector (501760-83886079, default 501760): Using default value 501760 Last sector, +sectors or +size{K,M,G} (501760-83886079, default 83886079): Using default value 83886079
再定義できているか確認します。
Command (m forhelp): p
Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders, total 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 Disk identifier: 0x0005d213
Device Boot Start End Blocks Id System /dev/sda1 * 2048 499711 248832 83 Linux /dev/sda2 499712 83886079 41693184 5 Extended /dev/sda5 501760 83886079 41692160 83 Linux
/dev/sda5をLinux LVMに変更します。
Command (m forhelp): t Partition number (1-5): 5 Hex code (type L to list codes): 8e Changed system type of partition 5 to 8e (Linux LVM)
Command (m forhelp): p
Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders, total 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 Disk identifier: 0x0005d213
Device Boot Start End Blocks Id System /dev/sda1 * 2048 499711 248832 83 Linux /dev/sda2 499712 83886079 41693184 5 Extended /dev/sda5 501760 83886079 41692160 8e Linux LVM
変更を保存してfdiskを終了します。
Command (m forhelp): wq 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.
$ sudo lvscan ACTIVE '/dev/ubuntu1404-desktop-vg/root' [39.26 GiB] inherit ACTIVE '/dev/ubuntu1404-desktop-vg/swap_1' [512.00 MiB] inherit
resize2fsを使ってファイルシステムをリサイズします。
$ sudo resize2fs /dev/ubuntu1404-desktop-vg/root resize2fs 1.42.9 (4-Feb-2014) Filesystem at /dev/ubuntu1404-desktop-vg/root is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 3 The filesystem on /dev/ubuntu1404-desktop-vg/root is now 10291200 blocks long.