[英]How to resize root partition online , on xfs filesystem?
當我嘗試擴展根分區時,使用以下方法
[root@oel7 ~]# resize2fs /dev/root_vg/root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/root_vg/root
Couldn't find valid filesystem superblock.
我無法對上述最后一行錯誤執行相同操作。
您正在使用 XFS 文件系統,在這種情況下,您需要使用 xfs_growfs 而不是 resize2fs。 執行此任務需要兩個命令:
# growpart /dev/sda 1
growpart 用於將 sda1 分區擴展到整個 sda 磁盤。
# xfs_growfs -d /dev/sda1
xfs_growfs 用於調整大小和應用更改。
# df -h
注意:您可以查看此腳本: https : //gist.github.com/OmarTrigui/7d6ec92c8f2ef83ba15b80e30fb6a5be
Environment :
[root@oel7 ~]# uname -a
Linux oel7.localdomain 3.8.13-55.1.6.el7uek.x86_64 #2 SMP Wed Feb 11 14:18:22 PST 2015 x86_64 x86_64 x86_64 GNU/Linux
Steps :
1) [root@oel7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/root_vg-root 5.0G 4.5G 548M 90% /
2)
PV /dev/sda2 VG root_vg lvm2 [6.00 GiB / 0 free]
as here it shows that there is no space left on root_vg volume group, so first i need to extend VG
3) [root@oel7 ~]# vgextend root_vg /dev/sdb5
Volume group "root_vg" successfully extended
4) [root@oel7 ~]# pvscan
PV /dev/sda2 VG root_vg lvm2 [6.00 GiB / 0 free]
PV /dev/sdb5 VG root_vg lvm2 [2.00 GiB / 2.00 GiB free]
5) Now extend the logical volume
[root@oel7 ~]# lvextend -L +1G /dev/root_vg/root
Size of logical volume root_vg/root changed from 5.00 GiB (1280 extents) to 6.00 GiB (1536 extents).
Logical volume root successfully resized
6) [root@oel7 ~]# resize2fs /dev/root_vg/root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/root_vg/root
Couldn't find valid filesystem superblock.
as root partition is not a ext* partiton so , you resize2fs will not work for you.
7) to check the filesystem type of a partition
[root@oel7 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/root_vg-root xfs 6.0G 4.5G 1.6G 75% /
devtmpfs devtmpfs 481M 0 481M 0% /dev
tmpfs tmpfs 491M 80K 491M 1% /dev/shm
tmpfs tmpfs 491M 7.1M 484M 2% /run
tmpfs tmpfs 491M 0 491M 0% /sys/fs/cgroup
/dev/mapper/data_vg-home xfs 3.5G 2.9G 620M 83% /home
/dev/sda1 xfs 497M 132M 365M 27% /boot
/dev/mapper/data_vg01-data_lv001 ext3 4.0G 2.4G 1.5G 62% /sybase
/dev/mapper/data_vg02-backup_lv01 ext3 4.0G 806M 3.0G 22% /backup
above command shows that root is an xfs filesystem , so we are sure that we need to use xfs_growfs command to resize the partition.
8) [root@oel7 ~]# xfs_growfs /dev/root_vg/root
meta-data=/dev/mapper/root_vg-root isize=256 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=1310720, 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 1310720 to 1572864
[root@oel7 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/root_vg-root xfs 6.0G 4.5G 1.6G 75% /
恭喜您的根分區在線擴展成功。
HTH
centos7 不支持 resize2fs 和 xfs,所以你可以使用 xfs_growfs
樓下注解:只是不支持xfs格式
234 fdisk /dev/sda
235 reboot
236 fdisk /dev/sda
237 pvcreate /dev/sda3
238 reboot
239 pvcreate /dev/sda3
240 vgdisplay
241 vgextend centos /dev/sda3
242 vgdisplay
243 lvextend -L +32768 /dev/mapper/centos-root
244 resize2fs /dev/mapper/centos-root
245 xfs_growfs /dev/mapper/centos-root
246 df -h
247 vgdisplay
248 lvextend -L +32768 /dev/mapper/centos-root
249 xfs_growfs /dev/mapper/centos-root
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.