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

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

  1. [root@aliyunsrv ~]# e2fsck -f /dev/vdb1
  2. e2fsck 1.41. (-May-)
  3. e2fsck: Superblock invalid, trying backup blocks...
  4. e2fsck: Bad magic number in super-block while trying to open /dev/vdb1
  5.  
  6. The superblock could not be read or does not describe a correct ext2
  7. filesystem. If the device is valid and it really contains an ext2
  8. filesystem (and not swap or ufs or something else), then the superblock
  9. is corrupt, and you might try running e2fsck with an alternate superblock:
  10. e2fsck -b <device>

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

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

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

  1. [root@aliyunsrv ~]# fdisk -l
  2.  
  3. Disk /dev/vda: 53.7 GB, bytes
  4. heads, sectors/track, cylinders
  5. Units = cylinders of * = bytes
  6. Sector size (logical/physical): bytes / bytes
  7. I/O size (minimum/optimal): bytes / bytes
  8. Disk identifier: 0x00078f9c
  9.  
  10. Device Boot Start End Blocks Id System
  11. /dev/vda1 * Linux
  12.  
  13. Disk /dev/vdb: 536.9 GB, bytes
  14. heads, sectors/track, cylinders
  15. Units = cylinders of * = bytes
  16. Sector size (logical/physical): bytes / bytes
  17. I/O size (minimum/optimal): bytes / bytes
  18. Disk identifier: 0x63c3e6e0
  19.  
  20. Device Boot Start End Blocks Id System
  21. /dev/vdb1 Linux        # 分区起始位置在103,很重要,需要确定

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

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

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

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

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

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

  1. parted /dev/vdb

2.删除旧的错误分区表

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

  1. (parted) rm

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

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

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

  1. (parted) unit s
  2. (parted) rescue 1099GB

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

完整的操作如下:

  1. [root@aliyunsrv ~]# parted /dev/vdb
  2. GNU Parted 2.1
  3. Using /dev/vdb
  4. Welcome to GNU Parted! Type 'help' to view a list of commands.
  5. (parted) p                       # 打印分区表
  6. Model: Virtio Block Device (virtblk)
  7. Disk /dev/vdb: 1100GB                # 分区容量
  8. Sector size (logical/physical): 512B/512B
  9. Partition Table: msdos                # 分区表类型
  10.  
  11. Number Start End Size Type File system Flags
  12. 5120B 1100GB 1099GB primary      # 当前的分区表信息,是不可用的
  13.  
  14. (parted) rm 1                     # 删除1号分区
  15. (parted) unit s                    # 使用扇区号
  16. (parted) rescue 1099GB             # 恢复分区表
  17. Information: A ext4 primary partition was found at 2048s -> 1048575999s. Do you want to add it
  18. to the partition table?            # 找到了ext4格式的分区,起始扇区定位到2048,结束扇区是1048575999(推测的,如有问题欢迎指正)  
  19. Yes/No/Cancel? y                # 是否要创建该分区表,也就是恢复旧的分区表    
  20. (parted) p                       
  21. Model: Virtio Block Device (virtblk)
  22. Disk /dev/vdb: 2147483648s
  23. Sector size (logical/physical): 512B/512B
  24. Partition Table: msdos
  25.  
  26. Number Start End Size Type File system Flags
  27. 2048s 1048575999s 1048573952s primary ext4    # 可以看到这个是正确的磁盘分区表
  28.  
  29. (parted) q
  30. Information: You may need to update /etc/fstab.

