在调整 Amazon AWS 上的 EBS 卷大小时,我意外删除了 ext4 签名。
root@server:~# fdisk /dev/xvdf
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-524287999, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-524287999, default 524287999):
Created a new partition 1 of type 'Linux' and of size 250 GiB.
Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: y
The signature will be removed by a write command.
Command (m for help): w
The partition table has been altered.
Syncing disks.
root@server:~#
root@server:~# resize2fs /dev/xvdf1
resize2fs 1.44.1 (24-Mar-2018)
resize2fs: Device or resource busy while trying to open /dev/xvdf1
Couldn't find valid filesystem superblock.
有没有办法恢复我的文件系统?
答案1
从备份恢复是最安全的选择,因为它是一个已知的过程。
迅速挽救数据会变得耗时、昂贵且有风险。备份损坏的卷,特别是当您重视数据并且没有其他副本时。
转储 ext4 详细信息并尝试使用备份超级块进行 fsck。无法恢复仍然是有可能的,但是如果可以找到的话,文件系统工具将会检查其结构。
对数据是否值得聘请恢复专业人员进行成本效益分析。(dumpe2fs 手册页中说是“文件系统向导”。)
就我个人而言,我更喜欢在未分区的磁盘上使用 LVM。仍然需要小心擦除文件系统,但不能通过 fdisk。