调整大小错误:ext2fs_open2:超级块中的魔法数字错误

调整大小错误:ext2fs_open2:超级块中的魔法数字错误
  1. 我有一台服务器 server1,运行 8GB 根分区

  2. 我已经获取了此 server1 的 ami 并创建了另一个 server2,但将根分区更改为 60GB

3.我想扩展server2中的linux分区,并按照以下链接操作: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/storage_expand_partition.html 但它失败了。请告诉我我错过了什么?/dev/xvdf 是附加到另一个实例以调整大小的根分区。

root@ip-172-31-254-234:~# fdisk -l

Disk /dev/xvda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 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 identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/xvda1 * 16065 16771859 8377897 83 Linux+

Disk /dev/xvdf: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders, total 125829120 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 identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/xvdf1 * 16065 16771859 8377897 83 Linux+
root@ip-172-31-254-234:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 8G 0 disk
ââxvda1 202:1 0 8G 0 part /
xvdf 202:80 0 60G 0 disk
ââxvdf1 202:81 0 8G 0 part
root@ip-172-31-254-234:~# parted /dev/xvdf
xvdf xvdf1
root@ip-172-31-254-234:~# parted /dev/xvdf
GNU Parted 2.3
Using /dev/xvdf
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
(parted)
(parted)
(parted) print
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdf: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 8225kB 8587MB 8579MB primary ext4 boot

(parted) unit s
(parted)
(parted)
(parted) print
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdf: 125829120s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 16065s 16771859s 16755795s primary ext4 boot

(parted) rm 1
Warning: Partition /dev/xvdf1 is being used. Are you sure you want to continue?
Yes/No? yes
(parted)
(parted)
(parted) print
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdf: 125829120s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags

(parted) mkpart primary 2048s 100%
(parted) print
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdf: 125829120s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 2048s 125829119s 125827072s primary

(parted) set 1 boot on
(parted) print
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdf: 125829120s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 2048s 125829119s 125827072s primary boot

(parted) quit
Information: You may need to update /etc/fstab.

root@ip-172-31-254-234:~# sudo e2fsck -f /dev/xvdf1
e2fsck 1.42.9 (4-Feb-2014)
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/xvdf1

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
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 <device>
or
e2fsck -b 32768 <device>

答案1

前:

Number Start End Size Type File system Flags
1 16065s 16771859s 16755795s primary ext4 boot
  ^^^^^^

后:

Number Start End Size Type File system Flags
1 2048s 125829119s 125827072s primary boot
  ^^^^^

不,这样不行。

(第一个) 超级块存储在与分区起始点相距固定偏移的位置。您不能随意更改磁盘上的起始点,因为e2fsck这样会在错误的位置查找超级块... 并找不到它。

从您引用的链接:

注意上面分区 1 的起点和分区类型。

mkpart使用主分区类型、分区 1 的起点和 100%运行该命令以使用所有可用空间。

2048s示例中的值是例子值(我认为这就是为什么它显示为红色)。

假设您到目前为止还没有对文件系统造成任何损坏,您应该能够删除分区定义并将其放回正确的起点,然后e2fsck就可以工作了。

我还假设,这parted是使用一些启发式方法来显示文件系统类型。事实上,您移动了分区的开头,这大概也导致了ext4列表输出中消失,这可能是您第一次收到警告,表明有些事情不对劲。

相关内容