在 Ubuntu 18..04 中恢复带有加密 /home 目录的分区

在 Ubuntu 18..04 中恢复带有加密 /home 目录的分区

我的台式电脑上有大约 5 个分区,我现在使用的分区是 18.04,带有加密 /home 目录的分区比较旧。里面有一些重要的文件和数据,所以如果可以恢复的话,我会花时间去做。所以我做的第一件事就是检查里面有哪些分区:

$ sudo fdisk -l
Disk /dev/loop0: 3.7 MiB, 3887104 bytes, 7592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 42.1 MiB, 44183552 bytes, 86296 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 2.3 MiB, 2355200 bytes, 4600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop3: 14.5 MiB, 15204352 bytes, 29696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop4: 13 MiB, 13619200 bytes, 26600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop5: 2.3 MiB, 2433024 bytes, 4752 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop6: 3.7 MiB, 3878912 bytes, 7576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop7: 14.5 MiB, 15196160 bytes, 29680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes




Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x0004f908

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1            2048   62500863   62498816  29.8G 82 Linux swap / Solaris
/dev/sda2        62502910  160157695   97654786  46.6G  5 Extended
/dev/sda3  *    160157696 1953523711 1793366016 855.1G 83 Linux
/dev/sda5        62502912  117922805   55419894  26.4G 83 Linux
/dev/sda6       117923840  160157695   42233856  20.1G 83 Linux

Partition 2 does not start on physical sector boundary.
Partition table entries are not in disk order.

因此安装分区并查看其中的内容,这是我得到的:

dominic@domscomputer:/mnt/recover$ cd /mnt/recover/home
dominic@domscomputer:/mnt/recover/home$ ls -l
total 28
drwxrwxrwx 19    1005    1005 4096 Apr 23  2017 decodify
drwxrwxrwx  3 dominic dominic 4096 Apr 23  2017 horse
drwxrwxrwx  5    1009    1009 4096 Apr 30  2017 horsebox
drwxrwxrwx  2    1008    1008 4096 Apr 29  2017 jimbob
drwxrwxrwx  2    1007    1007 4096 Apr 29  2017 johnjoe
drwxrwxrwx  2    1006    1006 4096 Apr  8  2017 new_user
drwxrwxrwx  2    1004    1004 4096 Feb 17  2017 sammy
dominic@domscomputer:/mnt/recover/home$ cd /mnt/recover/home/horse
dominic@domscomputer:/mnt/recover/home/horse$ ls -l
total 0
lrwxrwxrwx 1 dominic dominic 56 Feb 10  2017 Access-Your-Private-Data.desktop -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop
lrwxrwxrwx 1 dominic dominic 52 Feb 10  2017 README.txt -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt

文件系统的其余部分中还有很多文件,它们有用吗?

编辑:由于我没有密码,所以它不起作用:

/mnt/恢复/家/马$ sudo ecryptfs-recover-private -rw /media/sda3/home/.ecryptfs/horse/.Private
信息:搜索加密的私人目录(这可能需要一段时间)...
信息:找到 [/mnt/recover/home/.ecryptfs/horse/.Private]。
尝试恢复此目录?[Y/n]:y
信息:找到您的包装密码
您知道您的登录密码吗?[Y/n] n
信息:要恢复此目录,您必须拥有原始的 MOUNT 密码。
信息:当你首次设置加密的私人目录时,系统会要求你记录
信息:您的 MOUNT 密码。
信息:长度应为 32 个字符,由 [0-9] 和 [af] 组成。

输入您的 MOUNT 密码:
mount:/tmp/ecryptfs.5GDXtbtp:mount(2)系统调用失败:没有此文件或目录。
错误:无法在 [/tmp/ecryptfs.5GDXtbtp] 挂载私人数据。

答案1

您没有使用-a标志,ls所以它没有列出任何隐藏文件,但 ecryptfs-recover-private 程序在文件夹中找到至少一个home/.ecryptfs/horse(它包含所有用户的加密数据,home/horse只是一个挂载点)。

您绝对可以备份整个主目录并稍后再试,但无论如何,您肯定需要登录密码或挂载密码来解密数据。

您的所有用户数据应该在您的用户主目录中,但 /etc 中通常有一些可能有用的配置文件(/etc/fstab?)。

相关内容