virtualbox – 使用vgextend / lvextend添加额外的8GB空间但它没有反映在df输出中

前端之家收集整理的这篇文章主要介绍了virtualbox – 使用vgextend / lvextend添加额外的8GB空间但它没有反映在df输出中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在VirtualBox中创建了一个ubuntu VM实例.一开始我只为存储分配了7GB,而VM现在已经用完了空间.

首先,我通过VirtualBox前端向VM添加了另外8GB(/ dev / sdb).然后我设置以下分区:

  1. $sudo fdisk -l /dev/sdb
  2.  
  3. Disk /dev/sdb: 8589 MB,8589934592 bytes
  4. 40 heads,1 sectors/track,419430 cylinders,total 16777216 sectors
  5. Units = sectors of 1 * 512 = 512 bytes
  6. Sector size (logical/physical): 512 bytes / 512 bytes
  7. I/O size (minimum/optimal): 512 bytes / 512 bytes
  8. Disk identifier: 0x076b5690
  9.  
  10. Device Boot Start End Blocks Id System
  11. /dev/sdb1 2048 16777215 8387584 5 Extended
  12. /dev/sdb5 4096 16777215 8386560 8e Linux LVM

然后我运行以下命令来扩展VG.

  1. sudo pvcreate /dev/sdb5
  2. sudo vgextend ubuntudevBox2 /dev/sdb5
  3. sudo lvextend 100% /dev/ubuntudevBox2/root
  4. lvextend --help
  5. sudo lvextend -l 100%FREE /dev/ubuntudevBox2/root
  6. sudo lvextend -r -l 100%FREE /dev/ubuntudevBox2/root
  7. sudo resize2fs /dev/mapper/ubuntudevBox2-root

我原本预计/的大小会扩展到16Gb.然而,df报告说

  1. $df -h
  2. Filesystem Size Used Avail Use% Mounted on
  3. /dev/mapper/ubuntudevBox2-root 8.0G 6.9G 680M 92% /

根安装只增加到8G

这是VG信息

  1. $sudo vgdisplay ubuntudevBox2
  2. [sudo] password for antkong:
  3. --- Volume group ---
  4. VG Name ubuntudevBox2
  5. System ID
  6. Format lvm2
  7. Metadata Areas 2
  8. Metadata Sequence No 5
  9. VG Access read/write
  10. VG Status resizable
  11. MAX LV 0
  12. Cur LV 2
  13. Open LV 2
  14. Max PV 0
  15. Cur PV 2
  16. Act PV 2
  17. VG Size 15.75 GiB
  18. PE Size 4.00 MiB
  19. Total PE 4033
  20. Alloc PE / Size 2182 / 8.52 GiB
  21. Free PE / Size 1851 / 7.23 GiB
  22. VG UUID ZV6VAi-qkxC-KnKz-1LHg-nfLB-afSI-mVpIPv

为什么我没有获得完整的8Gb额外空间?

附加信息1:我在使用fdisk添加新分区后立即运行了mkfs -t ext5 / dev / sdb5.它会导致失败吗?

附加信息2:

  1. $uname -a
  2. Linux ubuntudevBox2 3.5.0-27-generic #46-Ubuntu SMP Mon Mar 25 19:58:17 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

lvdisplay输出

$sudo lvdisplay

  1. --- Logical volume ---
  2. LV Path /dev/ubuntudevBox2/root
  3. LV Name root
  4. VG Name ubuntudevBox2
  5. LV UUID V1Qq0f-qKJR-UTf5-4tjM-ycoY-1J5L-mJQ2Fy
  6. LV Write Access read/write
  7. LV Creation host,time ubuntudevBox2,2013-03-29 12:18:26 +1100
  8. LV Status available
  9. # open 1
  10. LV Size 8.03 GiB
  11. Current LE 2055
  12. Segments 3
  13. Allocation inherit
  14. Read ahead sectors auto
  15. - currently set to 256
  16. Block device 252:0
  17.  
  18. --- Logical volume ---
  19. LV Path /dev/ubuntudevBox2/swap_1
  20. LV Name swap_1
  21. VG Name ubuntudevBox2
  22. LV UUID LbvPFE-j3GO-oaF1-HQV3-a2r5-HTfy-YrhQve
  23. LV Write Access read/write
  24. LV Creation host,2013-03-29 12:18:29 +1100
  25. LV Status available
  26. # open 2
  27. LV Size 508.00 MiB
  28. Current LE 127
  29. Segments 1
  30. Allocation inherit
  31. Read ahead sectors auto
  32. - currently set to 256
  33. Block device 252:1

解决方法

输出是绝对的
  1. sudo lvextend -l 100%FREE /dev/ubuntudevBox2/root

因为你在vgextended之后只有8G的可用范围,所以你只得到一个代表8G绝对大小的lv.

您必须通知LVM您打算增加一个空间大小.来自lvextend的联机帮助页;

  1. -l,--extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}]
  2. Extend or set the logical volume size in units of logical
  3. extents. With the '+' sign the value is added to the actual
  4. size of the logical volume and without it,the value is taken as
  5. an absolute one.

尝试

  1. sudo lvextend -l +100%FREE /dev/ubuntudevBox2/root

猜你在找的Linux相关文章