xinlugang 2020-06-11
一、 查看目前的分区信息,显示磁盘大小为30G,但分区只有10G
[ ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 30G 0 disk
└─sdb1 8:17 0 10G 0 part /mount1
二、安装EPEL以及工具
yum install -y http://dl.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install cloud-init cloud-utils-growpart dracut-modules-growroot -y
三、覆盖已有的initramfs文件
dracut -f
四、使用growpart扩展分区
[ ~]# growpart /dev/sdb 1
CHANGED: partition=1 start=63 old: size=20964762 end=20964825 new: size=62910477,end=62910540
五、 重启
reboot
六、 安装了上述工具后,重启不能使用客户端工具进行ssh,修改配置文件
vim /etc/ssh/sshd_config
修改第66行 PasswordAthentication yes
七、 对文件系统扩容
[ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 9.8G 23M 9.2G 1% /mount1
[ ~]# resize2fs /dev/sdb1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/sdb1 is mounted on /mount1; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/sdb1 to 7863809 (4k) blocks.
The filesystem on /dev/sdb1 is now 7863809 blocks long.
[ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 30G 28M 28G 1% /mount1