linux fix superblock not found

* Mistakes by Linux/UNIX Sys admin
* Buggy device driver or utilities (especially third party utilities)
* Power outage (very rarer on production system) due to UPS failure
* Kernel bugs (that is why you don’t run latest kernel on production Linux/UNIX system, most of time you need to use stable kernel release)

    Due to filesystem failure:

    • File system will refuse to mount
    • Entire system get hangs
    • Even if filesystem mount operation result into success, users may notice strange behavior when mounted such as system reboot, gibberish characters in directory listings etc

    So how the hell you are gonna Surviving a Filesystem Failures? Most of time fsck (front end to ext2/ext3 utility) can fix the problem, first simply run e2fsck – to check a Linux ext2/ext3 file system (assuming /home [/dev/sda3 partition] filesystem for demo purpose), first unmount /dev/sda3 then type following command :
    # e2fsck -f /dev/sda3
    Where,

    • -f : Force checking even if the file system seems clean.

    Please note that If the superblock is not found, e2fsck will terminate with a fatal error. However Linux maintains multiple redundant copies of the superblock in every file system, so you can use -b {alternative-superblock} option to get rid of this problem. The location of the backup superblock is dependent on the filesystem’s blocksize:

    • For filesystems with 1k blocksizes, a backup superblock can be found at block 8193
    • For filesystems with 2k blocksizes, at block 16384
    • For 4k blocksizes, at block 32768.

    Tip you can also try any one of the following command(s) to determine alternative-superblock locations:
    # mke2fs -n /dev/sda3
    OR
    # dumpe2fs /dev/sda3|grep -i superblock
    To repair file system by alternative-superblock use command as follows:
    # e2fsck -f -b 8193 /dev/sda3

    However it is highly recommended that you make backup before you run fsck command on system, use dd command to create a backup (provided that you have spare space under /disk2)
    # dd if=/dev/sda2 of=/disk2/backup-sda2.img

    If you are using Sun Solaris UNIX, see howto: Restoring a Bad Superblock.

    Please note that things started to get complicated if hard disk participates in software RAID array. Take a look at Software-RAID HOWTO – Error Recovery. This article/tip is part of Understanding UNIX/Linux file system series, Continue reading rest of the Understanding Linux file system series (this is part III):

    ### fsck 命令的用法与问题解决 `fsck` 是文件系统一致性检查和修复工具,主要用于 Linux 和类 Unix 系统中的磁盘维护。它能够扫描文件系统的错误并尝试自动修复这些问题。以下是关于 `fsck` 的详细介绍及其常见问题的解决方法。 #### 1. fsck 的基本功能 `fsck` 可用于以下几种主要目的: - 检查文件系统的完整性。 - 找出损坏的节点或丢失的链接。 - 尝试恢复不可读取的数据块。 - 清理不必要的临时文件或其他垃圾数据[^5]。 #### 2. 使用语法 通用格式如下所示: ```bash fsck [-t fstype] [options] device_name ``` 其中, - `-t fstype`: 指定要检查的文件系统类型(如 ext4, xfs)。 - `[options]`: 自定义选项参数列表。 - `device_name`: 待检测的目标存储介质路径名(比如 `/dev/sda1` 表示第一个分区)。 一些常用的附加标志包括但不限于: - `-a` : 对所有发现的问题都采用默认响应动作来修正它们; - `-r` : 请求用户确认每一个单独的操作之前先询问是否继续; - `-n` / `-y` :模拟模式下只报告而不做任何更改;或者强制回答 yes 至每一步骤提问从而加快进程速度[^6]。 ##### 示例一:常规全盘扫描 假设我们需要对根目录所在的硬盘进行全面分析,则可执行下面这条语句: ```bash sudo fsck -f / ``` ##### 示例二:针对特定类型的文件系统进行深入探查 如果知道具体使用的文件系统类别为 EXT3/EXT4 ,那么可以直接声明出来以提高效率: ```bash sudo fsck.ext4 -C0 -p /dev/hdb7 ``` 这里增加了两个新标记解释一下: - `-C fd` : 输出进度条信息到指定描述符fd,默认值为标准输出流(即屏幕显示)。 - `-p` : 自动修补那些可以被安全处理的小毛病而无需人工干预[^7]。 #### 3. 解决常见的 fsck 错误消息 当运行 `fsck` 时可能会碰到各种报错情况,下面列举几个典型例子以及对应的处置办法: | Error Message | Solution | |------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | **The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem** | Try specifying different block sizes with option '-b' until successful identification occurs; Alternatively try recovery mode via live CD/DVD image | | **Filesystem mounted or open readonly** | Unmount the affected partition first before performing any checks (`umount`) | | **Inode bitmap differences between backup copy and current inode table contents found during pass 3 of e2fsck** | Let program fix itself unless there's reason to believe otherwise based on prior knowledge about system state at time corruption occurred | 以上表格列出了部分可能出现的状况连同推荐解决方案概述[^8]。 --- ### 注意事项 为了保障操作过程顺利无误,请注意以下几点建议: - 总是在非活动状态下实施此类深层次检验工作,也就是确保目标卷已被卸载(unmounted),否则可能导致进一步损害风险增加。 - 如果不确定如何解读某些复杂的技术术语含义的话,最好查阅官方手册页(`man fsck`)获取权威指导说明文档内容。 - 利用备份副本作为参照依据可以帮助减少因误判而导致的重大损失可能性。 ---
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值