ECS Linux伺服器xfs磁碟擴容
ECS Linux伺服器xfs磁碟擴
ECS Linux伺服器xfs磁碟使用阿里雲官方提供的磁碟擴容方法擴容會有報錯:
[[email protected] ~]# e2fsck /dev/xvdb1
e2fsck 1.42.9 (28-Dec-2013)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/xvdb1
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
可以看到報錯是超級塊不可用。
超級塊不可用有兩種可能性:
1. 超級塊損壞,導致不可用。
2. 不同的檔案系統,使用ext檔案系統去檢查xfs的檔案系統,超級塊不能識別。
此處是由於第二中原因導致的,檢視分割槽的檔案系統的方法:
[[email protected] ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/xvda1 ext4 20510332 1660744 17784680 9% /
devtmpfs devtmpfs 934320 0 934320 0% /dev
tmpfs tmpfs 942004 0 942004 0% /dev/shm
tmpfs tmpfs 942004 8508 933496 1% /run
tmpfs tmpfs 942004 0 942004 0% /sys/fs/cgroup
/dev/xvdb1 xfs 10474496 33088 10441408 1% /mnt
可以看到/dev/xvdb1是xfs的檔案系統。
對xfs的檔案系統擴容方法如下:
1. 不需要解除安裝已經掛載的磁碟,否則擴容會報錯。
[[email protected] ~]# xfs_growfs /dev/xvdb1
xfs_growfs: /dev/xvdb1 is not a mounted XFS filesystem
2. 可以在分割槽掛載的情況擴容xfs的檔案系統:
[[email protected] ~]# xfs_growfs /dev/xvdb1
meta-data=/dev/xvdb1 isize=256 agcount=4, agsize=327616 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=1310464, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1310464 to 2621184
可以看到blocks 的數量從131046擴容到了2621184,實現了擴容。
擴容前/dev/xvdb1是5G的容量:
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 1.5G 18G 9% /
devtmpfs 913M 0 913M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.3M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/xvdb1 5.0G 33M 5.0G 1% /mnt
擴容後的/dev/xvdb1的容量為10G:
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 1.5G 18G 9% /
devtmpfs 913M 0 913M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.3M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/xvdb1 10G 33M 10G 1% /mnt