Resize error : ext2fs_open2: Bad magic number in super-block

0
  1. I have a server server1 running 8GB root partition

  2. I have taken the ami of this server1 and created anothe server2 but changed the root partition to 60GB

3.I wanted to extend the linux partition in the server2 and followed the below link: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/storage_expand_partition.html But It is failed. Please let me know what I had missed ? /dev/xvdf is the root partition attached to another instance for resize.

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>
amazon-web-services
diskmanagement
asked on Server Fault Mar 11, 2015 by user173141

1 Answer

0

Before:

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

After:

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

No, that's not going to work.

The (first) superblock is stored at a fixed offset from the start of the partition. You can't arbitrarily change where the start point is on the disk, because e2fsck is then going to look for the superblock in the wrong place... and fail to find it.

From the link you cited:

Note the start point and the partition type of partition 1 above.

Run the mkpart command with a primary partition type, the start point of partition 1, and 100% to use all of the available space.

The value 2048s in the example is an example value (which is why, I assume, it's shown in red).

Assuming you haven't done any damage to the filesystem up to this point, you should be able to remove the partition definition and put it back with the correct starting point, and then e2fsck should work.

I assume, also, that parted is using some heuristics to display the file system type. The fact that you moved the start of the partition also presumably caused ext4 to disappear from the list output, which was probably your first warning that something wasn't as it should be.

answered on Server Fault Mar 12, 2015 by Michael - sqlbot • edited Jun 11, 2020 by Community

User contributions licensed under CC BY-SA 3.0