「Dm-crypt/システム全体の暗号化」の版間の差分
細 (→概要) |
|||
4行目: | 4行目: | ||
[[Category:Arch の入手とインストール]] |
[[Category:Arch の入手とインストール]] |
||
[[en:Dm-crypt/Encrypting an entire system]] |
[[en:Dm-crypt/Encrypting an entire system]] |
||
− | [[es:Dm-crypt/Encrypting an |
+ | [[es:Dm-crypt/Encrypting an entire system]] |
[[dm-crypt]] に戻る。 |
[[dm-crypt]] に戻る。 |
||
− | 以下は ''dm-crypt'' を使って完全なシステム暗号化を行う一般的なシナリオの例です。通常の[[インストールガイド|インストール手順]]に加える必要がある変更を全て説明しています。必要なツールは全て [https:// |
+ | 以下は ''dm-crypt'' を使って完全なシステム暗号化を行う一般的なシナリオの例です。通常の[[インストールガイド|インストール手順]]に加える必要がある変更を全て説明しています。必要なツールは全て [https://www.archlinuxjp.org/download/ インストールイメージ] に入っています。 |
== 概要 == |
== 概要 == |
||
35行目: | 35行目: | ||
* [[Dm-crypt/スワップの暗号化#suspend-to-disk_を使用する|ハイバネート]]を利用したいときの一番簡単な方法 |
* [[Dm-crypt/スワップの暗号化#suspend-to-disk_を使用する|ハイバネート]]を利用したいときの一番簡単な方法 |
||
| |
| |
||
− | * LVM adds an additional mapping layer and hook |
+ | * LVM adds an additional mapping layer and hook |
− | * Less useful, if a singular volume should receive a separate key |
+ | * Less useful, if a singular volume should receive a separate key |
|---------------------------------------------------------- |
|---------------------------------------------------------- |
||
| [[#LUKS on LVM]] |
| [[#LUKS on LVM]] |
||
49行目: | 49行目: | ||
|---------------------------------------------------------- |
|---------------------------------------------------------- |
||
| [[#Plain dm-crypt]] |
| [[#Plain dm-crypt]] |
||
− | dm-crypt の plain モードを使用、LUKS ヘッダーや LUKS の複数のキーのオプションは使わない<br>このシナリオでは /boot とキーストレージに USB デバイスを使いますが、これは他のデバイスでも利用可能です |
+ | dm-crypt の plain モードを使用、LUKS ヘッダーや LUKS の複数のキーのオプションは使わない<br>このシナリオでは {{ic|/boot}} とキーストレージに USB デバイスを使いますが、これは他のデバイスでも利用可能です |
| |
| |
||
* Data resilience for cases where a LUKS header may be damaged |
* Data resilience for cases where a LUKS header may be damaged |
||
− | * [[Wikipedia:Deniable encryption| |
+ | * [[Wikipedia:Deniable encryption|否認可能暗号]]が使える |
| |
| |
||
* High care to all encryption parameters is required |
* High care to all encryption parameters is required |
||
* Single encryption key and no option to change it |
* Single encryption key and no option to change it |
||
+ | |---------------------------------------------------------- |
||
+ | | [[#boot パーティションの暗号化 (GRUB)]] |
||
+ | GRUB ブートローダーを使って boot パーティションを暗号化する方法を説明します。<br>このシナリオでは ESP パーティションを使いますが、他のシナリオでも ESP を使うことができます。 |
||
+ | | |
||
+ | * Same advantages as the scenario the installation is based on (LVM on LUKS for this particular example) |
||
+ | * Less data is left unencrypted, i.e. the boot loader and the ESP partition, if present |
||
+ | | |
||
+ | * Same disadvantages as the scenario the installation is based on (LVM on LUKS for this particular example) |
||
+ | * More complicated configuration |
||
+ | * Not supported by other boot loaders |
||
|} |
|} |
||
139行目: | 149行目: | ||
{{Tip|Two variants of this setup: |
{{Tip|Two variants of this setup: |
||
+ | * [[Dm-crypt/特記事項#リモート LUKS ヘッダーを使ってシステムを暗号化]]ではこのセットアップと USB デバイスのリモート LUKS ヘッダーを使って二段階認証を実現します。 |
||
− | * Instructions at [[Dm-crypt/Specialties#Encrypted system using a remote LUKS header]] use this setup with a remote LUKS header on a USB device to achieve a two factor authentication with it. |
||
* Instructions at [http://www.pavelkogan.com/2014/05/23/luks-full-disk-encryption/ Pavel Kogan's blog] show how to encrypt the {{ic|/boot}} partition while keeping it on the main LUKS partition when using GRUB, but be aware of {{Bug|43663}}.}} |
* Instructions at [http://www.pavelkogan.com/2014/05/23/luks-full-disk-encryption/ Pavel Kogan's blog] show how to encrypt the {{ic|/boot}} partition while keeping it on the main LUKS partition when using GRUB, but be aware of {{Bug|43663}}.}} |
||
146行目: | 156行目: | ||
パーティションを作成する前に、[[Dm-crypt/ドライブの準備]] で説明されているように、ディスクを完全に消去する必要性・方法を学んでください。 |
パーティションを作成する前に、[[Dm-crypt/ドライブの準備]] で説明されているように、ディスクを完全に消去する必要性・方法を学んでください。 |
||
− | + | [[GPT]] で [[GRUB]] ブートローダーを使う時は、[[GRUB#BIOS システム]] で説明されているように BIOS Boot Partition を作成してください。 |
|
Create a partition to be mounted at {{ic|/boot}} of type {{ic|8300}} with a size of 100 MB or more. |
Create a partition to be mounted at {{ic|/boot}} of type {{ic|8300}} with a size of 100 MB or more. |
||
156行目: | 166行目: | ||
# cryptsetup luksFormat /dev/''sdaX'' |
# cryptsetup luksFormat /dev/''sdaX'' |
||
+ | cryptsetup のオプションについては [[Dm-crypt/デバイスの暗号化#LUKS モードの暗号化オプション|LUKS 暗号化のオプション]]を見て下さい。 |
||
− | For more information about the available cryptsetup options see the [[Dm-crypt/Device encryption#Encryption_options_for_LUKS_mode|LUKS encryption options]] prior to above command. |
||
Open the container: |
Open the container: |
||
169行目: | 179行目: | ||
# pvcreate /dev/mapper/lvm |
# pvcreate /dev/mapper/lvm |
||
+ | {{ic|MyStorage}} という名前のボリュームグループを作成して、先に作成した物理ボリュームを追加: |
||
− | Create the volume group named {{ic|MyStorage}}, adding the previously created physical volume to it: |
||
# vgcreate MyStorage /dev/mapper/lvm |
# vgcreate MyStorage /dev/mapper/lvm |
||
+ | ボリュームグループに論理ボリュームを作成: |
||
− | Create all your logical volumes on the volume group: |
||
# lvcreate -L 8G MyStorage -n swapvol |
# lvcreate -L 8G MyStorage -n swapvol |
||
179行目: | 189行目: | ||
# lvcreate -l +100%FREE MyStorage -n homevol |
# lvcreate -l +100%FREE MyStorage -n homevol |
||
+ | 論理ボリュームのファイルシステムをフォーマット: |
||
− | Format your filesystems on each logical volume: |
||
# mkfs.ext4 /dev/mapper/MyStorage-rootvol |
# mkfs.ext4 /dev/mapper/MyStorage-rootvol |
||
185行目: | 195行目: | ||
# mkswap /dev/mapper/MyStorage-swapvol |
# mkswap /dev/mapper/MyStorage-swapvol |
||
+ | ファイルシステムをマウント: |
||
− | Mount your filesystems: |
||
# mount /dev/MyStorage/rootvol /mnt |
# mount /dev/MyStorage/rootvol /mnt |
||
195行目: | 205行目: | ||
The bootloader loads the kernel, [[initramfs]], and its own configuration files from the {{ic|/boot}} directory. This directory must be located on a separate unencrypted filesystem. |
The bootloader loads the kernel, [[initramfs]], and its own configuration files from the {{ic|/boot}} directory. This directory must be located on a separate unencrypted filesystem. |
||
+ | {{ic|/boot}} にするパーティションに Ext2 ファイルシステムを作成します。ブートローダーが読み込めるファイルシステムなら何でもかまいません。 |
||
− | Create an Ext2 filesystem on the partition intended for {{ic|/boot}}. Any filesystem that can be read by the bootloader is eligible. |
||
# mkfs.ext2 /dev/''sdbY'' |
# mkfs.ext2 /dev/''sdbY'' |
||
− | + | {{ic|/mnt/boot}} ディレクトリを作成: |
|
# mkdir /mnt/boot |
# mkdir /mnt/boot |
||
− | + | パーティションを {{ic|/mnt/boot}} にマウント: |
|
# mount /dev/''sdbY'' /mnt/boot |
# mount /dev/''sdbY'' /mnt/boot |
||
218行目: | 228行目: | ||
=== ブートローダーの設定 === |
=== ブートローダーの設定 === |
||
+ | 起動時に暗号化された root パーティションの暗号化が解除されるように、以下のカーネルパラメータをブートローダーで設定します: |
||
− | In order unlock the encrypted root partition at boot, the following kernel parameters need to be set by the boot loader: |
||
cryptdevice=/dev/''partition'':MyStorage root=/dev/mapper/MyStorage-rootvol |
cryptdevice=/dev/''partition'':MyStorage root=/dev/mapper/MyStorage-rootvol |
||
詳しくは [[Dm-crypt/システム設定#ブートローダー]] を見て下さい。 |
詳しくは [[Dm-crypt/システム設定#ブートローダー]] を見て下さい。 |
||
− | |||
− | {{Note|1=When re-installing [[GRUB]], you may receive warnings like {{ic|/run/lvm/lvmetad.socket: connect failed: No such file or directory|}} or {{ic|WARNING: failed to connect to lvmetad: No such file or directory. Falling back to internal scanning|}}. This is because {{ic|/run}} is not available inside the chroot. These warnings will not prevent the system from booting, provided that everything has been done correctly, so you may continue with the installation.}} |
||
== LUKS on LVM == |
== LUKS on LVM == |
||
230行目: | 238行目: | ||
[[LVM]] 上で暗号化を利用するには、まず LVM ボリュームをセットアップして、それから暗号化パーティションのベースとして使うことになります。この方法では、暗号化パーティションと非暗号化パーティションのミックスが可能です。[[#LVM on LUKS]] とは違って、複数のディスクにまたがるような通常の論理ボリュームは使えません。 |
[[LVM]] 上で暗号化を利用するには、まず LVM ボリュームをセットアップして、それから暗号化パーティションのベースとして使うことになります。この方法では、暗号化パーティションと非暗号化パーティションのミックスが可能です。[[#LVM on LUKS]] とは違って、複数のディスクにまたがるような通常の論理ボリュームは使えません。 |
||
− | The following short example creates a LUKS on LVM setup and mixes in the use of a key-file for the /home partition and temporary crypt volumes for {{ic|/tmp}} and {{ic|/swap}}. The latter is considered desirable from a security perspective, because no potentially sensitive temporary data survives the reboot, when the encryption is re-initialised. If you are experienced with LVM, you will be able to ignore/replace LVM and other specifics according to your plan. If you want to span a logical volume over multiple disks during setup already, a procedure to do so is described in [[Dm-crypt/ |
+ | The following short example creates a LUKS on LVM setup and mixes in the use of a key-file for the /home partition and temporary crypt volumes for {{ic|/tmp}} and {{ic|/swap}}. The latter is considered desirable from a security perspective, because no potentially sensitive temporary data survives the reboot, when the encryption is re-initialised. If you are experienced with LVM, you will be able to ignore/replace LVM and other specifics according to your plan. If you want to span a logical volume over multiple disks during setup already, a procedure to do so is described in [[Dm-crypt/特記事項#LVM を複数のディスクに拡張]]. |
=== ディスクの準備 === |
=== ディスクの準備 === |
||
238行目: | 246行目: | ||
* {{ic|/dev/sda2}} -> LVM |
* {{ic|/dev/sda2}} -> LVM |
||
+ | [[Dm-crypt/ドライブの準備#インストール前に dm-crypt で消去]]を見て {{ic|/dev/sda2}} をランダム化してください。 |
||
− | Randomise {{ic|/dev/sda2}} according to [[Dm-crypt/Drive preparation#dm-crypt_wipe_before_installation]]. |
||
=== 論理ボリュームの準備 === |
=== 論理ボリュームの準備 === |
||
254行目: | 262行目: | ||
# mount /dev/mapper/root /mnt |
# mount /dev/mapper/root /mnt |
||
− | Note that {{ic|/home}} will be encrypted [[#論理ボリューム /home の暗号化|later]] in this example. Further, note that if you ever have to access the encrypted root from the Arch-ISO, the above {{ic|open}} action will allow you to after the [[ |
+ | Note that {{ic|/home}} will be encrypted [[#論理ボリューム /home の暗号化|later]] in this example. Further, note that if you ever have to access the encrypted root from the Arch-ISO, the above {{ic|open}} action will allow you to after the [[LVM#論理ボリュームが表示されない|LVM shows up]]. |
=== boot パーティションの準備 === |
=== boot パーティションの準備 === |
||
262行目: | 270行目: | ||
# mount /dev/sda1 /mnt/boot |
# mount /dev/sda1 /mnt/boot |
||
− | Now after setup of the encrypted LVM partitioning, it would be time to install: [[ |
+ | Now after setup of the encrypted LVM partitioning, it would be time to install: [[インストールガイド#パーティションのマウント|Arch Install Scripts]]. |
=== mkinitcpio の設定 === |
=== mkinitcpio の設定 === |
||
290行目: | 298行目: | ||
=== 論理ボリューム /home の暗号化 === |
=== 論理ボリューム /home の暗号化 === |
||
Since this scenario uses LVM as the primary and dm-crypt as secondary mapper, each encrypted logical volume requires its own encryption. Yet, unlike the temporary filesystems configured with volatile encryption above, the logical volume for {{ic|/home}} should be persistent, of course. The following assumes you have rebooted into the installed system, otherwise you have to adjust paths. |
Since this scenario uses LVM as the primary and dm-crypt as secondary mapper, each encrypted logical volume requires its own encryption. Yet, unlike the temporary filesystems configured with volatile encryption above, the logical volume for {{ic|/home}} should be persistent, of course. The following assumes you have rebooted into the installed system, otherwise you have to adjust paths. |
||
− | To safe on entering a second passphrase at boot for it, a [[Dm-crypt/ |
+ | To safe on entering a second passphrase at boot for it, a [[Dm-crypt/デバイスの暗号化#キーファイル|keyfile]] is created: |
mkdir -m 700 /etc/luks-keys |
mkdir -m 700 /etc/luks-keys |
||
dd if=/dev/random of=/etc/luks-keys/home bs=1 count=256 |
dd if=/dev/random of=/etc/luks-keys/home bs=1 count=256 |
||
307行目: | 315行目: | ||
and setup is done. |
and setup is done. |
||
− | If you want to expand the logical volume for {{ic|/home}} (or any other volume) at a later point, it is important to note that the LUKS encrypted part has to be resized as well. For a procedure see [[Dm-crypt/ |
+ | If you want to expand the logical volume for {{ic|/home}} (or any other volume) at a later point, it is important to note that the LUKS encrypted part has to be resized as well. For a procedure see [[Dm-crypt/特記事項#LVM を複数のディスクに拡張]]. |
== Plain dm-crypt == |
== Plain dm-crypt == |
||
This scenario sets up a system on a dm-crypt a full disk with ''plain'' mode encryption. Note that for most use cases, the methods using LUKS described above are the better options for both system encryption and encrypted partitions. LUKS features like key management with multiple pass-phrases/key-files are unavailable with ''plain'' mode. |
This scenario sets up a system on a dm-crypt a full disk with ''plain'' mode encryption. Note that for most use cases, the methods using LUKS described above are the better options for both system encryption and encrypted partitions. LUKS features like key management with multiple pass-phrases/key-files are unavailable with ''plain'' mode. |
||
+ | |||
+ | dm-crypt ''plain'' mode does not require a header on the encrypted disk: this means that an unpartitioned, encrypted disk will be indistinguishable from a disk filled with random data, which is the desired attribute for this scenario, see also [[Wikipedia:Deniable encryption]]. |
||
+ | |||
+ | ''Plain'' dm-crypt encrypted disks can be more resilient to damage than LUKS encrypted disks, because it does not rely on an encryption master-key which can be a single-point of failure if damaged. However, using ''plain'' mode also requires more manual configuration of encryption options to achieve the same cryptographic strength. See also [[ディスク暗号化#暗号メタデータ]]. |
||
+ | |||
+ | {{Tip|If headerless encryption is your goal but you are unsure about the lack of key-derivation with ''plain'' mode, then two alternatives are: |
||
+ | * [[tcplay]] which offers headerless encryption but with the PBKDF2 function, or |
||
+ | * dm-crypt LUKS mode by using the ''cryptsetup'' {{ic|--header}} option. It cannot be used with the standard ''encrypt'' hook, but the hook [[Dm-crypt/特記事項#リモート LUKS ヘッダーを使ってシステムを暗号化|may be modified]].}} |
||
The scenario uses a USB stick for the boot device and another one to store the encryption key. The disk layout is: |
The scenario uses a USB stick for the boot device and another one to store the encryption key. The disk layout is: |
||
− | + | |--------------------+------------------+--------------------+ +---------------+ +---------------+ |
|
− | |disk drive /dev/sdaX encrypted using plain mode and LVM | |USB stick 1 | |USB stick 2 | |
||
− | |--------------------+------------------+--------------------| |---------------| |---------------| |
||
|Volume 1: |Volume 2: |Volume 3: | |Boot device | |Encryption key | |
|Volume 1: |Volume 2: |Volume 3: | |Boot device | |Encryption key | |
||
| | | | | | |file storage | |
| | | | | | |file storage | |
||
323行目: | 337行目: | ||
| | | | | | |in example) | |
| | | | | | |in example) | |
||
|/dev/store/root |/dev/store/swap |/dev/store/home | |/dev/sdY1 | |/dev/sdZ | |
|/dev/store/root |/dev/store/swap |/dev/store/home | |/dev/sdY1 | |/dev/sdZ | |
||
− | + | |--------------------+------------------+--------------------| |---------------| |---------------| |
|
+ | |disk drive /dev/sdaX encrypted using plain mode and LVM | |USB stick 1 | |USB stick 2 | |
||
+ | +------------------------------------------------------------+ +---------------+ +---------------+ |
||
+ | {{ic|/boot}} and the boot loader cannot be kept on the encrypted drive, or it will defeat the purpose of using ''plain'' mode for deniable encryption. This also allows storing the options required to open/unlock the plain encrypted device in the boot loader configuration, since typing them on each boot would be error prone. |
||
− | The reasons for the use of two USB-keys are: |
||
− | * The boot loader options required to open/unlock a plain encrypted device are detailed. Typing them each boot is error prone, storing them on an unencrypted {{ic|/boot}} partition on the same device results in security concerns. |
||
− | * This scenario uses a key file, storing the keyfile on a second USB stick for security again. A passphrase with good [[Disk_encryption#Choosing_a_strong_passphrase|entropy]] may be used instead. |
||
+ | This scenario also uses a key file, assuming it stored as raw bits on a second USB stick, so that to the eyes of an unaware attacker who might get the usbkey the encryption key will appear as random data instead of being visible as a normal file. See also [[Wikipedia:Security through obscurity]], follow [[Dm-crypt/デバイスの暗号化#キーファイル]] to prepare the keyfile. |
||
− | The main consideration for choosing ''plain'' over ''LUKS'' mode for the scenario is: |
||
+ | {{Tip| |
||
− | * dm-crypt ''plain'' mode does not require a header on the encrypted disk. This means that an unpartitioned, encrypted disk will be indistinguishable from a disk filled with random data, which is the desired attribute for this scenario. |
||
+ | * It is also possible to use a single usb key by copying the keyfile to the initram directly. An example keyfile {{ic|/etc/keyfile}} gets copied to the initram image by setting {{ic|1=FILES="/etc/keyfile"}} in {{ic|/etc/mkinitcpio.conf}}. The way to instruct the {{ic|encrypt}} hook to read the keyfile in the initram image is using {{ic|rootfs:}} prefix before the filename, e.g. {{ic|cryptkey=rootfs:/etc/keyfile}}. |
||
− | |||
+ | * Another option is using a passphrase with good [[ディスク暗号化#強固なパスフレーズの選択|entropy]]. |
||
− | ''Plain'' dm-crypt encrypted disks can be more resilient to damage than LUKS encrypted disks, because it does not rely on an encryption master-key which can be a single-point of failure if damaged. However, using ''plain'' mode also requires more manual configuration of encryption options to achieve the same cryptographic strength. See also [[Disk encryption#Cryptographic metadata]] |
||
+ | }} |
||
− | |||
− | {{Tip|If headerless encryption is your goal but you are unsure about the lack of key-derivation with ''plain'' mode, then two alternatives are: |
||
− | * [[tcplay]] which offers headerless encryption but with the PBKDF2 function, or |
||
− | * dm-crypt LUKS mode by using the ''cryptsetup'' {{ic|--header}} option. It cannot be used with the standard ''encrypt'' hook, but the hook [[Dm-crypt/Specialties#Encrypted system using a remote LUKS header|may be modified]].}} |
||
=== ディスクの準備 === |
=== ディスクの準備 === |
||
343行目: | 354行目: | ||
It is vital that the mapped device is filled with data. In particular this applies to the scenario usecase we apply here. |
It is vital that the mapped device is filled with data. In particular this applies to the scenario usecase we apply here. |
||
− | + | [[Dm-crypt/ドライブの準備]] や [[Dm-crypt/ドライブの準備#dm-crypt 固有の方法]] を見て下さい。 |
|
=== boot 以外のパーティションの準備 === |
=== boot 以外のパーティションの準備 === |
||
+ | 詳しくは [[Dm-crypt/デバイスの暗号化#plain モードの暗号化オプション]] を参照。 |
||
− | See [[Dm-crypt/Device encryption#Encryption options for plain mode]] for details. |
||
Using the device {{ic|/dev/sd''X''}}, with the twofish-xts cipher with a 512 bit key size and using a keyfile we have the following options for this scenario: |
Using the device {{ic|/dev/sd''X''}}, with the twofish-xts cipher with a 512 bit key size and using a keyfile we have the following options for this scenario: |
||
356行目: | 367行目: | ||
# fdisk -l |
# fdisk -l |
||
− | Next, we setup [[LVM]] logical volumes on the mapped device, see [[ |
+ | Next, we setup [[LVM]] logical volumes on the mapped device, see [[LVM#Arch Linux を LVM にインストールする]] for further details: |
# pvcreate /dev/mapper/enc |
# pvcreate /dev/mapper/enc |
||
# vgcreate store /dev/mapper/enc |
# vgcreate store /dev/mapper/enc |
||
372行目: | 383行目: | ||
=== boot パーティションの準備 === |
=== boot パーティションの準備 === |
||
− | The {{ic|/boot}} partition can be installed on the standard vfat partition of a USB stick, if required. But if manual partitioning is needed, then a small 200MB partition is all that is required. Create the partition using a [[ |
+ | The {{ic|/boot}} partition can be installed on the standard vfat partition of a USB stick, if required. But if manual partitioning is needed, then a small 200MB partition is all that is required. Create the partition using a [[パーティショニング#パーティショニングツール|partitioning tool]] of your choice. |
We choose a non-journalling file system to preserve the flash memory of the {{ic|/boot}} partition, if not already formatted as vfat: |
We choose a non-journalling file system to preserve the flash memory of the {{ic|/boot}} partition, if not already formatted as vfat: |
||
409行目: | 420行目: | ||
# mount /boot |
# mount /boot |
||
+ | |||
+ | == boot パーティションの暗号化 (GRUB) == |
||
+ | |||
+ | This setup utilizes the same partition layout and configuration for the system's root partition as the previous [[#LVM on LUKS]] section, with two distinct differences: |
||
+ | |||
+ | # The setup is performed for an [[UEFI]] system and |
||
+ | # A special feature of the [[GRUB]] bootloader is used to additionally encrypt the boot partition {{ic|/boot}}. See also [[GRUB#Boot partition]]. |
||
+ | |||
+ | The disk layout in this example is: |
||
+ | |||
+ | +---------------+----------------+----------------+----------------+----------------+ |
||
+ | |ESP partition: |Boot partition: |Volume 1: |Volume 2: |Volume 3: | |
||
+ | | | | | | | |
||
+ | |/boot/efi |/boot |root |swap |home | |
||
+ | | | | | | | |
||
+ | | | |/dev/store/root |/dev/store/swap |/dev/store/home | |
||
+ | |/dev/sdaX |/dev/sdaY +----------------+----------------+----------------+ |
||
+ | |'''un'''encrypted |LUKS encrypted |/dev/sdaZ encrypted using LVM on LUKS | |
||
+ | +---------------+----------------+--------------------------------------------------+ |
||
+ | |||
+ | {{Tip|All scenarios are intended as examples. It is, of course, possible to apply both of the two above distinct installation steps with the other scenarios as well. See also the variants linked in [[#LVM on LUKS]].}} |
||
+ | |||
+ | === ディスクの準備 === |
||
+ | |||
+ | Prior to creating any partitions, you should inform yourself about the importance and methods to securely erase the disk, described in [[Dm-crypt/ドライブの準備]]. |
||
+ | |||
+ | Create an [[Unified_Extensible_Firmware_Interface#EFI_System_Partition|EFI System Partition (ESP)]] with an appropriate size, it will later be mounted at {{ic|/boot/efi}}. |
||
+ | |||
+ | Create a partition to be mounted at {{ic|/boot}} of type {{ic|8300}} with a size of 100 MB or more. |
||
+ | |||
+ | {{Tip|When using the [[GRUB]] bootloader together with a BIOS/[[GPT]], create a BIOS Boot Partition as explained in [[GRUB#BIOS システム]] instead of the ESP.}} |
||
+ | |||
+ | Create a partition of type {{ic|8E00}}, which will later contain the encrypted container. |
||
+ | |||
+ | Create the LUKS encrypted container at the "system" partition. |
||
+ | |||
+ | # cryptsetup luksFormat /dev/''sdaZ'' |
||
+ | |||
+ | For more information about the available cryptsetup options see the [[Dm-crypt/デバイスの暗号化#LUKS モードの暗号化オプション|LUKS encryption options]] prior to above command. |
||
+ | |||
+ | Your partition layout should look similar to this: |
||
+ | {{hc| gdisk /dev/sda | |
||
+ | Number Start (sector) End (sector) Size Code Name |
||
+ | 1 2048 1050623 512.0 MiB EF00 EFI System |
||
+ | 2 1050624 1460223 200.0 MiB 8300 Linux filesystem |
||
+ | 3 1460224 41943006 19.3 GiB 8E00 Linux LVM |
||
+ | }} |
||
+ | |||
+ | Open the container: |
||
+ | |||
+ | # cryptsetup open --type luks /dev/''sdaZ'' lvm |
||
+ | |||
+ | The decrypted container is now available at {{ic|/dev/mapper/lvm}}. |
||
+ | |||
+ | === 論理ボリュームの準備 === |
||
+ | |||
+ | The LVM logical volumes of this example follow the exact layout as the previous scenario. Therefore, please follow [[#論理ボリュームの準備|Preparing the logical volumes]] above or adjust as required. |
||
+ | |||
+ | === boot パーティションの準備 === |
||
+ | |||
+ | The bootloader loads the kernel, [[initramfs]], and its own configuration files from the {{ic|/boot}} directory. |
||
+ | |||
+ | First, create the LUKS container where the files will be located and installed into: |
||
+ | |||
+ | # cryptsetup luksFormat /dev/sda''Y'' |
||
+ | |||
+ | Next, open it: |
||
+ | # cryptsetup open /dev/sda''Y'' cryptboot |
||
+ | |||
+ | Create a filesystem on the partition intended for {{ic|/boot}}. Any filesystem that can be read by the bootloader is eligible: |
||
+ | |||
+ | # mkfs.ext2 /dev/mapper/''cryptboot'' |
||
+ | |||
+ | Create the directory {{ic|/mnt/boot}}: |
||
+ | |||
+ | # mkdir /mnt/boot |
||
+ | |||
+ | Mount the partition to {{ic|/mnt/boot}}: |
||
+ | |||
+ | # mount /dev/mapper/''cryptboot'' /mnt/boot |
||
+ | |||
+ | Create a mountpoint for the [[Unified_Extensible_Firmware_Interface#EFI_System_Partition|ESP]] at {{ic|/boot/efi}} for compatibility with {{ic|grub-install}} and mount it: |
||
+ | |||
+ | # mkdir /mnt/boot/efi |
||
+ | # mount /dev/''sdaX'' /mnt/boot/efi |
||
+ | |||
+ | At this point, you should have the following partitions and logical volumes inside of {{ic|/mnt}}: |
||
+ | {{hc|lsblk| |
||
+ | NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT |
||
+ | sda 8:0 0 200G 0 disk |
||
+ | ├─sda1 8:1 0 512M 0 part /boot/efi |
||
+ | ├─sda2 8:2 0 200M 0 part |
||
+ | │ └─boot 254:0 0 198M 0 crypt /boot |
||
+ | └─sda3 8:3 0 100G 0 part |
||
+ | └─lvm 254:1 0 100G 0 crypt |
||
+ | ├─MyStorage-swapvol 254:2 0 8G 0 lvm [SWAP] |
||
+ | ├─MyStorage-rootvol 254:3 0 15G 0 lvm / |
||
+ | └─MyStorage-homevol 254:4 0 77G 0 lvm /home |
||
+ | }} |
||
+ | |||
+ | Afterwards continue with the installation procedure up to the mkinitcpio step. |
||
+ | |||
+ | === mkinitcpio の設定 === |
||
+ | |||
+ | [[mkinitcpio|mkinitcpio.conf]] に {{ic|encrypt}} と {{ic|lvm2}} フックを追加: |
||
+ | {{hc|/etc/mkinitcpio.conf|2=HOOKS="... '''encrypt''' '''lvm2''' ... filesystems ..."}} |
||
+ | |||
+ | 詳細や必要な他のフックについては [[dm-crypt/システム設定#mkinitcpio]] を参照。 |
||
+ | |||
+ | === ブートローダーの設定 === |
||
+ | |||
+ | 起動時に暗号化された root パーティションの暗号化が解除されるように、以下のカーネルパラメータをブートローダーで設定します: |
||
+ | |||
+ | cryptdevice=/dev/''partition'':MyStorage root=/dev/mapper/MyStorage-rootvol |
||
+ | |||
+ | 詳しくは [[Dm-crypt/システム設定#ブートローダー]] を参照。 |
||
+ | |||
+ | Now we prepare the GRUB bootloader installation to recognize the LUKS encrypted {{ic|/boot}} partition according to [[GRUB#Boot partition]]. |
||
+ | |||
+ | {{ic|/etc/default/grub}} を開いてパラメーターを末端に追加: |
||
+ | |||
+ | {{ic|1=GRUB_ENABLE_CRYPTODISK=y}} |
||
+ | |||
+ | GRUB メニュー設定ファイルを作成: |
||
+ | |||
+ | # grub-mkconfig -o /boot/grub/grub.cfg |
||
+ | |||
+ | マウントされている ESP に [[GRUB#インストール|GRUB をインストール]]: |
||
+ | |||
+ | # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub --recheck |
||
+ | |||
+ | If this finished without errors, GRUB should prompt for the passphrase to unlock the {{ic|/boot}} partition after the next reboot. |
||
+ | |||
+ | === fstab と crypttab の設定 === |
||
+ | |||
+ | This section deals with extra configuration to let the system '''mount''' the encrypted {{ic|/boot}}. |
||
+ | |||
+ | While GRUB asks for a passphrase to unlock the encrypted {{ic|/boot}} after above instructions, the partition unlock is not passed on to the initramfs. Hence, {{ic|/boot}} will not be available after the system has re-/booted, because the {{ic|encrypt}} hook only unlocks the system's root. |
||
+ | |||
+ | If you used the ''genfstab'' script during installation, it will have generated {{ic|/etc/fstab}} entries for the {{ic|/boot}} and {{ic|/boot/efi}} mount points already, but the system will fail to find the generated device mapper for the boot partition. To make it available, add it to [[Dm-crypt/システム設定#crypttab|crypttab]]. For example: |
||
+ | |||
+ | {{hc|/etc/crypttab| |
||
+ | cryptboot /dev/sdaY none luks}} |
||
+ | |||
+ | will make the system ask for the passphrase again (i.e. you have to enter it twice at boot: once for GRUB and once for systemd init). To avoid the double entry for unlocking {{ic|/boot}}, follow the instructions at [[Dm-crypt/デバイスの暗号化#キーファイル]] to: |
||
+ | |||
+ | # Create a [[Dm-crypt/デバイスの暗号化#ファイルシステムにキーファイルを保存|randomtext keyfile]], |
||
+ | # Add the keyfile to the ({{ic|/dev/sdaY}}) [[Dm-crypt/デバイスの暗号化#キーファイルを使用するように LUKS を設定|boot partition's LUKS header]] and |
||
+ | # Check the {{ic|/etc/fstab}} entry and add the {{ic|/etc/crypttab}} line to [[Dm-crypt/デバイスの暗号化#起動時にロックを解除|unlock it automatically at boot]]. |
||
+ | |||
+ | If for some reason the keyfile fails to unlock the boot partition, systemd will fallback to ask for a passphrase to unlock and, in case that is correct, continue booting. |
||
+ | |||
+ | {{Tip|Optional post-installation steps: |
||
+ | * It may be worth considering to add the GRUB bootloader to the ignore list of {{ic|/etc/pacman.conf}} in order to take particular control of when the bootloader (which includes its own encryption modules) is updated. |
||
+ | * If you want to encrypt the {{ic|/boot}} partition to protect against offline tampering threats, the [[Dm-crypt/特記事項#mkinitcpio-chkcryptoboot|mkinitcpio-chkcryptoboot]] hook has been contributed to help.}} |
2015年8月20日 (木) 20:15時点における版
dm-crypt に戻る。
以下は dm-crypt を使って完全なシステム暗号化を行う一般的なシナリオの例です。通常のインストール手順に加える必要がある変更を全て説明しています。必要なツールは全て インストールイメージ に入っています。
目次
概要
root ファイルシステムの暗号化については機能やパフォーマンスの点で dm-crypt が優れています。システムの root ファイルシステムが dm-crypt デバイス上にあれば、システム上のほとんど全てのファイルが暗号化されます。root 以外のファイルシステムを選択的に暗号化するのと異なり、root ファイルシステムの暗号化は様々な情報を隠匿できます。インストールされているプログラム、ユーザーアカウントのユーザー名、mlocate や /var/log/
など媒介してデータ漏洩の恐れがあるファイルなど。さらに、root ファイルシステムを暗号化することでシステムの改竄が非常に難しくなります。ブートローダーやカーネルを除く全てが暗号化されるためです。
以上の利点をのぞく、それぞれのシナリオのメリットやデメリットなどの違いをまとめて、全てのシナリオを以下の表で説明します:
シナリオ | メリット | デメリット |
---|---|---|
#LUKS を使用するシンプルなパーティションレイアウト
LUKS で root を完全に暗号化するベーシックなセットアップ |
|
|
#LVM on LUKS
LUKS 暗号化パーティションの中で LVM を使うことでパーティショニングの柔軟性を確保 |
|
|
#LUKS on LVM
LVM をセットアップした後に dm-crypt を使用 |
|
|
#Plain dm-crypt
dm-crypt の plain モードを使用、LUKS ヘッダーや LUKS の複数のキーのオプションは使わない |
|
|
#boot パーティションの暗号化 (GRUB)
GRUB ブートローダーを使って boot パーティションを暗号化する方法を説明します。 |
|
|
上記全てのシナリオが外部からの脅威に対して十分な保護を約束しますが、共通の欠点も存在します。暗号化キーを持っているユーザーなら誰でもデバイスの全てを復号化して、他のユーザーのデータにもアクセスすることが可能という点です。これが問題だという場合は、ブロックデバイスの暗号化とスタックファイルシステムの暗号化と組み合わせて使用することで、両者の利点を取り入れることができます。ディスク暗号化を見て下さい。
他にも、スワップパーティションの暗号化を設定するべきかどうか考慮する必要があります。Dm-crypt/スワップの暗号化を見て下さい。
シナリオで使用されているパーティショニングの外観について Dm-crypt/ドライブの準備#パーティショニング も参照してください。
LUKS を使用するシンプルなパーティションレイアウト
この例ではシンプルなパーティションレイアウトによる 'dmcrypt+ LUKS のフルシステム暗号化を説明します:
+--------------------+--------------------------+--------------------------+ |Boot partition |LUKS encrypted system |Optional free space | | |partition |for additional partitions | |/dev/sdaY |/dev/sdaX |or swap to be setup later | +--------------------+--------------------------+--------------------------+
最初のステップは Arch Linux のインストールイメージを起動した後すぐに実行します。
ディスクの準備
パーティションを作成する前に、Dm-crypt/ドライブの準備 で説明されているように、ディスクを完全に消去する必要性・方法を学んでください。
それから必要なパーティションを作成します。最低でも /
が必要です (例: /dev/sdaX
) と /boot
(/dev/sdaY
)。パーティショニングを参照。
boot 以外のパーティションの準備
以下のコマンドは暗号化された root パーティションを作成・マウントします。Dm-crypt/root 以外のファイルシステムの暗号化#パーティション に詳しく説明されている手順に該当します (ページタイトルと相違して、mkinitcpio とブートローダーが正しく設定されていれば、root パーティションにも適用できます)。デフォルトになってない特定の暗号化オプションを使いたいときは (例: 暗号アルゴリズムや鍵長など)、最初のコマンドを実行する前に暗号化オプションを読んでください:
# cryptsetup -y -v luksFormat /dev/sdaX # cryptsetup open /dev/sdaX cryptroot # mkfs -t ext4 /dev/mapper/cryptroot # mount -t ext4 /dev/mapper/cryptroot /mnt
マッピングが問題ないかチェック:
# umount /mnt # cryptsetup close cryptroot # cryptsetup open /dev/sdaX cryptroot # mount -t ext4 /dev/mapper/cryptroot /mnt
パーティションを分割した場合 (例: /home
)、以上のコマンドを全てのパーティションに繰り返し実行してください。ただし /boot
は別です。起動時に追加のパーティションを扱う方法は Dm-crypt/root 以外のファイルシステムの暗号化#ロック解除とマウントの自動化 を見て下さい。
それぞれのブロックデバイスには個々のパスフレーズが必要になります。起動時に、別々のパスフレーズを入力しないといけないので、不便とも言えます。crypttab
を使うことでシステムパーティションにキーファイルを保存して使用することで別のパーティションを解錠することができます。方法は Dm-crypt/デバイスの暗号化#LUKS を使ってキーファイルでパーティションをフォーマット を見て下さい。
boot パーティションの準備
セットアップする必要があるのは暗号化されない /boot
パーティションで、暗号化する root に必要となります。例えば、標準的な MBR/BIOS の /boot
パーティションの場合、以下を実行します:
# mkfs -t ext4 /dev/sdaY # mkdir /mnt/boot # mount -t ext4 /dev/sdaY /mnt/boot
デバイスのマウント
インストールガイド#パーティションのマウントでは実際のパーティションではなく、マップされたデバイスをマウントしてください。もちろん、/boot
は暗号化されていないので、直接マウントします。
mkinitcpio の設定
encrypt
フックを mkinitcpio.conf 内の filesystems
の前に追加します:
etc/mkinitcpio.conf
HOOKS="... encrypt ... filesystems ..."
他に必要なフックについては dm-crypt/システム設定#mkinitcpio を見て下さい。
ブートローダーの設定
暗号化された root パーティションを起動するには、ブートローダーに以下のカーネルパラメータを設定する必要があります:
cryptdevice=/dev/sdaX:cryptroot
他に必要なパラメータについては Dm-crypt/システム設定#ブートローダー を見て下さい。
LVM on LUKS
The straight-forward method is to set up LVM on top of the encrypted partition instead of the other way round. Technically the LVM is setup inside one big encrypted blockdevice. Hence, the LVM is not transparent until the blockdevice is unlocked and the underlying volume structure is scanned and mounted during boot.
The disk layout in this example is:
+------------------------------------------------------------------------------------+ +----------------+ |Logical volume1 | Logical volume2 | Logical volume3 | | | |/dev/MyStorage/swapvol | /dev/MyStorage/rootvol | /dev/MyStorage/homevol | | Boot partition | |_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _| | (may be on | | | | other device) | | LUKS encrypted partition | | | | /dev/sdaX | | /dev/sdbY | +------------------------------------------------------------------------------------+ +----------------+
This method does not allow you to span the logical volumes over multiple disks, even in the future. The #LUKS on LVM method does not have this limitation.
ディスクの準備
パーティションを作成する前に、Dm-crypt/ドライブの準備 で説明されているように、ディスクを完全に消去する必要性・方法を学んでください。
GPT で GRUB ブートローダーを使う時は、GRUB#BIOS システム で説明されているように BIOS Boot Partition を作成してください。
Create a partition to be mounted at /boot
of type 8300
with a size of 100 MB or more.
Create a partition of type 8E00
, which will later contain the encrypted container.
Create the LUKS encrypted container at the "system" partition. Enter the chosen password twice.
# cryptsetup luksFormat /dev/sdaX
cryptsetup のオプションについては LUKS 暗号化のオプションを見て下さい。
Open the container:
# cryptsetup open --type luks /dev/sdaX lvm
The decrypted container is now available at /dev/mapper/lvm
.
論理ボリュームの準備
Create a physical volume on top of the opened LUKS container:
# pvcreate /dev/mapper/lvm
MyStorage
という名前のボリュームグループを作成して、先に作成した物理ボリュームを追加:
# vgcreate MyStorage /dev/mapper/lvm
ボリュームグループに論理ボリュームを作成:
# lvcreate -L 8G MyStorage -n swapvol # lvcreate -L 15G MyStorage -n rootvol # lvcreate -l +100%FREE MyStorage -n homevol
論理ボリュームのファイルシステムをフォーマット:
# mkfs.ext4 /dev/mapper/MyStorage-rootvol # mkfs.ext4 /dev/mapper/MyStorage-homevol # mkswap /dev/mapper/MyStorage-swapvol
ファイルシステムをマウント:
# mount /dev/MyStorage/rootvol /mnt # mkdir /mnt/home # mount /dev/MyStorage/homevol /mnt/home # swapon /dev/MyStorage/swapvol
boot パーティションの準備
The bootloader loads the kernel, initramfs, and its own configuration files from the /boot
directory. This directory must be located on a separate unencrypted filesystem.
/boot
にするパーティションに Ext2 ファイルシステムを作成します。ブートローダーが読み込めるファイルシステムなら何でもかまいません。
# mkfs.ext2 /dev/sdbY
/mnt/boot
ディレクトリを作成:
# mkdir /mnt/boot
パーティションを /mnt/boot
にマウント:
# mount /dev/sdbY /mnt/boot
Aftwards continue with the installation procedure up to the mkinitcpio step.
mkinitcpio の設定
encrypt
と lvm2
フックを mkinitcpio.conf 内の filesystems
の前に追加します:
/etc/mkinitcpio.conf
HOOKS="... encrypt lvm2 ... filesystems ..."
他に必要なフックについては dm-crypt/システム設定#mkinitcpio を見て下さい。
ブートローダーの設定
起動時に暗号化された root パーティションの暗号化が解除されるように、以下のカーネルパラメータをブートローダーで設定します:
cryptdevice=/dev/partition:MyStorage root=/dev/mapper/MyStorage-rootvol
詳しくは Dm-crypt/システム設定#ブートローダー を見て下さい。
LUKS on LVM
LVM 上で暗号化を利用するには、まず LVM ボリュームをセットアップして、それから暗号化パーティションのベースとして使うことになります。この方法では、暗号化パーティションと非暗号化パーティションのミックスが可能です。#LVM on LUKS とは違って、複数のディスクにまたがるような通常の論理ボリュームは使えません。
The following short example creates a LUKS on LVM setup and mixes in the use of a key-file for the /home partition and temporary crypt volumes for /tmp
and /swap
. The latter is considered desirable from a security perspective, because no potentially sensitive temporary data survives the reboot, when the encryption is re-initialised. If you are experienced with LVM, you will be able to ignore/replace LVM and other specifics according to your plan. If you want to span a logical volume over multiple disks during setup already, a procedure to do so is described in Dm-crypt/特記事項#LVM を複数のディスクに拡張.
ディスクの準備
Partitioning scheme:
/dev/sda1
->/boot
/dev/sda2
-> LVM
Dm-crypt/ドライブの準備#インストール前に dm-crypt で消去を見て /dev/sda2
をランダム化してください。
論理ボリュームの準備
# lvm pvcreate /dev/sda2 # lvm vgcreate lvm /dev/sda2 # lvm lvcreate -L 10G -n lvroot lvm # lvm lvcreate -L 500M -n swap lvm # lvm lvcreate -L 500M -n tmp lvm # lvm lvcreate -l 100%FREE -n home lvm
# cryptsetup luksFormat -c aes-xts-plain64 -s 512 /dev/lvm/lvroot # cryptsetup open --type luks /dev/lvm/lvroot root # mkfs -t ext4 /dev/mapper/root # mount /dev/mapper/root /mnt
Note that /home
will be encrypted later in this example. Further, note that if you ever have to access the encrypted root from the Arch-ISO, the above open
action will allow you to after the LVM shows up.
boot パーティションの準備
# dd if=/dev/zero of=/dev/sda1 bs=1M # mkfs -t ext4 /dev/sda1 # mkdir /mnt/boot # mount /dev/sda1 /mnt/boot
Now after setup of the encrypted LVM partitioning, it would be time to install: Arch Install Scripts.
mkinitcpio の設定
encrypt
と lvm2
フックを mkinitcpio.conf 内の filesystems
の前に追加します:
etc/mkinitcpio.conf
HOOKS="... lvm2 encrypt ... filesystems ..."
他に必要なフックについては dm-crypt/システム設定#mkinitcpio を見て下さい。
ブートローダーの設定
上の例の場合、ブートローダーの設定で root デバイスのカーネルオプションを以下のように変更します:
cryptdevice=/dev/lvm/lvroot:root root=/dev/mapper/root
詳しくは Dm-crypt/システム設定#ブートローダー を見て下さい。
fstab と crypttab の設定
/etc/fstab
/dev/mapper/root / ext4 defaults 0 1 /dev/sda1 /boot ext4 defaults 0 2 /dev/mapper/tmp /tmp tmpfs defaults 0 0 /dev/mapper/swap none swap sw 0 0
以下の crypttab オプションは再起動するたびに一時ファイルシステムを暗号化します:
/etc/crypttab
swap /dev/lvm/swap /dev/urandom swap,cipher=aes-xts-plain64,size=256 tmp /dev/lvm/tmp /dev/urandom tmp,cipher=aes-xts-plain64,size=256
論理ボリューム /home の暗号化
Since this scenario uses LVM as the primary and dm-crypt as secondary mapper, each encrypted logical volume requires its own encryption. Yet, unlike the temporary filesystems configured with volatile encryption above, the logical volume for /home
should be persistent, of course. The following assumes you have rebooted into the installed system, otherwise you have to adjust paths.
To safe on entering a second passphrase at boot for it, a keyfile is created:
mkdir -m 700 /etc/luks-keys dd if=/dev/random of=/etc/luks-keys/home bs=1 count=256
論理ボリュームは以下のように暗号化します:
cryptsetup luksFormat -v -s 512 /dev/lvm/home /etc/luks-keys/home cryptsetup -d /etc/luks-keys/home open --type luks /dev/lvm/home home mkfs -t ext4 /dev/mapper/home mount /dev/mapper/home /home
暗号化されたマウントは crypttab で設定します:
/etc/crypttab
home /dev/lvm/home /etc/luks-keys/home
/etc/fstab
/dev/mapper/home /home ext4 defaults 0 2
これでセットアップは完了です。 and setup is done.
If you want to expand the logical volume for /home
(or any other volume) at a later point, it is important to note that the LUKS encrypted part has to be resized as well. For a procedure see Dm-crypt/特記事項#LVM を複数のディスクに拡張.
Plain dm-crypt
This scenario sets up a system on a dm-crypt a full disk with plain mode encryption. Note that for most use cases, the methods using LUKS described above are the better options for both system encryption and encrypted partitions. LUKS features like key management with multiple pass-phrases/key-files are unavailable with plain mode.
dm-crypt plain mode does not require a header on the encrypted disk: this means that an unpartitioned, encrypted disk will be indistinguishable from a disk filled with random data, which is the desired attribute for this scenario, see also Wikipedia:Deniable encryption.
Plain dm-crypt encrypted disks can be more resilient to damage than LUKS encrypted disks, because it does not rely on an encryption master-key which can be a single-point of failure if damaged. However, using plain mode also requires more manual configuration of encryption options to achieve the same cryptographic strength. See also ディスク暗号化#暗号メタデータ.
The scenario uses a USB stick for the boot device and another one to store the encryption key. The disk layout is:
|--------------------+------------------+--------------------+ +---------------+ +---------------+ |Volume 1: |Volume 2: |Volume 3: | |Boot device | |Encryption key | | | | | | | |file storage | |root |swap |home | |/boot | |(unpartitioned | | | | | | | |in example) | |/dev/store/root |/dev/store/swap |/dev/store/home | |/dev/sdY1 | |/dev/sdZ | |--------------------+------------------+--------------------| |---------------| |---------------| |disk drive /dev/sdaX encrypted using plain mode and LVM | |USB stick 1 | |USB stick 2 | +------------------------------------------------------------+ +---------------+ +---------------+
/boot
and the boot loader cannot be kept on the encrypted drive, or it will defeat the purpose of using plain mode for deniable encryption. This also allows storing the options required to open/unlock the plain encrypted device in the boot loader configuration, since typing them on each boot would be error prone.
This scenario also uses a key file, assuming it stored as raw bits on a second USB stick, so that to the eyes of an unaware attacker who might get the usbkey the encryption key will appear as random data instead of being visible as a normal file. See also Wikipedia:Security through obscurity, follow Dm-crypt/デバイスの暗号化#キーファイル to prepare the keyfile.
ディスクの準備
It is vital that the mapped device is filled with data. In particular this applies to the scenario usecase we apply here.
Dm-crypt/ドライブの準備 や Dm-crypt/ドライブの準備#dm-crypt 固有の方法 を見て下さい。
boot 以外のパーティションの準備
詳しくは Dm-crypt/デバイスの暗号化#plain モードの暗号化オプション を参照。
Using the device /dev/sdX
, with the twofish-xts cipher with a 512 bit key size and using a keyfile we have the following options for this scenario:
# cryptsetup --hash=sha512 --cipher=twofish-xts-plain64 --offset=0 --key-file=/dev/sdZ --key-size=512 open --type=plain /dev/sdX enc
Unlike encrypting with LUKS, the above command must be executed in full whenever the mapping needs to be re-established, so it is important to remember the cipher, hash and key file details.
We can now check a mapping entry has been made for /dev/mapper/enc
:
# fdisk -l
Next, we setup LVM logical volumes on the mapped device, see LVM#Arch Linux を LVM にインストールする for further details:
# pvcreate /dev/mapper/enc # vgcreate store /dev/mapper/enc # lvcreate -L 20G store -n root # lvcreate -L 10G store -n swap # lvcreate -l +100%FREE store -n home
論理ボリュームをフォーマットしてマウントします。詳しくはファイルシステム#デバイスのフォーマットを見て下さい
# mkfs.ext4 /dev/store/root # mkfs.ext4 /dev/store/home # mount /dev/store/root /mnt # mkdir /mnt/home # mount /dev/store/home /mnt/home # mkswap /dev/store/swap # swapon /dev/store/swap
boot パーティションの準備
The /boot
partition can be installed on the standard vfat partition of a USB stick, if required. But if manual partitioning is needed, then a small 200MB partition is all that is required. Create the partition using a partitioning tool of your choice.
We choose a non-journalling file system to preserve the flash memory of the /boot
partition, if not already formatted as vfat:
# mkfs.ext2 /dev/sdY1 # mkdir /mnt/boot # mount /dev/sdY1 /mnt/boot
mkinitcpio の設定
encrypt
と lvm2
フックを mkinitcpio.conf 内の filesystems
の前に追加します:
etc/mkinitcpio.conf
HOOKS="... encrypt lvm2 ... filesystems ..."
他に必要なフックについては dm-crypt/システム設定#mkinitcpio を見て下さい。
ブートローダーの設定
In order to boot the encrypted root partition, the following kernel parameters need to be set by the boot loader:
cryptdevice=/dev/sdX:enc cryptkey=/dev/sdZ:0:512 crypto=sha512:twofish-xts-plain64:512:0:
他に必要なパラメータについては Dm-crypt/システム設定#ブートローダー を見て下さい。
インストール後
You may wish to remove the USB sticks after booting. Since the /boot
partition is not usually needed, the noauto
option can be added to the relevant line in /etc/fstab
:
/etc/fstab
# /dev/sdYn /dev/sdYn /boot ext2 noauto,rw,noatime 0 2
However, when an update to the kernel or bootloader is required, the /boot
partition must be present and mounted. As the entry in fstab
already exists, it can be mounted simply with:
# mount /boot
boot パーティションの暗号化 (GRUB)
This setup utilizes the same partition layout and configuration for the system's root partition as the previous #LVM on LUKS section, with two distinct differences:
- The setup is performed for an UEFI system and
- A special feature of the GRUB bootloader is used to additionally encrypt the boot partition
/boot
. See also GRUB#Boot partition.
The disk layout in this example is:
+---------------+----------------+----------------+----------------+----------------+ |ESP partition: |Boot partition: |Volume 1: |Volume 2: |Volume 3: | | | | | | | |/boot/efi |/boot |root |swap |home | | | | | | | | | |/dev/store/root |/dev/store/swap |/dev/store/home | |/dev/sdaX |/dev/sdaY +----------------+----------------+----------------+ |unencrypted |LUKS encrypted |/dev/sdaZ encrypted using LVM on LUKS | +---------------+----------------+--------------------------------------------------+
ディスクの準備
Prior to creating any partitions, you should inform yourself about the importance and methods to securely erase the disk, described in Dm-crypt/ドライブの準備.
Create an EFI System Partition (ESP) with an appropriate size, it will later be mounted at /boot/efi
.
Create a partition to be mounted at /boot
of type 8300
with a size of 100 MB or more.
Create a partition of type 8E00
, which will later contain the encrypted container.
Create the LUKS encrypted container at the "system" partition.
# cryptsetup luksFormat /dev/sdaZ
For more information about the available cryptsetup options see the LUKS encryption options prior to above command.
Your partition layout should look similar to this:
gdisk /dev/sda
Number Start (sector) End (sector) Size Code Name 1 2048 1050623 512.0 MiB EF00 EFI System 2 1050624 1460223 200.0 MiB 8300 Linux filesystem 3 1460224 41943006 19.3 GiB 8E00 Linux LVM
Open the container:
# cryptsetup open --type luks /dev/sdaZ lvm
The decrypted container is now available at /dev/mapper/lvm
.
論理ボリュームの準備
The LVM logical volumes of this example follow the exact layout as the previous scenario. Therefore, please follow Preparing the logical volumes above or adjust as required.
boot パーティションの準備
The bootloader loads the kernel, initramfs, and its own configuration files from the /boot
directory.
First, create the LUKS container where the files will be located and installed into:
# cryptsetup luksFormat /dev/sdaY
Next, open it:
# cryptsetup open /dev/sdaY cryptboot
Create a filesystem on the partition intended for /boot
. Any filesystem that can be read by the bootloader is eligible:
# mkfs.ext2 /dev/mapper/cryptboot
Create the directory /mnt/boot
:
# mkdir /mnt/boot
Mount the partition to /mnt/boot
:
# mount /dev/mapper/cryptboot /mnt/boot
Create a mountpoint for the ESP at /boot/efi
for compatibility with grub-install
and mount it:
# mkdir /mnt/boot/efi # mount /dev/sdaX /mnt/boot/efi
At this point, you should have the following partitions and logical volumes inside of /mnt
:
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi ├─sda2 8:2 0 200M 0 part │ └─boot 254:0 0 198M 0 crypt /boot └─sda3 8:3 0 100G 0 part └─lvm 254:1 0 100G 0 crypt ├─MyStorage-swapvol 254:2 0 8G 0 lvm [SWAP] ├─MyStorage-rootvol 254:3 0 15G 0 lvm / └─MyStorage-homevol 254:4 0 77G 0 lvm /home
Afterwards continue with the installation procedure up to the mkinitcpio step.
mkinitcpio の設定
mkinitcpio.conf に encrypt
と lvm2
フックを追加:
/etc/mkinitcpio.conf
HOOKS="... encrypt lvm2 ... filesystems ..."
詳細や必要な他のフックについては dm-crypt/システム設定#mkinitcpio を参照。
ブートローダーの設定
起動時に暗号化された root パーティションの暗号化が解除されるように、以下のカーネルパラメータをブートローダーで設定します:
cryptdevice=/dev/partition:MyStorage root=/dev/mapper/MyStorage-rootvol
詳しくは Dm-crypt/システム設定#ブートローダー を参照。
Now we prepare the GRUB bootloader installation to recognize the LUKS encrypted /boot
partition according to GRUB#Boot partition.
/etc/default/grub
を開いてパラメーターを末端に追加:
GRUB_ENABLE_CRYPTODISK=y
GRUB メニュー設定ファイルを作成:
# grub-mkconfig -o /boot/grub/grub.cfg
マウントされている ESP に GRUB をインストール:
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub --recheck
If this finished without errors, GRUB should prompt for the passphrase to unlock the /boot
partition after the next reboot.
fstab と crypttab の設定
This section deals with extra configuration to let the system mount the encrypted /boot
.
While GRUB asks for a passphrase to unlock the encrypted /boot
after above instructions, the partition unlock is not passed on to the initramfs. Hence, /boot
will not be available after the system has re-/booted, because the encrypt
hook only unlocks the system's root.
If you used the genfstab script during installation, it will have generated /etc/fstab
entries for the /boot
and /boot/efi
mount points already, but the system will fail to find the generated device mapper for the boot partition. To make it available, add it to crypttab. For example:
/etc/crypttab
cryptboot /dev/sdaY none luks
will make the system ask for the passphrase again (i.e. you have to enter it twice at boot: once for GRUB and once for systemd init). To avoid the double entry for unlocking /boot
, follow the instructions at Dm-crypt/デバイスの暗号化#キーファイル to:
- Create a randomtext keyfile,
- Add the keyfile to the (
/dev/sdaY
) boot partition's LUKS header and - Check the
/etc/fstab
entry and add the/etc/crypttab
line to unlock it automatically at boot.
If for some reason the keyfile fails to unlock the boot partition, systemd will fallback to ask for a passphrase to unlock and, in case that is correct, continue booting.