标签:需要 only 没有 打印 decide tab ges 规划 command
根据目前我们使用的需求,以前规划的100G磁盘空间不够,这里将演示XFS文件系统的扩容,因为我使用的是KVM所以也会演示KVM的扩容方式。
扩容前一定要先备份,或者做快照,不要造成数据的损坏。
[root@vm-node-1 img]# qemu-img info c7_data_g2.raw #<--查看原磁盘信息
image: c7_data_g2.raw
file format: raw
virtual size: 100G (107374182400 bytes)
disk size: 100G
[root@vm-node-1 img]# qemu-img resize c7_data_g2.raw +200G #<--增加200G
Image resized.
[root@vm-node-1 img]# qemu-img info c7_data_g2.raw
image: c7_data_g2.raw
file format: raw
virtual size: 300G (322122547200 bytes) #<--增加成功
disk size: 100G
修改完成,需要重启KVM虚拟机生效
[root@vm-node-1 ~]# virsh shutdown kvm-node-1
域 kvm-node-1 被关闭
[root@dsd ~]# virsh start kvm-node-1
域 kvm-node-1 已开始
第一步: 摘下磁盘
[root@kvm-node-1 ~]# umount /data
[root@kvm-node-1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 253:0 0 40G 0 disk
└─vda1 253:1 0 40G 0 part /
vdb 253:16 0 300G 0 disk
└─vdb1 253:17 0 100G 0 part
第二步:调整分区表大小
调整分区表大小不会真正去修改数据,类似于重新修订书籍的目录; 注意起始位置要一致,我这里用默认即可;默认是2048开始,所以我直接回车就行
[root@kvm-node-1 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p #<-- 打印分区信息
Disk /dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x60f8f320
Device Boot Start End Blocks Id System
/dev/vdb1 2048 209715199 104856576 83 Linux
Command (m for help): d #<-- 删除分区
Selected partition 1
Partition 1 is deleted
Command (m for help): n #<-- 创建分区, 剩下的基本就是一路回车了
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-629145599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599):
Using default value 629145599
Partition 1 of type Linux and of size 300 GiB is set
Command (m for help): wq #<-- 保存分区信息
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
第三步:在线扩容
[root@kvm-node-1 ~]# xfs_growfs /dev/vdb1
meta-data=/dev/vdb1 isize=512 agcount=4, agsize=6553536 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=26214144, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=12799, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 26214144 to 78642944
[root@kvm-node-1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 2.3G 38G 6% /
devtmpfs 12G 0 12G 0% /dev
tmpfs 12G 0 12G 0% /dev/shm
tmpfs 12G 8.5M 12G 1% /run
tmpfs 12G 0 12G 0% /sys/fs/cgroup
tmpfs 2.4G 0 2.4G 0% /run/user/0
/dev/vdb1 300G 100G 201G 34% /data
在测试发现,XFS文件系统如果没有挂载进行扩容,则会提示不是一个xfs文件系统。
标签:需要 only 没有 打印 decide tab ges 规划 command
原文地址:https://www.cnblogs.com/evan-blog/p/9842523.html