我已经克隆并调整了 VirtualBox 的磁盘映像大小,但找不到使用所有新空间的方法。这是我的开始方式:
fdisk:
Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders, total 157286400 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: 0x00034aae
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 41940991 20719617 5 Extended
/dev/sda5 501760 41940991 20719616 8e Linux LVM
lv显示:
--- Logical volume ---
LV Path /dev/localhost/root
LV Name root
VG Name localhost
LV UUID tbJqka-ZlYQ-nkq4-Cufz-Yl7t-peSL-z1FGpR
LV Write Access read/write
LV Creation host, time localhost, 2014-04-16 21:15:12 +0200
LV Status available
# open 1
LV Size 18.91 GiB
Current LE 4840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/localhost/swap_1
LV Name swap_1
VG Name localhost
LV UUID 3yEDBL-Nc0G-QuVU-M9iR-Pe3u-r6E4-A5egVb
LV Write Access read/write
LV Creation host, time localhost, 2014-04-16 21:15:12 +0200
LV Status available
# open 2
LV Size 872.00 MiB
Current LE 218
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
因此,我现在已经删除了 sda2 分区并创建了一个新分区,如下所示(这是重启后):
Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders, total 157286400 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: 0x00034aae
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 499712 157286399 78393344 5 Extended
/dev/sda5 501760 157286399 78392320 8e Linux LVM
那么,我现在应该怎么做才能增加 LVM 组然后调整大小为 100%FREE?
谢谢!
答案1
经过上述操作,我自己找到了解决方案:
vgdisplay
--- Volume group ---
VG Name localhost
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.76 GiB
PE Size 4.00 MiB
Total PE 5058
Alloc PE / Size 5058 / 19.76 GiB
Free PE / Size 0 / 0
VG UUID XgGBDt-lHmJ-3Tci-hKW6-IRFU-PxN2-wsJmek
进而:
pvresize /dev/sda5
Physical volume "/dev/sda5" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
root@host:/home/vagrant# vgdisplay
--- Volume group ---
VG Name localhost
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 74.76 GiB
PE Size 4.00 MiB
Total PE 19138
Alloc PE / Size 5058 / 19.76 GiB
Free PE / Size 14080 / 55.00 GiB
VG UUID XgGBDt-lHmJ-3Tci-hKW6-IRFU-PxN2-wsJmek
root@host:/home/vagrant# vgdisplay
--- Volume group ---
VG Name localhost
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 74.76 GiB
PE Size 4.00 MiB
Total PE 19138
Alloc PE / Size 5058 / 19.76 GiB
Free PE / Size 14080 / 55.00 GiB
VG UUID XgGBDt-lHmJ-3Tci-hKW6-IRFU-PxN2-wsJmek
root@host:/home/vagrant# lvextend -l +100%FREE /dev/localhost/root
Extending logical volume root to 73.91 GiB
Logical volume root successfully resized
root@host:/home/vagrant# resize2fs /dev/localhost/root
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/localhost/root is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 5
Performing an on-line resize of /dev/localhost/root to 19374080 (4k) blocks.
The filesystem on /dev/localhost/root is now 19374080 blocks long.
root@host:/home/vagrant# df -lah
Filesystem Size Used Avail Use% Mounted on
rootfs 73G 18G 52G 26% /