0

I've got two questions.

1) Can you install Ubuntu 16.10 with a preexisting encrypted /home partition?

2) What's the best way to back up an encrypted /home partition? Preferably to a second hard drive.

I am currently dual booting Windows 7 and Ubuntu 16.10 with an encrypted home folder using ecryptfs. I'm going upgrade my motherboard soon and will be installing a fresh copy of Windows 10, and I'd like to make it so I can keep all my settings from my current /home folder.

Historically I could install Ubuntu with an existing /home directory that mounts to it's own partition. This allowed me to update Ubuntu installations without having to lose all of my settings. Will this work if that folder is encrypted with ecryptfs? Or will I lose something in the OS install that will lock me out of my files? I have access to the ecryptfs passphrase and the ecryptfs-manager utility.

Windows installers also usually don't play well other operating system installs. If they don't wipe the entire drive they will at least remove the master boot record and I'll have to reinstall Ubuntu to recover access. Because of this I'd like to be able to backup my /home partition. I had planned on copying it with gparted, but I've run into problems with that confusing the computer because it thinks it has two partitions mounted to /home and my inability to mount the backup partition because of ecryptfs. Though the latter may just be my unfamiliarity with the software. I've also tried doing 'cp -r /home/myUsername/* ./backupLocation' but that wreaks havoc with the file owners and permissions. So I'd if there is a solution to backup the encrypted /home partition, so I can restore it to a new installation of Ubuntu in case Windows 10 wipes out the entire drive.

My primary drive currently looks like this:

  • /dev/sda1 - 200 GiB ntfs Windows 7 installation, to be replaced by Windows 10
  • /dev/sda2 - 190 MiB ext4 filesystem mounted as /boot
  • /dev/sda3 - 16 GiB ext4 filesystem mounted as /
  • /dev/sda4 - 15 GiB ext4 filesystem mounted as /home, the only part of the Ubuntu install I'd care about keeping

Secondary Drive:

  • /dev/sdb1 - 2.7 TiB nfts filesystem for datastorage
  • 17 GiB freespace, enough to fit the entire /home partition
0

Your home partition's currently using ecryptfs, or LUKS? Usually for a whole partition LUKS would be great, and I think it's easier to decrypt a LUKS on it's own than it is an eCryptfs folder (many people lose the important hidden/dot config files & wrapped-passphrase and can't get back into their files if something goes wrong).

I think the answer's basically:

  1. Yes. Personally I'd start by installing Ubuntu with a plain/un-encrypted home user, then change the home (or make a new user & change their home) to the old encrypted home partition. I've read that Ubuntu's installer likes to overwrite existing partitions sometimes, so I'd keep it simple to start, and definitely make backups first.
  2. Copy the home files while logged in/decrypted would be easiest. It sounds like the backup drive's not saving user/permissions (maybe it's FAT or NTFS isn't co-operating) so using an archive (or a few small archives) like tar.xz is nice for keeping permissions & smaller backups too. If you're using eCryptfs this avoids the problem of having to get into a copied eCryptfs encrypted folder too.

    If they're encrypted now, you may want to keep the backups encrypted so piped/encrypted with gpg (tar.xz.gpg) would be great. Or make another LUKS container (partition or file) to copy them to. Or if just copying the eCryptfs encrypted files themselves, make sure to get all the settings files especially wrapped-passphrase.

Just copying a partition with dd (I think gparted does the same thing) would make an exact image, so the same label & UUID, and that probably causes the two homes problems. You could change those afterwards, but just making a new partition would give it a different UUID & you can pick a new label, and copying only files wouldn't copy all the free / unused space (like dd) so should be quicker too. A gui file manager should copy the user & permission info, or search for rsync and it's "-a --archive" mode .

0

So I've reinstalled my OSes on my machine, and I've got answers to my questions.

1) A new Ubuntu installation can absolutely go on top of an old encrypted /home partition without worrying about it, at least with ecryptfs.

2) What I used to back up was "cp -pauvr" which preserved the permissions I was hoping for. dd or gparted does copy the label and UUID and that does cause problems. In theory you could use it if you immediately disconnect the second drive, but a preserving cp worked just fine.

The real complication was this: Windows 10 would only install in UEFI mode instead of BIOS by switching from a MBR to a GPT as the partition table for the drive. Which did force me to wipe out everything on the drive. This is a step you can take during Win10 install. So while I could recover my encrypted /home, I ended up having to wipe it out to switch to a GPT.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.