我的/boot当时安装的时候只分了不到200MB现在不够了所以扩容下
这是我学习的文章:https://blog.51cto.com/u_15801765/5697187
开始操作前,可以先用命令 df -hl 记录一下你现在/boot 剩余磁盘空间。
到文章最后面我们可以对比一下/boot磁盘扩容后做个对比。
第一步:虚拟机添加新的硬盘。点虚拟机->设置->添加。

选择硬盘



下图的硬盘大小可以看需要选择,一般情况下3个G左右就足够了(还有剩)



回到虚拟机命令界面,将原来/boot里面的内容,备份到/目录下新建的一个/boot_old目录
cd / (切记先切换到‘/’目录下)
mkdir /boot_old (新建一个备份文件夹存放旧的boot)
cp -r /boot /boot_old (把 /boot 文件备份复制到 /boot_old)
第三步:可以先重启一下,因为添加了新硬盘,虚拟机要重新读取这块硬盘,使用命令reboot重启虚拟机
然后进行给新的硬盘分区
首先使用 lsblk -f 查看我们新加的硬盘
如果有一个选项没有UID就代表这是我们新的硬盘,比如下图中的sdb。

使用
fdisk /dev/sdb
你可能会遇到这样的问题:(这个不知道为啥,复制不可以,手打一下就可以了,没遇到当我没说)

成功后是这样的:

然后输入m

然后输入n

然后输入p(代表主区)

然后输入1(代表你这一块一盘就分了一个区,你如果想分2个区就写2)

然后按两下回车 (默认选择 First sector 和 Last sector ) 直到下图界面

最后再输入w

这样分区就完成了。
然后可以检查一下,使用 lsblk -f 命令,可以看到分了一个sdb1这个区,因为我们上面只输入1个区

使用mkfs.xfs /dev/sdb1(sdb1代表sdb硬盘的第一个分区,如果你最开始设置的boot界面不是xfs类型的就别写xfs,写你自己的那个类型,不知道自己的是什么类型的,输入lsblk -f就可以查看,如下图)

格式化分区 mkfs.xfs /dev/sdb1 执行完后是这样的

现在就已经格式化好了。
lsblk -f 在查看下

umount /boot
第七步挂载mount /dev/sdb1 /boot
第八步:设置永久挂载编辑fstab的内容
vi /etc/fstab
先把之前这个旧的/boot 用#号注释了

然后新添加一行下面内容就可以了,
/dev/sdb1 /boot xfs defaults 0 0
注意你们的硬盘分区位置(最左边/dev/sdb1写你们自己的,然后第二个矩形框地方为/boot,然后后面写你自己的文件类型就可以了,defaults后面就写两个0,然后 :wq保存并退出,reboot重启就可以了)

输入lsblk -f 查看是否挂载成功,sdb1后面新出现了个/boot,出现下图情况就代表成功了。

使用命令将原来备份的数据再复制进去
cp -r /boot_old /boot
到此,扩容就彻底成功了。
查看磁盘剩余空间
df -hl

常遇到的问题:

这种情况说明你没有 cd / 切换到 /根目录下,仔细看我的步骤,文字或者截图上面都有
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
网站栏目:VMware-【Linux】centos7/boot磁盘扩容-创新互联
网页链接:http://scpingwu.com/article/hhjji.html