解密旧主分区中丢失的数据

解密旧主分区中丢失的数据

我昨天决定从 16.04 升级到 GNOME(Ubuntu) 17.04。我按照说明使用 live-usb,但当我尝试重新启动时,却没有成功。所以我重复了两次安装,直到成功。

我现在有一个 Ubuntu-Gnome 17.04 工作系统。但是旧安装的主文件夹数据已被加密。我忘记了这个事实。

我得到:

$ sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
sda             931.5G                                                
├─sda1   vfat     479M /boot/efi                                      
├─sda2   ext4   186.3G /                                              
├─sda3   swap     3.7G                                                
│ └─cryptswap1 │        swap     3.7G [SWAP]                          
└─sda4   ext4   741.1G
/media/gnsibab/be2da67b-d6ac-4b75-a94e-34ad4d62c040  sr0             
1024M

我想打开sda4我的旧/home分区。但是我没有保存密码。我只有我的旧登录名sirah18(而gnsibab是我的新登录名)和我的旧登录密码oldpass我怎样才能恢复分区里的数据sda4(注意:sda4大小大于sda2。)请将我视为新手,因为我已经有 4 年没有使用 Ubuntu 了。

我试过:

$ cryptfs-unwrap-passphrase wrapped-passphrase
Error: Unwrapping passphrase failed [-2]

$ cat /etc/fstab
UUID=462b7284-7533-47e9-9c38-8d6c775d73ef /               ext4   errors=remount-ro  0       1
UUID=6675-4A8A                            /boot/efi       vfat    umask=0077        0       1
UUID=25592dd8-52fb-49e4-a376-9f5693f3c15e none            swap    sw                0       0
/dev/mapper/cryptswap1 none swap sw 0 0

最后,我现在再次使用上次安装时加密的主文件夹,但现在我已经保存了密码。

更新:我找到了密码 - 毕竟它已保存在 USB 驱动器中。就像斯蒂芬告诉我的那样:

gksudo gedit /etc/fstab  added: UUID=be2da67b-d6ac-4b75-a94e-34ad4d62c040 /home ext4 defaults 0 2
sudo cp -rp /home/.ecryptfs/gnsibab/ /media/gnsibab/be2da67b-d6ac-4b75-a94e-34ad4d62c040/.ecryptf‌​s/
sudo cp -rp /home/gnsibab/ /media/gnsibab/be2da67b-d6ac-4b75-a94e-34ad4d62c040/

重启成功

$ sudo mount -t ecryptfs /home/sirah18/.Private /home/sirah18/Private 
Passphrase:  
Select cipher:   
 1) aes: blocksize = 16; min keysize = 16; max keysize = 32
 2) blowfish: blocksize = 8; min keysize = 16; max keysize = 56
 3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24
 4) twofish: blocksize = 16; min keysize = 16; max keysize = 32
 5) cast6: blocksize = 16; min keysize = 16; max keysize = 32
 6) cast5: blocksize = 8; min keysize = 5; max keysize = 16
Selection [aes]: 1
Select key bytes:
 1) 16
 2) 32
 3) 24
Selection [16]: 1
Enable plaintext passthrough (y/n) [n]: n
Enable filename encryption (y/n) [n]: y
Filename Encryption Key (FNEK) Signature [0ebecd7fc86a9814]: 65b9422c4ecc5e53
Attempting to mount with the following options:
  ecryptfs_unlink_sigs
  ecryptfs_fnek_sig=65b9422c4ecc5e53
  ecryptfs_key_bytes=16
  ecryptfs_cipher=aes
  ecryptfs_sig=0ebecd7fc86a9814
Mounted eCryptfs

但私人文件夹是空的。我得到:

