故障处理:磁盘扩容出错:e2fsck: Bad magic number in super-block while trying to open /dev/vdb1

摘要:
在网上找到的其他老铁的解决思路尝试可以解决,现在重新整理下供大家参考需要使用到parted分区工具,以下操作注意数据备份!!!完整的操作如下:[root@aliyunsrv~]#parted/dev/vdbGNUParted2.1Using/dev/vdbWelcometoGNUParted!            #找到了ext4格式的分区,起始扇区定位到2048,结束扇区是1048575999  Yes/No/Cancel?

按照阿里云官网教程对云服务器进行磁盘扩容,使用fdisk重新分区,最后使用e2fsck和resize2fs来完成文件系统层面的扩容

在执行“e2fsck -f /dev/vdb1”命令时报错,如果你的问题和下面的错误一样,可以接着往下看:

[root@aliyunsrv ~]# e2fsck -f /dev/vdb1 
e2fsck 1.41.12 (17-May-2010)
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/vdb1

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), thenthe superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

按照提示执行“e2fsck -b 8193/dev/vdb1”,并没有什么用

根据报错信息推测是该工具并没有找到super-block,也就是分区起始位置有问题

因为已经重新创建分区表,所以往前查看了命令记录发现,分区的起始位置在103处,

[root@aliyunsrv ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200bytes
255 heads, 63 sectors/track, 6527cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00078f9c
   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        6527    52426752   83Linux

Disk /dev/vdb: 536.9 GB, 536870912000bytes
2 heads, 10 sectors/track, 52428800cylinders
Units = cylinders of 20 * 512 = 10240bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x63c3e6e0
   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1             103    52428800   524286976   83  Linux        # 分区起始位置在103,很重要,需要确定

由此其实可以推测出阿里云的磁盘扩容最近可能出问题了,之前分区我写的必定是1,但是扩容后就变了,这个应该是导致这个问题的原因

提阿里云工单得到的结果是用testdisk进行数据恢复,显然这个不是我要的方法,这个只是分区表损坏,数据并没有丢,处理好分区表即可。

在网上找到的其他老铁的解决思路尝试可以解决,现在重新整理下供大家参考

需要使用到parted分区工具,以下操作注意数据备份!!!

1.使用parted工具读取磁盘分区表信息

# 我在阿里云控制台扩展的分区大小为1024GB

parted /dev/vdb

2.删除旧的错误分区表

# 在parted交互式分区工具中执行

(parted) rm 1

注意:分区表用parted工具删除后无法直接使用fdisk进行分区

3.使用parted工具恢复之前正常的分区表

# 在parted交互式分区工具中执行

(parted) unit s                                                           
(parted) rescue 103 1099GB

这里根据之前的分区起始位置确认是103扇区,由于parted工具默认启动、结束位置单位都是用容量单位即kB/MB/GB,所以需要通过unit s命令定义默认使用sectors定义起始扇区。

完整的操作如下:

[root@aliyunsrv ~]# parted /dev/vdb
GNU Parted 2.1Using /dev/vdb
Welcome to GNU Parted! Type 'help'to view a list of commands.
(parted) p                       # 打印分区表                                                              
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 1100GB                # 分区容量
Sector size (logical/physical): 512B/512B
Partition Table: msdos                # 分区表类型

Number  Start  End     Size    Type     File system  Flags
 15120B  1100GB  1099GB  primary      # 当前的分区表信息,是不可用的

(parted) rm 1                     # 删除1号分区(parted) unit s                    # 使用扇区号                                                          
(parted) rescue 1031099GB               # 恢复分区表                                            
Information: A ext4 primary partition was found at 2048s ->1048575999s.  Do you want to add it
to the partition table?            # 找到了ext4格式的分区,起始扇区定位到2048,结束扇区是1048575999(推测的,如有问题欢迎指正)  Yes/No/Cancel?y                # 是否要创建该分区表,也就是恢复旧的分区表                                                              
(parted) p                                                                                       
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2147483648s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End          Size         Type     File system  Flags
 12048s  1048575999s  1048573952s  primary  ext4    # 可以看到这个是正确的磁盘分区表

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

4.重新创建新的分区表

这里需要注意的是parted工具里END的值,由于磁盘的扇区数量不容易确定,可以使用容量来替代

[root@aliyunsrv ~]# parted /dev/vdb
GNU Parted 2.1Using /dev/vdb
Welcome to GNU Parted! Type 'help'to view a list of commands.
(parted) p                                                                
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 1100GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size   Type     File system  Flags
 11049kB  537GB  537GB  primary  ext4          # 重新打开后发现分区表的显示格式有变化,但并不影响,同时也可以看出来是以前的分区表(未扩容前)

(parted) rm 1                            # 删除旧的分区表(parted) p                                                  
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 1100GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags

(parted) unit s
(parted) mkpart primary ext4 20481099GB            # 创建新的分区表,注意要使用前文获取的扇区起始位置2048
(parted) p                                                                
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2147483648s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End          Size         Type     File system  Flags
 12048s  2146484223s  2146482176s  primary  ext4   # 新的分区表

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

此时新的分区表就创建成功了,需要注意:是使用的parted工具创建的分区表!!!

如果想使用fdisk进行分区,可以在fdisk中使用2048起始扇区进行测试,注意数据备份!!!

[root@aliyunsrv ~]# e2fsck -f /dev/vdb1 
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vdb1: 237246/32768000 files (75.3% non-contiguous), 112383325/131071744 blocks

可以正常执行检查文件系统的操作

[root@aliyunsrv ~]# resize2fs /dev/vdb1 
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vdb1 to 268310272(4k) blocks.
The filesystem on /dev/vdb1 is now 268310272 blocks long.

可以正常执行确认变更文件系统大小的操作,执行完即可挂在使用

最后使用工具检查分区表状态,供参考

[root@aliyunsrv ~]# parted /dev/vdb     
GNU Parted 2.1Using /dev/vdb
Welcome to GNU Parted! Type 'help'to view a list of commands.
(parted) p                                                                
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 1100GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1099GB  1099GB  primary  ext4

fdisk工具查看的信息

[root@aliyunsrv ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200bytes
255 heads, 63 sectors/track, 6527cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x00078f9c
   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        6527    52426752   83Linux

Disk /dev/vdb: 1099.5 GB, 1099511627776bytes
255 heads, 63 sectors/track, 133674cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x000ead8a
   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1      133613  1073241088   83  Linux

附上提供帮助老铁的文章链接:

https://bbs.aliyun.com/read/272957.html?pos=4

======= 完毕,呵呵呵呵 ========

免责声明:文章转载自《故障处理:磁盘扩容出错:e2fsck: Bad magic number in super-block while trying to open /dev/vdb1》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇【Mybatis-Plus学习笔记(八)】基本配置缩略图生成算法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

react webpack 环境配置

1. 默认已经安装了nodejs,并输入:npm init 根据提示输入内容并 创建 package.json 2. 创建项目 reactapp reactapp |--app |--components |--productBox.jsx |--main.jsx |--build |-...

Gitblit搭建及Git协作开发流程

1. 概述 目前主流的是git作为自己代码管理,但是采用github需要付费才能够使用,如果不付费,代码需要公开。创业团队及小型开发团队都有必要搭建自己的代码服务器,自己摸索需要一定的时间,会赶不及项目进度。在此作者把自己的经验作为文档写下来,方便互联网各位创业者参考,能很快的搭建自己所需要的代码服务器。 同时作者也把最基本的开发流程,代码提交,代码上传,...

阿里云服务器安全设置

1、开启云盾所有服务 2、通过防火墙策略限制对外扫描行为 请您根据您的服务器操作系统,下载对应的脚本运行,运行后您的防火墙策略会封禁对外发包的行为,确保您的主机不会再出现恶意发包的情况,为您进行后续数据备份操作提供足够的时间。 Window2003的批处理文件下载地址:http://oss.aliyuncs.com/aliyunecs/windows20...

linux下重新安装grub

介绍 本篇指南会告诉你如果不知什么缘故丢失了GRUB后如何用一张Arch安装光盘重装GRUB。 注意 在这篇指南,我将使用sda1作为我的根udev类型references。如果你使用0.7.1以前的安装光盘,你应该将udev references换成devfs references。如果不明白请参见Technical_Terms#Hard_Drives。...

Centos7增加磁盘空间并挂载目录(VMware)

1.前言 今天本机vmware在使用docker安装oracle11g时提示nospace空间不足,所以用这篇文章简介下虚拟机如何扩展硬盘并挂载 2.添加新硬盘 依次点击"虚拟机"->"设置" 3.查看磁盘信息 fdisk -l 可以看到有4个磁盘,/dev/sda磁盘有两个分区,/dev/sdb磁盘为我这次新增的,但并未分区...

Android x86 镜像分析之二

上一篇中我们分析了android的启动脚本之类的东西,在这一篇中我们将分析一下do_install 这个函数,由于这个脚本是包含在install.img文件中,我们先看一下这个包里有那些文件,在这里我以树的形式列出包含有那些文件: install# tree . ├── bin │   ├── cfdisk │   ├── dialog │   └── p...