XenSystem VPS下启用(挂载)未使用的硬盘空间

林继 VPS 知识 3,010 共写了307个字 (2012-11-15 12:43:54) 没有评论 打印 扫描二维码 百度已收录

XenSystem 系统有个不好的地方,就是新开通的VPS或者重新安装系统后的VPS,硬盘空间都没有挂载,需要自己手动挂载一下。以下是完整的挂载记录

查看硬盘分区情况

  1. fdisk -l
  2. df -hal #查看已划分区空间使用情况

添加整个物理硬盘到lvm

  1. pvcreate /dev/xvdb #添加整个物理硬盘xvdb到lvm
  2. vgextend VolGroup00 /dev/xvdb #添加整个物理硬盘xvdb到LVM卷VolGroup00
  3. vgdisplay #查看结果
  4. #lvresize -L +20.00G /dev/VolGroup00/LogVol00 #扩展20G硬盘 这里出现错误,不需要执行
  5. lvresize -L +19.96G /dev/VolGroup00/LogVol00 #扩展硬盘20G 略微有个差数
  6. resize2fs /dev/VolGroup00/LogVol00 重置LVM大小

附加说明

也可以对/dev/xvdb分区再加入LVM。 我这里是直接把硬盘整个的加入LVM了。
创建分区:

  1. fdisk /dev/xvda
  2. n 输入n新建分区
  3. p 输入p,主分区
  4. 3 由上图的fdisk -l可以看到硬盘已经有两个分区,我们这里输入3,第三个分区
  5. t 通过t来指定分区系统格式
  6. 33个分区(如果你就建了一个分区就不要输入3了它会自动选择的.跳过这一步)
  7. 8e 输入8e,LVM系统格式
  8. w 输入w保存退出
  9. reboot 重启使之生效

加入分区:

  1. pvcreate /dev/xvda3 #创建物理卷
  2. vgextend VolGroup00 /dev/xvda3 #将物理卷加入到组VolGroup00

完整的命令交互记录

  1. [root@MyVPS ~]# fdisk -l
  2.  
  3. Disk /dev/xvda: 10.7 GB, 10737418240 bytes
  4. 255 heads, 63 sectors/track, 1305 cylinders
  5. Units = cylinders of 16065 * 512 = 8225280 bytes
  6.  
  7.     Device Boot      Start         End      Blocks   Id  System
  8. /dev/xvda1   *           1          13      104391   83  Linux
  9. /dev/xvda2              14        1044     8281507+  8e  Linux LVM
  10. /dev/xvda3            1045        1305     2096482+  8e  Linux LVM
  11.  
  12. Disk /dev/xvdb: 21.4 GB, 21474836480 bytes
  13. 255 heads, 63 sectors/track, 2610 cylinders
  14. Units = cylinders of 16065 * 512 = 8225280 bytes
  15.  
  16. Disk /dev/xvdb doesn't contain a valid partition table
  17. [root@MyVPS ~]# df -hal
  18. Filesystem            Size  Used Avail Use% Mounted on
  19. /dev/mapper/VolGroup00-LogVol00
  20.                       9.3G  1.8G  7.1G  20% /
  21. proc                     0     0     0   -  /proc
  22. sysfs                    0     0     0   -  /sys
  23. devpts                   0     0     0   -  /dev/pts
  24. /dev/xvda1             99M   36M   58M  39% /boot
  25. tmpfs                 513M     0  513M   0% /dev/shm
  26. none                     0     0     0   -  /proc/sys/fs/binfmt_misc
  27. sunrpc                   0     0     0   -  /var/lib/nfs/rpc_pipefs
  28. [root@MyVPS ~]# vgdisplay
  29.   --- Volume group ---
  30.   VG Name               VolGroup00
  31.   System ID
  32.   Format                lvm2
  33.   Metadata Areas        2
  34.   Metadata Sequence No  5
  35.   VG Access             read/write
  36.   VG Status             resizable
  37.   MAX LV                0
  38.   Cur LV                2
  39.   Open LV               2
  40.   Max PV                0
  41.   Cur PV                2
  42.   Act PV                2
  43.   VG Size               9.84 GB
  44.   PE Size               32.00 MB
  45.   Total PE              315
  46.   Alloc PE / Size       315 / 9.84 GB
  47.   Free  PE / Size       0 / 0
  48.   VG UUID               ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI
  49.  
  50. [root@MyVPS ~]# pvcreate /dev/xvdb
  51.   Physical volume "/dev/xvdb" successfully created
  52. [root@MyVPS ~]# vgextend VolGroup00 /dev/xvdb
  53.   Volume group "VolGroup00" successfully extended
  54. [root@MyVPS ~]# vgdisplay
  55.   --- Volume group ---
  56.   VG Name               VolGroup00
  57.   System ID
  58.   Format                lvm2
  59.   Metadata Areas        3
  60.   Metadata Sequence No  6
  61.   VG Access             read/write
  62.   VG Status             resizable
  63.   MAX LV                0
  64.   Cur LV                2
  65.   Open LV               2
  66.   Max PV                0
  67.   Cur PV                3
  68.   Act PV                3
  69.   VG Size               29.81 GB
  70.   PE Size               32.00 MB
  71.   Total PE              954
  72.   Alloc PE / Size       315 / 9.84 GB
  73.   Free  PE / Size       639 / 19.97 GB
  74.   VG UUID               ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI
  75.  
  76. [root@MyVPS ~]# lvresize -L +20.00G /dev/VolGroup00/LogVol00
  77.   Extending logical volume LogVol00 to 29.59 GB
  78.   Insufficient free space: 640 extents needed, but only 639 available
  79. [root@MyVPS ~]# lvresize -L +19.96G /dev/VolGroup00/LogVol00
  80.   Rounding up size to full physical extent 19.97 GB
  81.   Extending logical volume LogVol00 to 29.56 GB
  82.   Logical volume LogVol00 successfully resized
  83. [root@MyVPS ~]# resize2fs /dev/VolGroup00/LogVol00
  84. resize2fs 1.39 (29-May-2006)
  85. Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
  86. Performing an on-line resize of /dev/VolGroup00/LogVol00 to 7749632 (4k) blocks.
  87. The filesystem on /dev/VolGroup00/LogVol00 is now 7749632 blocks long.

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

< >