我不小心删除了所有用户目录文件。有很多重要的文件和脚本我没有上传到GitHub。我已经吸取了教训,我必须进行备份。我在 Linux 生态系统中相对较新。任何帮助将不胜感激。我被困住了。 16小时——尝试不同的事情。
我通过数据恢复软件包生成了一个image.dd
文件。testdisk
问题:无法挂载此image.dd
btrfs 文件
所有步骤:
$ sudo file /home/image.dd
image.dd: BTRFS Filesystem sectorsize 4096, nodesize 16384, leafsize 16384, UUID=f3c3509c-fbe0-41d7-9af6-df1b3de1139c, 5435559936/103767080960 bytes used, 1 devices
image.dd
文件大小:
$ du -h /home/image.dd
90G /home/image.dd
注意:我没有足够的剩余空间。比如还剩 1 GB 之类的。
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 232.9G 0 disk
|-sda1 8:1 0 1G 0 part /boot
|-sda2 8:2 0 96.7G 0 part
| `-cryptlvm 254:0 0 96.6G 0 crypt /
|-sda3 8:3 0 68.4G 0 part /mnt/3
`-sda4 8:4 0 66.9G 0 part /mnt/4
sr0 11:0 1 1024M 0 rom
使用 losetup 设置块循环设备:
$ sudo losetup -f /home/image.dd
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 89G 0 loop
sda 8:0 0 232.9G 0 disk
|-sda1 8:1 0 1G 0 part /boot
|-sda2 8:2 0 96.7G 0 part
| `-cryptlvm 254:0 0 96.6G 0 crypt /
|-sda3 8:3 0 68.4G 0 part /mnt/3
`-sda4 8:4 0 66.9G 0 part /mnt/4
sr0 11:0 1 1024M 0 rom
安装块设备以评估内容并进行修改但出现错误:
$ sudo mount /dev/loop0 /mnt/backup
mount: /mnt/backup: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
dmesg(1) may have more information after failed mount system call.
注意:我还尝试了 kpartx 来创建块设备 - 但同样的按摩。
在这里,出现错误:
$ sudo btrfs check /dev/loop0
[1/7] checking root items
[2/7] checking extents
ERROR: block device size is smaller than total_bytes in device item, has 95611650048 expect >= 103767080960
ERROR: errors found in extent allocation tree or chunk allocation
[3/7] checking free space tree
[4/7] checking fs roots
[5/7] checking only csums items (without verifying data)
[6/7] checking root refs
[7/7] checking quota groups skipped (not enabled on this FS)
Opening filesystem to check...
Checking filesystem on /dev/loop0
UUID: f3c3509c-fbe0-41d7-9af6-df1b3de1139c
found 5435559936 bytes used, error(s) found
total csum bytes: 5179888
total tree bytes: 127172608
total fs tree bytes: 113983488
total extent tree bytes: 6193152
btree space waste bytes: 21944841
file data blocks allocated: 5312581632
referenced 5307400192
我尝试这个:
$ sudo mount -t btrfs -r -o /dev/loop0 /mnt/backup
mount: /mnt/backup: can't find in /etc/fstab.
$ cat /etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.
# <file system> <dir> <type> <options> <dump> <pass>
# /dev/mapper/creepy
UUID=4ecde757-fcb5-479c-bdea-a5d2cfa3d072 / btrfs rw,relatime,space_cache=v2,subvolid=5,subvol=/ 0 0
# /dev/sda1
UUID=4C90-DE53 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
通过执行此命令:
$ sudo testdisk /log /dev/loop0
这是 testdisk 生成的日志文件,其中包含一些额外的详细信息:
$ cat testdisk.log
Failed to set locale, using default 'C'.
Mon Jul 31 04:42:45 2023
Command line: TestDisk /log /dev/loop0
TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <[email protected]>
https://www.cgsecurity.org
OS: Linux, kernel 6.4.3-artix1-2 (#1 SMP PREEMPT_DYNAMIC Mon, 17 Jul 2023 15:17:04 +0000) x86_64
Compiler: GCC 12.2
ext2fs lib: 1.47.0, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.4
Hard disk list
Disk /dev/loop0 - 95 GB / 89 GiB - 186741504 sectors, sector size=512
Partition table type (auto): None
Disk /dev/loop0 - 95 GB / 89 GiB
Partition table type: None
Interface Advanced
P btrfs 0 186741503 186741504
btrfs blocksize=4096, 95 GB / 89 GiB
Change partition type:
P btrfs 0 186741503 186741504
btrfs blocksize=4096, 95 GB / 89 GiB
Interface Advanced
P btrfs 0 186741503 186741504
btrfs blocksize=4096, 95 GB / 89 GiB
New options :
Dump : No
Align partition: Yes
Expert mode : No
TestDisk exited normally.
```