I have a system with both Ubuntu 11.10 and Windows 7 and I want to encrypt the whole harddisk or at least some of my partitions.
My partition table is something like this (the ones marked with * are the ones that need to be encrypted):
- Windows boot reserved partition
- *Windows system partition (ntfs)
- *Windows data partition (ntfs)
- Ubuntu root partition (ext4)
- *Ubuntu home partition (ext4)
- Ubuntu swap
As I said I don't need to encrypt the whole disk.
What is the best way to accomplish this? Maybe something (TrueCrypt?) where I enter the password before the system boots so that it decrypts the whole hdd? Or maybe individual encryption using Windows-only encryption (for Windows partitions) and Ubuntu home encryption (well, for Ubuntu home partition)?
By the way, I almost always use Ubuntu, so it would be nice if I could continue to boot Ubuntu by default but have an option to boot Windows too (like in grub).
EDIT: I was thinking of doing this: encrypting ubuntu home with eCryptfs (I think this is used to encrypt home when selected during installation). Encrypting Windows partitions with TrueCrypt. Still having Grub as a bootloader, when I choose ubuntu everything goes as normal (home is decrypted when login in). When I choose windows the TrueCrypt password prompt shows and windows boots.
If you're looking for cross-compatibility between both encrypted systems, I'd recommend using TrueCrypt.
Since you have a /home partition already, things get a little difficult.
NOTE: MAKE BACKUPS of all files you modify in case this doesn't go totally as planned.
Recommended Backups:
So, you have Windows and Linux already installed, the first thing you should do it attempt to encrypt your /home partition.
Linux
Firstly download and install the appropriate architecture's .deb file from TrueCrypt.org
Next, you have two choices:
Choice 1:
First, log out and Ctrl+Alt+F1 and login.
Ctrl-Alt-F7 to get back to the login screen and log in as usual
Now assuming all went well, remove /home's line in /etc/fstab and format the partition that used to house your /home folder as a TrueCrypt container:
Set options as desired. If you installed the GUI version, the goal is to prompt for a mount password before showing the login screen. I'm not sure how the command-line version will react to this. I would recommend using the keyfiles for the command-line version. Make sure you make it an ext2 paritition and not ext3/ext4, if you want it to be readable by Windows with the ext2fs driver for Windows)
Choice 2: If you've got the extra space, you can take the easy way out and make a new partition to house your encrypted home folder.
Use gparted or a similar tool to make your new partition (from a LiveCD if you have to resize /home or /)
Reboot.
Now, if you have to use gparted again to find your new partition's device (/dev/sda6, for example). Format the new partition using TrueCrypt. As stated above, I recommend using keyfiles for the command-line version as I don't know if it can prompt for a password. And again, make it ext2 if you want to be able to use it in Windows.
Now, mount the new TrueCrypt partition using the GUI or the command line. There are so many options here I'm going to leave it to you to read the TrueCrypt help.
Copy home files to encrypted volume
Do not delete the files in /home/[myusername] yet!
Now,
cp /media/truecrypt1/.profile /home/[myusername]
. Also, move your keyfile if you used one to here (insecure!) or know where it can be referenced (as long as it's not inside the TrueCrypt partition.Add the following line to the end of /home/[myusername]/.profile:
Add this line in /etc/sudoers using
visudo
: [myusername] ALL = (root) NOPASSWD : /usr/bin/truecryptNow, log out and log back in.
Just because you've made it this far doesn't mean anything.
Check the output of
mount
. If there's an entry that says /home/[myusername], then you're all set! Alternatively, you can check the contents of .profile. If the line we added isn't there, then you were successful!But! Just to be absolutely sure, reboot and do it from a fresh boot.
If you've made it this far successfully, logout. Ctrl-Alt-F1
and delete everything in /home/[myusername] EXCEPT the .profile file. (You might be wondering what's going on right now. If you weren't paying attention, I overlapped the existing /home with a mount, which hides all files that already existed in /home until you unmount the overlaying filesystem. This is why we can check the .profile file to see if we were successful.)
Finally! Back up your MBR with
dd if=/dev/sda of=/path/to/backup/mbr.bin bs=512 count=1
. Remember, it must be accessible from both Window and Linux. Rungrub-install --force /dev/sda3
, where /dev/sda3 is your root filesystem partition.If something's not working correctly, go through the tutorial again and make sure you did every step. If you're having trouble here, you should probably undo everything.
Undoing choice 1: - Re-format the TrueCrypt partition back to what it was (probably ext4) - Delete the line from /home/[myusername]/.profile. -
sudo mkdir /home2;sudo mount /dev/sdaX home2
Where /dev/sdaX is the re-made /home partition -sudo cp -aR /home/* /home2
- Verify your files (especially dot files) -sudo umount /home2;sudo rmdir /home2
-sudo rm -R /home/*
- Then, uncomment the line in /etc/fstab that starts with#/dev/sdaX.../home
-sudo mount -a
- Log out and back inUndoing choice 2: - Open Gparted and put your partition back the way they were (probably a delete and expand operation. This will probably take logging out, Ctrl+Alt+F1, login,
cd /;sudo umount / home; sudo su
and using parted instead. Or you can boot from a LiveCD to resize your /home partition). - Back in your normal system, Remove the added line from .profile - Log out and log back inWindows
Reboot into Windows and run the TrueCrypt full disk encryption. This will place a new TrueCrypt MBR onto your disk.
This is the easy part.
How to Select Between Windows/Linux
Some of you might be packing right now because your boot screen doesn't look like it used to. Well, we prepared for this by installing grub to your root partition instead of the MBR. When the TrueCrypt screen shows up, hit
ESC
to be kicked into the GRUB2 bootloader - ideally.If it doesn't work download "dd for Windows" and running dd.exe if=F:\path\to\backup\mbr.bin of=\?\Device\Harddisk0\Parition0 (may have to run it with administrator privileges).
To encrypt the Ubuntu home, just select that option (at the bottom) during the installation.
https://help.ubuntu.com/community/GraphicalInstall?action=AttachFile&do=get&target=install-step5.png
As for Windows, what version do you use? Truecrypt seems to offer system partition encryption, and I've heard the W7 had some encryption options.