我已使用 AWS 控制台修改卷调整了 EBS 卷的大小。这是 lsblk 命令在任何更改之前返回的内容:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvdn 202:208 0 4G 0 disk
└─md0 9:0 0 16G 0 raid0 /mnt/data
xvdc 202:32 0 80G 0 disk
└─md1 9:1 0 160G 0 raid0 /mnt/temp
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdp 202:240 0 4G 0 disk
└─md0 9:0 0 16G 0 raid0 /mnt/data
xvdo 202:224 0 4G 0 disk
└─md0 9:0 0 16G 0 raid0 /mnt/data
xvdb 202:16 0 80G 0 disk
└─md1 9:1 0 160G 0 raid0 /mnt/temp
xvdq 202:4096 0 4G 0 disk
└─md0 9:0 0 16G 0 raid0 /mnt/data
我已将 xvdn(/dev/sdn) 的大小增加到 6G。之后我重新启动了实例。注意 xvdn 用于创建 4 个设备的 RAID 0 阵列。
$ sudo file -s /dev/xvd*
/dev/xvda: DOS/MBR boot sector; GRand Unified Bootloader, stage1 version 0x3, stage2 address 0x2000, 1st sector stage2 0x800, stage2 segment 0x200, GRUB version 0.94, extended partition table (last)
/dev/xvda1: Linux rev 1.0 ext4 filesystem data, UUID=1afa51d9-105a-4c14-8f32-8b8b424b1c81 (needs journal recovery) (extents) (large files) (huge files)
/dev/xvdb: Linux Software RAID version 1.2 (1) UUID=cbe5ee82:c33cad21:699bec71:b4cf4a63 name=dbx_head:head_ephem level=0 disks=2
/dev/xvdc: Linux Software RAID version 1.2 (1) UUID=cbe5ee82:c33cad21:699bec71:b4cf4a63 name=dbx_head:head_ephem level=0 disks=2
/dev/xvdn: Linux Software RAID version 1.2 (1) UUID=c42b27c0:3586d4c5:635e2925:39a006e5 name=dbx_head:head_ebs level=0 disks=4
/dev/xvdo: Linux Software RAID version 1.2 (1) UUID=c42b27c0:3586d4c5:635e2925:39a006e5 name=dbx_head:head_ebs level=0 disks=4
/dev/xvdp: Linux Software RAID version 1.2 (1) UUID=c42b27c0:3586d4c5:635e2925:39a006e5 name=dbx_head:head_ebs level=0 disks=4
/dev/xvdq: Linux Software RAID version 1.2 (1) UUID=c42b27c0:3586d4c5:635e2925:39a006e5 name=dbx_head:head_ebs level=0 disks=4
挂载的xfs
文件类型为:
$ mount
/dev/md0 on /mnt/data type xfs (rw,noatime,nodiratime,swalloc,attr2,largeio,inode64,logbsize=128k,sunit=256,swidth=1024,noquota)
/dev/md1 on /mnt/temp type xfs (rw,noatime,nodiratime,swalloc,attr2,largeio,inode64,sunit=256,swidth=512,noquota)
/dev/md0 on /xdlog type xfs (rw,noatime,nodiratime,swalloc,attr2,largeio,inode64,logbsize=128k,sunit=256,swidth=1024,noquota)
重新启动后,大小没有变化,所以我做了
$ xfs_growfs -d /dev/md0
meta-data=/dev/md0 isize=2048 agcount=17, agsize=262112 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4194176, imaxpct=25
= sunit=32 swidth=128 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=32 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data size unchanged, skipping
现在,lsblk
回报:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvdn 202:208 0 6G 0 disk
└─md0 9:0 0 16G 0 raid0 /mnt/data
xvdc 202:32 0 80G 0 disk
└─md1 9:1 0 160G 0 raid0 /mnt/temp
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdp 202:240 0 4G 0 disk
└─md0 9:0 0 16G 0 raid0 /mnt/data
xvdo 202:224 0 4G 0 disk
└─md0 9:0 0 16G 0 raid0 /mnt/data
xvdb 202:16 0 80G 0 disk
└─md1 9:1 0 160G 0 raid0 /mnt/temp
xvdq 202:4096 0 4G 0 disk
└─md0 9:0 0 16G 0 raid0 /mnt/data
但是当我通过文件大小时df -h
,它没有显示任何变化:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.4G 96K 7.4G 1% /dev
tmpfs 7.4G 55M 7.3G 1% /dev/shm
/dev/xvda1 7.8G 1.8G 6.0G 23% /
tmpfs 7.4G 24K 7.4G 1% /home/xdaux/tmp
tmpfs 7.4G 124K 7.4G 1% /home/xdcrm/tmp
/dev/md0 16G 35M 16G 1% /xdlog
/dev/md1 160G 3.1G 157G 2% /mnt/temp
我在这里做错了什么/遗漏了什么?
答案1
xvdn
是 RAID0 阵列 ( md0
) 的一部分,由文件系统使用。要扩展文件系统,您需要扩展md0
阵列,但这需要您扩展全部四个首先是组件设备。基本上:
- 拍摄 EBS 卷快照和/或其他备份。不是跳过此步骤!
- 调整大小全部四个设备
- 卸载文件系统(
umount /dev/md0
) - 停止数组 (
mdadm -S /dev/md0
) --update=devicesize
使用选项 (mdadm --assemble --update=devicesize /dev/md0 /dev/xvdn /dev/xvdp /dev/xvdo /dev/xvdq
)重新组装数组- 重新挂载文件系统(
mount /dev/md0 /xdlog
) - 扩大文件系统 (
xfs_growfs /dev/md0
)
请注意,我发布 bash 命令仅仅是为了方便,请三重检查在进行破坏性操作之前。