4.重新创建新的分区表

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

  1. [root@aliyunsrv ~]# parted /dev/vdb
  2. GNU Parted 2.1
  3. Using /dev/vdb
  4. Welcome to GNU Parted! Type 'help' to view a list of commands.
  5. (parted) p
  6. Model: Virtio Block Device (virtblk)
  7. Disk /dev/vdb: 1100GB
  8. Sector size (logical/physical): 512B/512B
  9. Partition Table: msdos
  10.  
  11. Number Start End Size Type File system Flags
  12. 1049kB 537GB 537GB primary ext4          # 重新打开后发现分区表的显示格式有变化,但并不影响,同时也可以看出来是以前的分区表(未扩容前)
  13.  
  14. (parted) rm 1                            # 删除旧的分区表
  15. (parted) p
  16. Model: Virtio Block Device (virtblk)
  17. Disk /dev/vdb: 1100GB
  18. Sector size (logical/physical): 512B/512B
  19. Partition Table: msdos
  20.  
  21. Number Start End Size Type File system Flags
  22.  
  23. (parted) unit s
  24. (parted) mkpart primary ext4 1099GB            # 创建新的分区表,注意要使用前文获取的扇区起始位置2048
  25. (parted) p
  26. Model: Virtio Block Device (virtblk)
  27. Disk /dev/vdb: 2147483648s
  28. Sector size (logical/physical): 512B/512B
  29. Partition Table: msdos
  30.  
  31. Number Start End Size Type File system Flags
  32. 2048s 2146484223s 2146482176s primary ext4   # 新的分区表
  33.  
  34. (parted) q
  35. Information: You may need to update /etc/fstab.

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

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

  1. [root@aliyunsrv ~]# e2fsck -f /dev/vdb1
  2. e2fsck 1.41. (-May-)
  3. Pass : Checking inodes, blocks, and sizes
  4. Pass : Checking directory structure
  5. Pass : Checking directory connectivity
  6. Pass : Checking reference counts
  7. Pass : Checking group summary information
  8. /dev/vdb1: / files (75.3% non-contiguous), / blocks

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

  1. [root@aliyunsrv ~]# resize2fs /dev/vdb1
  2. resize2fs 1.41. (-May-)
  3. Resizing the filesystem on /dev/vdb1 to (4k) blocks.
  4. The filesystem on /dev/vdb1 is now blocks long.

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

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

  1. [root@aliyunsrv ~]# parted /dev/vdb
  2. GNU Parted 2.1
  3. Using /dev/vdb
  4. Welcome to GNU Parted! Type 'help' to view a list of commands.
  5. (parted) p
  6. Model: Virtio Block Device (virtblk)
  7. Disk /dev/vdb: 1100GB
  8. Sector size (logical/physical): 512B/512B
  9. Partition Table: msdos
  10.  
  11. Number Start End Size Type File system Flags
  12. 1049kB 1099GB 1099GB primary ext4

fdisk工具查看的信息

  1. [root@aliyunsrv ~]# fdisk -l
  2.  
  3. Disk /dev/vda: 53.7 GB, bytes
  4. heads, sectors/track, cylinders
  5. Units = cylinders of * = bytes
  6. Sector size (logical/physical): bytes / bytes
  7. I/O size (minimum/optimal): bytes / bytes
  8. Disk identifier: 0x00078f9c
  9.  
  10. Device Boot Start End Blocks Id System
  11. /dev/vda1 * Linux
  12.  
  13. Disk /dev/vdb: 1099.5 GB, bytes
  14. heads, sectors/track, cylinders
  15. Units = cylinders of * = bytes
  16. Sector size (logical/physical): bytes / bytes
  17. I/O size (minimum/optimal): bytes / bytes
  18. Disk identifier: 0x000ead8a
  19.  
  20. Device Boot Start End Blocks Id System
  21. /dev/vdb1 Linux

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

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

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

