Starting with Ubuntu 12.10, users can now install Ubuntu OS and its core files into an encrypted volume (partition) for additional security (there is an option for that in the installer wizard).
It is called, ‘Encrypt the new Ubuntu installation for security’, and once chosen, all you have to do is enter a password, and the rest will be taken care of. However, if you go with that option, it will erase your entire HDD, and if you use Ubuntu alongside with Windows (I’m using 7), then this is not an ‘option’.
So I just thought that writing a ‘how-to’ guide for achieving this would come in handy for someone who is in new to Ubuntu and want to set it up properly.
Now, before we begin, I assume that you have a separate partition or an unformatted free space on your HDD. If you have already done that, then please skip this section and go directly to the ‘Installation …‘ step (a bit down below).
If you do not have one created and do not know how to do that, then you use the partition editor in Ubuntu or the one that comes with Windowss.
Since we are resizing a native Windows file system, the safest option is to use the ‘disk manager’ in Window. However, if it is Windows OS partition that you are trying to resize, and get errors, then you can use the partition manager in Ubuntu for that.
So, I will laid out the two methods.
Using Windows ‘disk manager’ …
1. Login to your Windows OS (I’m using 7). Then right click on the ‘My Computer’ icon and choose ‘Manage’.
2. From the next window, from the left, choose ‘Disk Management’.
3. As soon as you do that, Windows will list your current partition layout to the right side as shown below.
4. Now select the partition that you want to resize, right click on it and from the menu choose: ‘Shrink’.
5. Then under ‘Enter the amount of space to Shrink in MB’ option, enter the size in MB for the ‘free space partition’.
6. Once done, click on the ‘Shrink’ button:
Depending on the size and the data on the partition, it might take a while, so be patient (don’t run these tools on battery. If it is a desktop computer, then make sure you have a UPS connected, otherwise, if power goes down while doing it, you will end up losing your data!!).
When everything is complete, you should see the newly created free space partition to the right-side of the partition that you just shrink.
If you succeed with this tool, then you can skip the below steps, boot into the Ubuntu Live desktop and just straight to the ‘Installation…‘ step.
Using ‘Gparted’ in Ubuntu to resize a Windows partition …
Once booted into the Ubuntu 12.10 Live desktop, search for the following term in ‘Dash’ as shown in the below screenshot.
Once the partition editor finishes scanning your HDD, select the partition that you want to resize and right click and choose ‘Resize/Move’ as shown below.
This will open up a new window as shown below.
You can either create the free space partition before or after the existing one. But as a general rule, always create the free space area after the existing partition.
Because, if you are using the Windows partition (where it is installed) for this, and create the free space ‘before’ it, then it will make your Windows non-bootable!. So never, never do that!.
Anyway, then you can enter a value in Mega Bytes (MB) for the free space area under the option ‘Free space following MiB’, as shown above.
Important: If you used the keyboard to enter the size, then the ‘Resize/Move’ button will still be deactivated. I don’t know why, but for activating it, you will have to click on the down/up arrows.
However, when you do that, sometimes, the ‘0’ value of the ‘Free space preceding (MiB)’ option gets changed. Meaning that, when you resize, if it was the Windows OS partition, then it will be non-bootable!.
So before clicking the ‘Resize/Move’ button, always, always make sure the value under the ‘Free space preceding (MiB)’ is set to zero.
I have seen people saying ‘GParted’ has f*@k#( their Windows OS after resizing, and this is almost always the reason for that.
Now click on the ‘Resize’ button and it will take you into the partition editor’s main window. Then to apply the changes (always have a second look at the your changes, you never know!), click on the small check-mark icon on the upper toolbar, and it will do the rest for you. Once done close the partition editor.
Once you have created the empty (free space) partition (or had a separate partition from the beginning so jumped directly to this step), click on the ‘Install Ubuntu …’ icon on your Desktop to start the installation.
Then follow the on-screen instructions and when Ubuntu takes you to the ‘installation type’ step, from the list choose ‘Something else’, option.
This will take into the partition editor of the Ubuntu’s installer, and as you can see, the newly created ‘free space’ is listed at the bottom (doesn’t have to be listed at the bottom as it depends on your partition setup).
Now, unlike in the default method, before we can install Ubuntu into an encrypted partition, we have to create a small separate partition for storing the boot files of the OS, otherwise the OS will be unable to boot.
The partition is called ‘boot’, as it holds few but important files that are necessary for the OS’s boot process (and it is an unencrypted partition).
Now, select the ‘free space’ from the list (if you had prepared a partition manually, then choose that), click on the small cross-mark and this will open up a new window.
The ‘boot’ partition does not have to be a big one and a value of 200MB is more than enough. But I have entered 300MB, just in case :). Under the last option called ‘Mount point’, click on the arrow and choose ‘/boot’ option. Leave all other options in their default values!.
Once done, click the ‘OK’ button and then the partition editor will take few seconds and create a new partition called ‘/boot’ which is about 300MB in size (in this case), and will list it in its main window.
There should still be a partition called ‘Free space’, under the ‘boot’ partition. Now select it, and click on the cross-mark for creating another one.
From the next window, leave all the settings to their default values (including the size), but under the ‘Use as’ option, click on the down arrow and choose, ‘physical volume for encryption’ option.
As soon as you do that, two new options will be added to the window. One lets you add a password for the encryption for the partition and the other lets you overwrite the empty space for additional security (optional)..
So, enter your password, twice (never loose this password, otherwise you will not be able to access your data!), then click on the ‘OK’ button and wait for few seconds and the partition editor will apply your changes and take you into its main window again.
This time, you will notice that, at the top of the list, the newly created, encrypted partition is listed under ‘dev/mapper/sda6_crypt …’ (the name ‘sda6’ will differ according to your partition setup).
Now, select the newly created partition and then click on the ‘change’ button.
From the next window, under ‘Mount point’, click on the down-arrow and from the menu choose ‘/’. Then click on the ‘OK’ button.
As soon as you do this, you will be taken into the partition setup window again, and this time, under the newly created encrypted partition, you will see ‘/’ is added under the ‘mount point’ field.
That’s it!. Now you click on the ‘Install now’ button and continue with your usual Ubuntu installation.
‘Swap partition note created’ message …
If you get a message from Ubuntu saying that you have not created a swap partition and would like to create one, then simply click ‘Continue’ button to ignore this waring and to continue with the installation.
If you have like 4GB or more RAM, then you can use GNU/Linux distributions without a Swap partition. Nevertheless, once finished installing Ubuntu, and logged into the Desktop, you can easily create a virtual swap file as well.
If you are interested in how to do that, then please visit this Ubuntu Wiki page. Once you have figured out the size of the Swap file needed, scroll down until you find ‘Four-step Process to Add Swap File‘ sub heading, and proceed with the instructions to create a virtual Swap file.
Well, that’s pretty much it. Good luck.