$ sudo ecryptfs-recover-private sirah18
INFO: Searching for encrypted private directories (this might take a while)...
find: ‘/proc/2225/task/2225/net’: Invalid argument
find: ‘/proc/2225/net’: Invalid argument
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8AxPhJtAm2cepgCjSXk2vOU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8Zy5QlHf4bmjh-2o4On0tPU--’: No such file or directory
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8FgvJk0Y3CxCU7dhZ4KDdzk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8bEZdy915POoTqZ8yGDR6AE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8ZteXtq4cErCuYGVOLyfCq---’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8LnOginVw5O5lLjZFbWMRv---’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8QAYayz7xdRsJ7kEnx0Omrk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8N9zop1o89Leh8-14gGeClU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8K8duUb6ZTYolC6IFCaw.5E--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt88-zKowxY3laVs-z5oTuwxU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8NJPlguVA6BqEdb0sHjechk--’: No such file or directory  
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8.njQ3vaFHIAtU0TkxxIBVE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8nPvPzRW.O8utPRdP6jPvBU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt88g3l4RZv0rjefrdncnD5pk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8MtQHrXtUgpBqAjYNku1Ayk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8dXhM33s4of2rLM1KHDVYnU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8YbUBLndntDBQLuihssPAnk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8Wv65dwU9eS5V6D7iUQvDZ---’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8JPNjK9sKB8KY08MyeWXiQ---’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8XQ5dqqwxjeNrg6xFKonBIk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt863ci3CVYSS6CKD4SckaUPU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8VDk2q6hShlHb0TMVgESjRk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8LZi3nRP7FK3ktPwwZFTrAE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8o5mSmCZxs0s1KVwLlYy5KE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8iwywMPwdaxxnufaFGZFFFE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt83BzOMjBpqZKWVrJ.e5ID6E--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8-ajdK3Jfl.0X7Yy9rMx6UU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt80BtrLgbjRfDcvZLXG7C3jU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8IdpOfBXXqBAOtslTcVLxkU--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8vrBrypo.oO5UdHGZ407v2E--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8bK.efSVPf9cZDRbJt.nxQk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8RcAEdx73qHDtfX6wPkyrF---’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8ZppBlCuzOCWQPHb9XM4glk--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8OVaWQBoAa1tAwa2vHSYF9---’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8I4c0qMhAeR1ANSvQB3ZxEE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8H.r0FfzSkXUdCo1fi.GEwE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8uq47VRVFO45O4AlMPh1FbE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8GdQCq-RK16dxB4w6Pz-hfE--’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8W.VhhQOPVmtEzPsVlvJRj---’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8azLm8vZkWpoh8kKQTCih8---’: No such file or directory 
find: ‘/home/sirah18/Private/ECRYPTFS_FNEK_ENCRYPTED.FWac7O8cdBWxk-T5z6dTuO1YrK-tqJ-viXt8240D.plYihNtCcTJiUoghU--’: No such file or directory 
find: ‘/run/user/1000/gvfs’: Permission denied

答案1

这个问题已在评论中得到解决。以下是我们所做的总结:

将新的主文件夹复制到旧的主分区,并使 Ubuntu 在启动时自动挂载该分区

由于 OP 在上次安装时没有选择使用他以前的主分区sda4,因此需要进行修改/etc/fstab,以便在启动时自动安装此分区。但在执行此操作之前,我们必须将用户的当前主文件夹复制gnsibab到该分区。由于新的主目录也已加密,因此必须通过

$ ecryptfs-umount-private
$ cp -rp /home/.ecryptfs/gnsibab /$OLD_HOME_PARTITION/.ecryptfs
$ cp -rp /home/gnsibab/ /$OLD_HOME_PARTITION

其中 OLD_HOME_PARTITION 是 sda4 的挂载点。 是ecryptfs-umount-private为了防止文件在复制过程中被更改(有时会出现错误Sessions still open, not unmounting,在这种情况下,您应该退出图形会话并使用Ctrl+ Alt+F1登录文本控制台并在那里执行这些命令)。请注意,在 AskUbuntu 上的许多答案中,他们建议使用 rsync而不是 ,cp因为这样可以让您在复制过程中断时继续进行。

复制新的主文件夹后,我们添加了以下行

UUID=be2da67b-d6ac-4b75-a94e-34ad4d62c040 /home ext4 defaults 0 2

/etc/fstab,通过这样做,OP 能够在 下安装 sda4 后重新启动并作为 gnsibab 登录/home

恢复旧数据

为了访问旧用户的加密数据sirah18,我们使用

sudo ecryptfs-recover-private /home/sirah18/.Private

它检测wrapped-passphrase中的文件/home/sirah18/.ecryptfs,要求输入旧的登录密码,并使用它来解开挂载密码并将.Private文件夹挂载到中的目录中/tmp

相关内容