您的当前位置:首页 --> Linux操作指南
Linux VPS 扩充磁盘 [动态添加合并挂载]
浏览次数:1862 关键词 ( )
Linux操作系统扩充硬盘,此办法挂载硬盘,可把可用的硬盘空间,全部扩充到一个硬盘下,这样的好处就是,硬盘的空间可以利用起来,但坏处就是如果此硬盘分区出问题,就会导致硬盘分区损坏,可能在损坏下的数据就无法恢复了。

SSH登录到Linux系统先检查硬盘分区和挂载情况

df -hal



fdisk -l



以上可以看到,/dev/xvdb有20G硬盘没有分区,接下来就是对/dev/xvdb分区

fdisk /dev/xvdb

[root@MyVPS ~]# fdisk /dev/xvdb
The number of cylinders for this disk is set to 2871.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
输入n新建分区
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p

/dev/xvdb中第1个分区
Partition number (1-4): 1
First cylinder (1-2871, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2871, default 2871):
Using default value 2871

输入t,改变分区格式为8e (LVM格式)
Command (m for help): t
selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

输入w保存退出
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

重启机子生效 (可省略)

reboot


再次运行fdisk -l,我们看到
xvdb1分区为8e(LVM)格式生效了

先查看卷组情况,和卷组名称 (注:每种Linux系统的卷组名称都会不一样,接下来的参数也需要随之修改)

vgs



以上我们看到卷组名称为“VolGroup00”
创建物理卷,并将物理卷加入到组VolGroup00(注:卷名VolGroup00,因系统不同改变)

pvcreate /dev/xvdb1
vgextend VolGroup00 /dev/xvdb1



查看卷组剩余空间情况

vgdisplay



我们看到Free PE / Size有19.97G空间,那么把19.96G空间扩容到VolGroup00
(注:为什么这里是扩容19.96G,其实这里并没有19.97G,按单位换算大约在19.96G多点)

lvresize -L +19.96G /dev/VolGroup00/LogVol00
resize2fs /dev/VolGroup00/LogVol00



通过命令查看扩容最后情况

df -hal



系统重装后的重装扩展处理!
重装后,直接执行resize2fs进去动态扩容即可。

resize2fs /dev/VolGroup00/LogVol00

PVs missing导致LVM无法重新扩容的解决办法!
运行vgextend、vgdisplay返回错误:

Couldn't find device with uuid ************************
Cannot change VG VolGroup00 while PVs are missing.

此时可以运行

vgreduce VolGroup00  --removemissing
下一条 修改宝塔面板默认WWW安装目录为其他挂载盘目录
上一条 Linux VPS服务器修改root管理员密码

数千企业与站长的选择,7*24小时稳定运行

 了解更多套餐详细