| title | categories | tags | abbrlink | date | updated | |||
|---|---|---|---|---|---|---|---|---|
| 中标麒麟-Linux系统扩容根目录磁盘空间 |
|
| 6db4 | 2021-11-22 15:21:15 -0800 | 2021-11-22 15:21:15 -0800 |
### df -h 查看 [root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 167M 1.7G 9% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/mapper/nlas-root 50G 6.2G 44G 13% / /dev/mapper/nlas-home 66G 2.4G 63G 4% /home /dev/sda1 1014M 189M 826M 19% /boot tmpfs 839M 0 839M 0% /run/user/0
在使用一段时间后,空间不足、文件不能上存,再次 df -h 查看
在虚拟机添加磁盘空间(略)后,通过 fdisk 开始进行分区进入:
[root@localhost ~]# fdisk /dev/sda 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 命令(输入 m 获取帮助):m 命令操作 a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
命令(输入 m 获取帮助): n #new 新分区
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): p #选择主分区
Selected partition 3 #分区序号
起始 扇区 (251658240-13631448799,默认为 251658240): #分区开始回车默认
将使用默认值 251658240
Last 扇区, +扇区 or +size{K,M,G} (251658240-13631448799,默认为 13631448799):
将使用默认值 13631448799
5. 重启Linux操作系统,使用 reboot 命令
6. 创建物理卷,使用 pvcreate /dev/sda3 命令
7. 将添加新的物理卷,加载到centos卷组,使用 vgextend 命令
8. 增加 /dev/mapper/nlas-root 大小,使用 lvresize -L +500G /dev/mapper/nlas-root 命令
中标麒麟的root是在 /dev/mapper/nlas-root
Last login: Sat Nov 20 01:59:18 on ttys000 [root@localhost ~]# vgdisplay --- Volume group --- VG Name nlas System ID Format lvm2 metadata Areas 2 metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 2 Act PV 2 VG Size 648.99 GiB PE Size 4.00 MiB Total PE 166142 Alloc PE / Size 30462 / 118.99 GiB Free PE / Size 135680 / 530.00 GiB VG UUID Ac7YMK-JWY0-2q9Y-9pun-iU9i-Wsdv-KLEkMR ### 测试大小,超出会显示错误 [root@localhost ~]# lvresize -L +600G /dev/mapper/nlas-root Insufficient free space: 153600 extents needed, but only 135680 available ### 正式的 [root@localhost ~]# lvresize -L +530G /dev/mapper/nlas-root Size of logical volume nlas/root changed from 50.00 GiB (12800 extents) to 580.00 GiB (148480 extents). Logical volume nlas/root successfully resized. [root@localhost ~]# resize2fs /dev/nlas/root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block 当尝试打开 /dev/nlas/root 时 找不到有效的文件系统超级块.9. 同步文件系统
[root@localhost ~]# xfs_growfs /dev/mapper/nlas-root
meta-data=/dev/mapper/nlas-root isize=512 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 152043520
10. 查看扩容后的大小 ,使用 df -h 命令
[root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 devtmpfs 4.1G 0 4.1G 0% /dev tmpfs 4.1G 4.0K 4.1G 1% /dev/shm tmpfs 4.1G 11M 4.1G 1% /run tmpfs 4.1G 0 4.1G 0% /sys/fs/cgroup /dev/mapper/nlas-root 580G 50G 531G 9% / /dev/sda1 1014M 189M 826M 19% /boot /dev/mapper/nlas-home 66G 38G 28G 58% /home tmpfs 839M 0 839M 0% /run/user/0



