如何在 Ubuntu 中加密硬盘
加密
![](/data/attachment/album/201702/08/154554qi2f6j6kjcjnv1t3.jpg)


隐私保护、安全和加密是不可分开的，用户可以通过加密来提高安全和保护操作系统的隐私信息。本文将会介绍在 Ubuntu Linux 中对硬盘全盘加密的优缺点。此外，我们也介绍如何在系统级别上进行加密设置，并对一些目录进行加密。加密是非常有用的，而且也没有你想象中那么复杂。综上所述，让我开始进行加密吧。


### 加密的优缺点


尽管进行全盘加密听起来非常棒，但是否要这么做还是有些争议的。我们先来看看这个做法有哪些优缺点。


#### 加密的优点


* 提高私密程度
* 只有拥有密钥的人才能访问操作系统及其中文件
* 确保政府或者黑客无法侦测你的系统和侵犯你的隐私


#### 加密的缺点


* 在其他的 Linux 操作系统上访问和挂载文件系统将变得困难
* 无法从那些加密分区中恢复数据
* 如果用户丢失了加密密钥，那就彻底悲剧了


### 安装前的准备


在 Ubuntu 中加密最好就是在安装进程开始之前在系统层面进行。在 Ubuntu 安装进程开始之后是无法加密的，所以先备份你的重要数据到 [Dropbox](http://www.maketecheasier.com/tag/dropbox)、 [Google Drive](http://www.maketecheasier.com/tag/google-drive) （或者其它硬盘上），然后后准备重新安装 Ubuntu。


![](/data/attachment/album/201702/08/154614e1m0010qmx0015h1.jpg)


从 [此处](https://www.ubuntu.com/download/alternative-downloads) 开始下载最新版本的 Ubuntu，并制作好可启动的 U 盘 （需要至少 2 GB 可用空间）。


制作启动 U 盘需要一个烧录程序，可以到 [etcher.io](https://etcher.io/) 去下载。下载好之后解压 zip 文件，右击 (或者使用鼠标选定之后按下回车) 解压出来的文件以运行。


![](/data/attachment/album/201702/08/154637o96q2me55f9vp75n.jpg)


**注意**：烧录程序会询问是否创建图标，选择“yes”。


在烧录程序中点击“<ruby> 选择镜像 <rp>  （ </rp> <rt>  Select Image </rt> <rp>  ） </rp></ruby>”按钮，选择之前下载好的 Ubuntu ISO 镜像。然后插入你的 U 盘。烧录程序会自动检测并为你选择。最后，点击“<ruby> 开始烧录 <rp>  （ </rp> <rt>  Flash </rt> <rp>  ） </rp></ruby>”按钮来开始创建进程。


完成之后，重启电脑至 BIOS，设置为 U 盘启动。


**注意**：如果你的电脑不支持从 U 盘启动，下载 32 位的 Ubuntu，并使用你电脑中的烧录软件将其烧录到 DVD 中。


### 对你的硬盘进行全盘加密


加载好 Live Ubuntu 之后，安装进程就可以开始了。当 Ubuntu 安装进程开始之后，会出现下面这样一个界面。注意每个人安装进程都可能不同的，或许你会看到的不太一样。


![](/data/attachment/album/201702/08/154658yfx4ca3r4ofvsff4.jpg)


选择“<ruby> 擦除磁盘并安装 Ubuntu <rp>  （ </rp> <rt>  Erase disk and install Ubuntu </rt> <rp>  ） </rp></ruby>”,并选择“<ruby> 加密新装的 Ubuntu 以提高安全程度 <rp>  （ </rp> <rt>  Encrypt the new Ubuntu installation for Security </rt> <rp>  ） </rp></ruby>”来开始加密的安装进程。这样会自动选择 LVM。两个选框都必须选中。选好加密选项之后，点击“<ruby> 现在安装 <rp>  （ </rp> <rt>  Install Now </rt> <rp>  ） </rp></ruby>”。


**注意**：如果是双系统启动的话，你需要安装到空余磁盘空间，而非擦除磁盘。选择好之后，像上边一样选择加密选项。


选择加密选项并开始安装之后，会出现一个加密配置页面。这个页面用户需要为安装进程设置自己的加密密钥。


![](/data/attachment/album/201702/08/154718qnknswoku4nwntfz.jpg)


输入安全密钥。该安全密钥设置窗口会自动为你输入的密钥进行密码强度评级，使用这个功能时看着后边的显示，直到显示为“<ruby> 高强度密码 <rp>  （ </rp> <rt>  strong password </rt> <rp>  ） </rp></ruby>”为止。输入完成后，在下方在此输入来确认密码，最后用一张纸把密码写下下来妥善保管。


此外，选定“<ruby> 覆些磁盘空余空间 <rp>  （ </rp> <rt>  Overwrite empty disk space </rt> <rp>  ） </rp></ruby>”，当然这是一个可选步骤。一切准备就绪之后点击现在安装即可。


![](/data/attachment/album/201702/08/154734x9s2ikmzm9m2clcz.jpg)


在设置完加密密钥之后，就是传统的 Ubuntu 安装配置了。选择时区、创建用户以及对应的安全密码。


![](/data/attachment/album/201702/08/154751q5b5bfusssbowpou.jpg)


与创建和加密 Ubuntu 磁盘对应，在创建用户的时记得候选择“<ruby> 登录系统需要密码 <rp>  （ </rp> <rt>  require my password to log in </rt> <rp>  ） </rp></ruby>”和“<ruby> 加密我的家目录 <rp>  （ </rp> <rt>  encrypt my home folder </rt> <rp>  ） </rp></ruby>”。这样可以为你的数据再增加一层保护。


等到用户名、加密设置以及其他所有事情都完成之后，Ubuntu 安装进程就可以开始了。随后，安装进程会告知你安装已完成，移除安装介质后重启即可享受 Ubuntu 之旅。


### 结论


进行磁盘加密之后，如果没有加密密钥则无法开启 Ubuntu。尽管无趣，但这种级别的加密使用最容易的，并且还充分利用了操作系统提供的特性。用户不需要过多的知识，或者使用其他第三方程序就可以很快完成加密要求。


![](/data/attachment/album/201702/08/154813aeu55l0inniv1nn8.jpg)


加密之后的 Ubuntu，使用起来和没有加密的并没有什么区别。不需要其他的步骤，也不需要学习什么复杂的解密方法。对于那些非常在意隐私但又不想太过麻烦的人来说，这个提高安全等级的方法是必须学会的（当然，这很容易不是吗）。


你是否会使用 Ubuntu 对硬盘进行加密呢？在下方评论告诉我们。




---


译者简介：


[GHLandy](http://GHLandy.com) —— <ruby> 欲得之，则为之奋斗。 <rp>  （ </rp> <rt>  If you want it, work for it. </rt> <rp>  ） </rp></ruby>




---


via: <https://www.maketecheasier.com/encrypt-hard-disk-in-ubuntu/>


作者：[Derrik Diener](https://www.maketecheasier.com/author/derrikdiener/) 译者：[GHLandy](https://github.com/GHLandy) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![](https://www.maketecheasier.com/assets/uploads/2017/01/ubuntu-encrypt-feature-image.jpg)

Privacy, security and encryption go hand in hand. With encryption users can take extra steps to increase the security and privacy of their operating system. In this article we’ll go over the benefits and downsides of encrypting the entire hard drive on Ubuntu Linux. Additionally, we’ll cover exactly how to set up encryption at the OS level and encrypt the home directory. The encryption process is rewarding and not as complicated as some might think! With all that in mind, let’s get started!

## Pros and Cons of Encryption

Though encrypting an entire hard drive sounds like a flawless idea, there are some issues in doing it. Let’s go over the pros and cons.

### Benefits of Encryption

- Increased privacy
- Only those with the encryption key can access the operating system and all the files on it
- No state-governments or hackers can spy on your machine and invade your privacy

### Downsides of Encryption

- Accessing and mounting Linux file systems on other Linux operating systems will be difficult if not practically impossible
- Recovering data from these partitions is impossible
- If a user loses the decryption key, they are out of luck

## Preparing Installation

Encrypting with Ubuntu is best done at the OS level right when the installation starts. It isn’t feasible to encrypt an active Ubuntu installation, so back up all your important files to Dropbox, Google Drive (or even to extra hard drives) and prepare to reinstall Ubuntu.

Start out by downloading the latest version of Ubuntu from [here](https://www.ubuntu.com/download/alternative-downloads), and get a USB flash drive (of at least 2GBs in size) ready.

A program is needed in order to make a live USB disk. Head to etcher.io and download the Etcher tool. Extract it from the zip archive, and right click (or highlight with the mouse and press the Enter key) on the extracted file to run it.

**Note**: Etcher will ask to create an icon – select “yes.”

Inside Etcher click the “Select Image” button, and navigate towards the Ubuntu ISO image downloaded earlier. Then, plug in the USB flash drive. Etcher will automatically detect it and select for you. Finally, select the “Flash!” button to start the creation process.

Once completed, reboot the computer with the flash drive still plugged in, load the computer’s BIOS and select the option to boot from USB.

**Note**: if your machine does not support booting from USB, download the 32bit version of Ubuntu and burn the ISO to a DVD using the burning software on your computer.

## Encrypting Your Entire Hard Disk

With the live Ubuntu disk loaded, the installation can begin. When the Ubuntu installation begins, a window similar to this will appear. Keep in mind that each installation process is different and may say different things.

To begin the encrypted installation, select “Erase disk and install Ubuntu,” and check “**Encrypt the new Ubuntu installation for Security**” box. This will automatically select LVM as well. Both boxes must be checked. After selecting the encryption options, click “Install Now” to begin installation.

**Note**: if this is a dual-boot machine, you may notice install alongside instead of erase. Select it, and select the encryption options mentioned above as well.

Clicking “Install Now” with the encryption options selected in Ubuntu will bring up a configuration page. This page allows the user to set the encryption key for the installation.

Enter the security key. The security key window will grade the effectiveness of the security key, so use this tool as a barometer and try to get a security key that says “strong password.” Once chosen, enter it again to confirm it, and then write this key down on a piece of paper for safekeeping.

Additionally, check the box that says “Overwrite empty disk space.” This is an optional step. Select install now once everything is entered.

What follows selecting the encryption key is the typical Ubuntu installation configuration. Select the time zone, and create a username along with a secure password.

Along with creating an encrypted hard drive on Ubuntu, select the “require my password to log in” box and the “encrypt my home folder” box during the username creation process. This will add yet another layer of encryption for data on the system.

With the username, encryption settings and everything else configured, the Ubuntu installation will begin. Soon after, Ubuntu will inform the user that the installation has been completed and that everything is ready to go!

## Conclusion

From this point on Ubuntu will not be able to be accessed without the decryption key at startup. Though tedious, encrypting Ubuntu this way is the easiest and takes advantage of the features already present in the operating system. Users will not need to learn much, nor will they need to rely on third party programs to accomplish this task.

With Ubuntu decrypted, it runs like normal. No extra hoops to jump through nor overly complicated decryption methods to learn. This method of security is a must for those who value their privacy but don’t want to fuss.

Would you encrypt your Ubuntu installation? Tell us below!

Our latest tutorials delivered straight to your inbox