故障处理:磁盘扩容出错:e2fsck: Bad magic number in super-block while trying to open /dev/vdb1的更多相关文章

  1. ECS Linux服务器xfs磁盘扩容

    ECS Linux服务器xfs磁盘扩 ECS Linux服务器xfs磁盘使用阿里云官方提供的磁盘扩容方法扩容会有报错: [root@iZ28u04wmy2Z ~]# e2fsck /dev/xvdb1 ...

  2. Windows下虚拟机Linux(CentOS8)扩容设置 - 磁盘扩容中的坑和解决方法

    摘要:[原创]转载请注明作者Johnthegreat和本文链接 由于虚拟机空间不足,为了避免重装虚拟机,做了一次无损扩容.   过程中的报错如下: [root@localhost ~]# pvcrea ...

  3. 【转载】CentOS LVM磁盘扩容

    转自:http://blog.sina.com.cn/s/blog_8882a6260101cpfs.html EXSI5.1主机有一个linux虚拟机,系统是centos运行httpd服务,因为是多 ...

  4. resize2fs: Bad magic number in super-block while trying to open /dev/centos/root Couldn't find valid filesystem superblock

    今天在进行lvm扩容之后,按照惯例进行 resize2fs 操作,发现报如下错误: # resize2fs /dev/centos/root resize2fs 1.42.9 (28-Dec-2013 ...

  5. Vmware Linux虚拟机磁盘扩容方法

    我的LINUX版本是ubuntu12.04 32bit.今天在下载android源代码的时候发现自己最初给这个虚拟机分配的磁盘空间不足了(只有20G).所以就需要给磁盘扩容.网上大致搜索了一下,主要有 ...

  6. linux 的 两种磁盘扩容

    当LVM分区空间不足的时候,可以进行扩容.主要的扩容方法有两种: 通过空余的磁盘进行扩容,这个方法比较简单,不会对原有数据有影响.将其他LVM分区空间取出一部分给需要扩容的LVM分区.下面就分别具体介 ...

  7. 幻数浅析(Magic Number)

    在源代码编写中,有这么一种情况:编码者在写源代码的时候,使用了一个数字,比如0x2123,0.021f等,他当时是明白这个数字的意思的,但是别的程序员看他的代码,可能很难理解,甚至,过了一段时间,代码 ...

  8. Vmware centos 虚拟机 磁盘扩容

    一,lvm ext4 扩容 1,首先关闭虚拟机,在vSphere Client 将硬盘大小增加或者新增一块硬盘 (从原来10G增加到50G) 2,开机 此时,df -hT只显示原来的磁盘大小 使用 f ...

  9. 阿里云ECS 实例Centos7系统磁盘扩容

    需求:一台阿里云的数据盘磁盘空间不足,需要扩容,我这里只有一个主分区,ext4文件系统. 因为磁盘扩容场景不同,阿里云的文档比较全面一些,所以先奉上阿里云的文档,下面开始我的操作步骤: 1.登录控制台 ...

随机推荐

  1. ng-深度学习-课程笔记-3: Python和向量化(Week2)

    1 向量化( Vectorization ) 在逻辑回归中,以计算z为例,$ z =  w^{T}+b $,你可以用for循环来实现. 但是在python中z可以调用numpy的方法,直接一句$z = ...

  2. springcloud14---zuul

    package com.itmuch.cloud.study; import org.springframework.boot.SpringApplication; import org.spring ...

  3. 【开源】检查更新程序 CheckUpdate.Net 的实现

    访问最新源代码及更新历史:http://git.oschina.net/xcong/CheckUpdate.Net DownLoad 更新历史 version 1.2 [新增]添加UpdateFile ...

  4. git使用多个SSH公钥信息

    常常在开发环境存在多个git库,比如官方的github.公司搭建的gitlab.自己的私人库等等多个git库,为了方便使用,git需要配置多个SSH公钥信息. 在centos7.5下,进入用户目录,以 ...

  5. linux第四章读书笔记

    第四章 进程调度 一.多任务 多任务操作系统就是能同时并发的交互执行多个进程的操作系统.多任务操作系统使多个进程处于堵塞或者睡眠状态,实际不被投入执行,这些任务尽管位于内存,但是并不处于可运行状态.多 ...

  6. 【eclipse】点Clean后没反应

    问题:点击Clean重新编译class后没反应 解决:

  7. poj3164最小树形图模板题

    题目大意:给定一个有向图,根节点已知,求该有向图的最小树形图.最小树形图即有向图的最小生成树,定义为:选择一些边,使得根节点能够到达图中所有的节点,并使得选出的边的边权和最小. 题目算法:朱-刘算法( ...

  8. python 字符串的反转

    def string_reverse(str1): rstr1 = '' index = len(str1) : rstr1 += str1[ index - ] index = index - re ...

  9. python 十进制数转二进制数

    def convertToBinary(n): """Function to print binary number for the input decimal usin ...

  10. CentOS6.4_x86_120g__20160306.rar

    安装的镜像包: CentOS-6.4-i386-bin-DVD1to2(CentOS-6.4-i386-bin-DVD1.iso / CentOS-6.4-i386-bin-DVD2.iso) 1. ...