resize2fs:尝试打开超级块时出现错误的幻数
我试图在CentOS7上调整逻辑卷的大小,但遇到以下错误:
resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock.
我已经尝试添加一个新的分区(使用fdisk),并使用vgextend扩展卷组,然后resize。 resize使用lvextend逻辑卷罚款,但它在resize2fs失败。
我也尝试删除一个现有的分区(使用fdisk)并重新创build一个更大的结束块,然后使用lvm pvresize调整物理卷的大小,然后使用lvm lvresize调整逻辑卷的大小。 再次,一切正常到这一点。
一旦我尝试使用resize2fs,使用上述两种方法,我收到了完全相同的错误。
希望下面的部分内容能够提供一些启示。
fdisk -l
[root@server~]# fdisk -l Disk /dev/xvda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x0009323a Device Boot Start End Blocks Id System /dev/xvda1 * 2048 1026047 512000 83 Linux /dev/xvda2 1026048 41943039 20458496 8e Linux LVM /dev/xvda3 41943040 62914559 10485760 8e Linux LVM Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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 /dev/mapper/centos-root: 29.5 GB, 29532094464 bytes, 57679872 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
pvdisplay将
[root@server ~]# pvdisplay --- Physical volume --- PV Name /dev/xvda2 VG Name centos PV Size 19.51 GiB / not usable 2.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 4994 Free PE 0 Allocated PE 4994 PV UUID 7bJOPh-OUK0-dGAs-2yqL-CAsV-TZeL-HfYzCt --- Physical volume --- PV Name /dev/xvda3 VG Name centos PV Size 10.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 2559 Free PE 0 Allocated PE 2559 PV UUID p0IClg-5mrh-5WlL-eJ1v-t6Tm-flVJ-gsJOK6
的vgdisplay
[root@server ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 29.50 GiB PE Size 4.00 MiB Total PE 7553 Alloc PE / Size 7553 / 29.50 GiB Free PE / Size 0 / 0 VG UUID FD7k1M-koJt-2veW-sizL-Srsq-Y6zt-GcCfz6
lvdisplay命令
[root@server ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID KyokrR-NGsp-6jVA-P92S-QE3X-hvdp-WAeACd LV Write Access read/write LV Creation host, time localhost, 2014-10-09 08:28:42 +0100 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID ugCOcT-sTDK-M8EV-3InM-hjIg-2nwS-KeAOnq LV Write Access read/write LV Creation host, time localhost, 2014-10-09 08:28:42 +0100 LV Status available # open 1 LV Size 27.50 GiB Current LE 7041 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1
我可能做了一些愚蠢的事情,所以任何帮助将不胜感激!
经过一些试验和错误…在可能的答案中提到,事实certificate需要xfs_growfs
而不是resize2fs
。
CentOS 7,
fdisk /dev/xvda
创build新的主分区,设置types为linux lvm
。
n p 3 t 8e w
创build一个新的主卷,并将卷组扩展到新卷。
partprobe pvcreate /dev/xvda3 vgextend /dev/centos /dev/xvda3
检查物理卷是否有空余空间,用可用空间扩展逻辑卷。
vgdisplay -v lvextend -l+288 /dev/centos/root
最后执行在线resize来调整逻辑卷的大小,然后检查可用空间。
xfs_growfs /dev/centos/root df -h
我在今天中午左右遇到了同样的问题,最后在这里find了一个解决scheme – > 尝试resize2fs EB卷失败
我跳过安装,因为分区已经安装。
显然,CentOS 7使用XFS作为默认的文件系统,结果resize2fs
将会失败。
我在/etc/fstab
看了一下,猜测是什么,XFS正在盯着我…希望这有助于。
在Centos 7中默认的文件系统是xfs 。
xfs文件系统只支持扩展不减less。 所以如果你想调整文件系统的大小,使用xfs_growfs而不是resize2fs。
xfs_growfs /dev/root_vg/root
注意:对于ext4文件系统使用
resize2fs /dev/root_vg/root
CentOS7 + VM
我做到了:
- Gparted-live扩展音量
-
pvresize -v /dev/sda2
-
lvresize -r -l+100%FREE centos/root
在Centos 7上,回答resize2fs以“坏幻数”失败的原始问题,尝试使用fsadm,如下所示:
fsadm resize /dev/the-device-name-returned-by-df
然后:
df
…确认尺寸更改已经工作。
How to resize root partition online : 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 3) [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. 4) 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. 6) [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% /