「システム暗号化の解除」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(英語版より新規作成)
 
(add TranslationStatus.)
(同じ利用者による、間の6版が非表示)
10行目: 10行目:
 
=== 概要 ===
 
=== 概要 ===
   
  +
データをバックアップして、再フォーマットされたデバイスに復元するほど安全ではありませんが、cryptsetup はデバイスから LUKS 暗号化をインプレースで永久に解除することを可能にします。例えば、LUKS 暗号化されたパーティションの中に ext4 ファイルシステムが存在する場合、インプレース復号化を行うと LUKS シグネチャが削除され、パーティション上に直接 ext4 ファイルシステムが配置され、直接マウントできるようになります。何も問題が発生しなければ、ファイルシステム内のファイルはそのまま維持されます。cryptsetup のドキュメントで使用されている用語は「復号化」とされています。
Although not as safe as backing up your data and restoring it on to a reformatted device,
 
cryptsetup does allow the user to permanently remove the LUKS encryption from a device in-place. For example, if you have an ext4 filesystem living inside a LUKS-encrypted partition,
 
performing in-place decryption will remove the LUKS signature, and place the ext4 filesystem
 
directly on the partition, so that you can mount it directly. Unless something goes wrong,
 
the files in the filesystem will remain intact. The terms used by cryptsetup's documentation for this is "decryption."
 
   
See the {{man|8|cryptsetup-reencrypt}} manual for the {{ic|--decrypt}} option.
+
{{man|8|cryptsetup-reencrypt}} マニュアルを参照して、{{ic|--decrypt}} オプションについて確認してください。
   
  +
LUKS1 デバイスの非破壊オフライン復号化は、2012年にリリースされた {{ic|cryptsetup}} バージョン 1.5.0 から利用可能になりました。LUKS1の復号化はオフラインモードでのみサポートされています。
Support for non-destructive offline decryption of LUKS1 devices has been available starting with {{ic|cryptsetup}} version 1.5.0, which was released in 2012. LUKS1 decryption is only supported for offline mode decryption.
 
   
  +
LUKS2 デバイスの場合、オフラインおよびオンライン(アンマウント不要)の復号化がサポートされています。
For LUKS2 devices, both offline and online (i.e. unmount not required) decryption are supported.
 
   
  +
{{Warning|以下の手順は本質的にリスキーであり、大規模なデータ損失を引き起こす可能性があります。復号化中の事故からデータを保護するために、常にドライブと LUKS ヘッダのバックアップを行ってください。}}
{{Warning|The procedures which follow are inherently risky and may cause catastrophic data loss. You should always backup your drive and LUKS header before proceeding, to protect your data from accidents during decryption.}}
 
   
=== Decrypting LUKS1 devices in-place ===
+
=== LUKS1 デバイスのインプレース復号化 ===
   
  +
LUKS1 デバイスの復号化はオフラインモードで行われます。つまり、開いてマウントしてはいけません。システムドライブを復号化したい場合は、[[USB インストールメディア|USB ライブ環境]]で再起動してください。それ以外の場合は、{{ic|unmount}} に続いて {{ic|cryptsetup close ''dm-name''}} を使用してください。
The decryption of a LUKS1 device is done in offline mode, i.e. it must not opened and mounted. If you want to decrypt the system drive, reboot into a [[USB flash installation medium|USB live environment]]. Otherwise, use {{ic|unmount}} followed by {{ic|cryptsetup close ''dm-name''}}.
 
   
  +
まず、{{ic|blkid}} または {{ic|lsblk}} を使用して ''device_path'' を特定します。
To start, identify the ''device_path'' using {{ic|blkid}} or {{ic|lsblk}}.
 
   
  +
次に、以下のコマンドで復号化を実行します:
Next, the following command performs the decryption:
 
   
 
{{bc|# cryptsetup reencrypt --decrypt ''device_path''
 
{{bc|# cryptsetup reencrypt --decrypt ''device_path''
 
Enter any existing passphrase:
 
Enter any existing passphrase:
Finished, time 02m05s, 19 GiB written, speed 162,6 MiB/s}}
+
Finished, time 02m05s, 19 GiB written, speed 162.6 MiB/s}}
   
  +
自動的に LUKS1 ヘッダーバージョンを識別し、開いているデバイスの場合は進行しません。プロセスには時間がかかることがありますが、進行状況のメーターが表示されます。問題が発生しなければ、デバイス上のファイルシステムを直接マウントできます。
It will automatically identify the LUKS1 header version and not proceed for an opened device. The process might take a while, but give a progress meter. If no problems occur, the filesystem on the device can immediately be mounted directly.
 
   
=== Decrypting LUKS2 devices in-place ===
+
=== LUKS2 デバイスのインプレース復号化 ===
   
  +
復号化は、{{ic|cryptsetup}} コマンドを使用して、オフラインまたはオンラインモードのいずれかで行うことができます。{{ic|cryptsetup}} バージョン 2.5.0 (2022) から、LUKS2 は LUKS2 ヘッダーを別のファイルに移行することによって復号化をサポートしています。
Decryption can be done in either offline or online mode, using the {{ic|cryptsetup}} command. Since {{ic|cryptsetup}} version 2.5.0 (2022) LUKS2 supports decryption by migrating LUKS2 header in a separate file.
 
   
  +
復号化の初期段階で、LUKS2 ヘッダーが移行される {{ic|''new_file''}} は存在してはいけません。
The {{ic|''new_file''}} to which the LUKS2 header will be migrated must not exist in the initialization phase of the decryption.
 
   
 
{{bc|# cryptsetup reencrypt --decrypt --header ''new_file'' ''device_path''}}
 
{{bc|# cryptsetup reencrypt --decrypt --header ''new_file'' ''device_path''}}
   
  +
{{Warning|エクスポートされたヘッダーは、インプレース復号化されるデバイスがホストするファイルシステムの外に配置する必要があります。そうでないとデッドロックが発生するか、復号化プロセスが中断された場合に再開することができません。}}
{{Warning|The exported header must be placed outside the filesystem hosted on the device that will be in-place decrypted. Otherwise deadlock can occur or in case the decryption process is interrupted it will not be possible to resume it.}}
 
   
  +
LUKS2 のインプレース復号化が中断された場合は、次のコマンドを発行するだけです:
To resume interrupted LUKS2 in-place decryption just issue following command:
 
   
 
# cryptsetup reencrypt --decrypt --resume-only --header ''migrated_header_file'' ''device_path''
 
# cryptsetup reencrypt --decrypt --resume-only --header ''migrated_header_file'' ''device_path''
   
  +
オンライン復号化が成功し、アクティブデバイス上で完了した場合、マップされたデバイスは遅延で非アクティブ化され、使用しなくなったときに自動的に線形マッピングが解除されます。その後、元の {{ic|''device_path''}} をデバイスマッパーマッピングなしで使用できます。
If the decryption was successfully finished on active device (online decryption), the mapped device will be lazy deactivated so that linear mapping is automatically removed when no longer used. Later the original {{ic|''device_path''}} can be used without device mapper mapping.
 
   
  +
{{Note|移行されたヘッダーを使用して中断された LUKS2 復号化デバイスは、cryptsetup バージョン < 2.5.0 では再開できません}}
{{Note|Device with interrupted LUKS2 decryption using migrated header to a file can not be resumed with cryptsetup version < 2.5.0}}
 
   
  +
=== システムファイルのクリーニング ===
=== Cleaning up system files ===
 
   
  +
復号化によりデバイス名や UUID が変更される可能性があり、関連する設定ファイルを更新する必要があります。更新が必要なファイルとしては、{{ic|/etc/crypttab}}, {{ic|/etc/fstab}}, および、最近復号化されたデバイスがカーネルコマンドライン上に表示された場合は、ブートローダーの設定(例:{{ic|/etc/default/grub}})があります。後者を編集する場合は、[[GRUB]]に記載されている通りに grub 設定を再生成することを忘れないでください。
Device names and UUIDs may change due to decryption, and you will likely need to update relevant configuration files. The files most likely to need updating are {{ic|/etc/crypttab}}, {{ic|/etc/fstab}} and, if your recently decrypted device appeared on the kernel command line, your bootloader's configuration (e.g, {{ic|/etc/default/grub}}). If you edit the latter, remember to regenerate the grub configuration as described in [[GRUB]].
 
   
  +
== バックアップ-フォーマット-復元による LUKS の削除 ==
== Removing LUKS via Backup-Format-Restore ==
 
   
=== Prerequisites ===
+
=== 必要条件 ===
   
  +
* 復号化したい暗号化されたルートファイルシステム。
*An encrypted root filesystem you wish to decrypt.
 
  +
* バックアップを保存するための十分なドライブスペース。
*Enough drive space to store a backup.
 
*An Arch Linux (or other) live CD/USB.
+
* Arch Linux(またはその他の)ライブCD/USB
  +
* 数時間。
*A few hours.
 
   
=== Boot into a live environment ===
+
=== ライブ環境にブート ===
   
  +
最新の Arch ISO を CD または USB にダウンロードして焼き、システムを再起動し、cd からブートします。
Download and burn the latest Arch ISO to a CD or USB, reboot the system, and boot to cd.
 
   
  +
=== パーティションのアクティブ化 ===
=== Activate partitions ===
 
   
  +
==== 異なるセットアップに関する注記 ====
{{Style|Hard to read, written like a blog post, misses some prompts.}}
 
   
  +
ここに示される例のセットアップは以下のとおりです:
==== Note about different setups ====
 
 
An example setup is shown here:
 
   
 
{| class="wikitable"
 
{| class="wikitable"
99行目: 93行目:
 
|}
 
|}
   
  +
グレーのパーティションは参照枠として無視できます。
The grey partition is a frame of reference and can be ignored.
 
  +
黄色のパーティションはストレージスペースとして使用され、必要に応じて変更可能です。
The yellow partition will be used as storage space and may be changed at will.
 
  +
緑のパーティションは変更されます。太字のテキストはシステムの設定に合わせてください。
The green partitions will be modified. Bold text must match your system's setup.
 
   
  +
例のシステムでは:
In the example system:
 
'''myvg''' contains lvs called '''cryptroot''' and '''cryptswap'''. They are located at {{ic|/dev/myvg/cryptroot}} and {{ic|/dev/myvg/cryptswap}}. Upon boot, LUKS is used along with a few crypttab entries to create {{ic|/dev/mapper/root}} and {{ic|/dev/mapper/swap}}.
+
'''myvg''' には '''cryptroot''' '''cryptswap''' と呼ばれる lvs が含まれています。これらは {{ic|/dev/myvg/cryptroot}} {{ic|/dev/myvg/cryptswap}} に位置しています。起動時に、LUKS といくつかの crypttab エントリを使用して {{ic|/dev/mapper/root}} {{ic|/dev/mapper/swap}} を作成します。
   
  +
このガイドの一環として、スワップの暗号化は解除されません。スワップの暗号化を解除するには複雑なバックアップや復元は必要ありません。
Swap will not be unencrypted as part of this guide, as undoing the swap encryption does not require any complex backup or restoration.
 
   
  +
例のシステムはすべてのシステムを示すものではありません。異なるファイルシステムはデータを効果的にバックアップおよび復元するために異なるツールを必要とします。LVM は使用されていない場合は無視できます。
The example system is not indicative of all systems. Different filesystems require different tools to effectively backup and restore their data. LVM can be ignored if not used.
 
   
  +
{{Note|XFS は効果的なバックアップと復元を確保するために ''xfs_copy'' を必要とします。''dd'' は不十分です。ext2、3、および 4 では ''dd'' を使用することができます。}}
{{Note|XFS requires ''xfs_copy'' to ensure an effective backup and restore, ''dd'' is insufficient. ''dd'' may be used with ext2, 3 and 4.}}
 
   
  +
==== パーティションが特定されたら ====
{{Expansion|What of jfs, reiserfs and reiser4fs?}}
 
   
  +
必要なモジュールをロードします。デバイスマッパー/LVM の場合:
==== Once partitions are located ====
 
 
Load necessary modules. For device mapper/LVM:
 
   
 
# modprobe dm-mod
 
# modprobe dm-mod
   
For LUKS:
+
LUKS の場合:
   
 
# modprobe dm-crypt
 
# modprobe dm-crypt
   
  +
物理ボリューム、ボリュームグループ、および論理ボリュームをスキャンします:
Scan for physical, volume and logical volumes:
 
   
 
# pvscan; vgscan; lvscan
 
# pvscan; vgscan; lvscan
   
  +
LVM ボリュームグループをアクティブにします:
Activate the LVM volume group:
 
   
 
# lvchange -ay '''myvg/cryptroot'''
 
# lvchange -ay '''myvg/cryptroot'''
   
  +
暗号化されたファイルシステムを LUKS で開き、読み取り可能にします:
Open the encrypted filesystem with LUKS so that it can be read:
 
   
 
# cryptsetup luksOpen '''/dev/myvg/cryptroot''' root
 
# cryptsetup luksOpen '''/dev/myvg/cryptroot''' root
   
  +
パスワードを入力します。
Enter password.
 
   
  +
{{Note|この時点で操作されるべきパーティションはバックアップパーティションのみです。バックアップパーティション以外のパーティションがすでにマウントされている場合、それを安全にアンマウントできます。}}
{{Note|The only partition that will be operated on that should be mounted at this point is the backup partition. If a partition other than the backup partition is already mounted, it can be safely umounted it now.}}
 
   
===== Mounting backup space =====
+
===== バックアップスペースのマウント =====
   
  +
バックアップに NTFS を使用する場合のみ、{{Pkg|ntfs-3g}} をインストールします。
Only if using NTFS to store the backup, install {{Pkg|ntfs-3g}}.
 
   
  +
バックアップストレージの次のステップが重要です。
The next step is important for backup storage.
 
   
 
# mount -t ntfs-3g -o rw /dev/sd''XY'' ''/mount/point/''
 
# mount -t ntfs-3g -o rw /dev/sd''XY'' ''/mount/point/''
   
  +
または、バックアップをリモートシステムに保存するために netcat を使用します。
or use netcat to store the backup on a remote system.
 
   
  +
=== データのバックアップ ===
{{Expansion|Add netcat instructions.}}
 
   
  +
''xfs_copy'' を使用して:
=== Backup data ===
 
 
Using ''xfs_copy'':
 
   
 
# xfs_copy -db '''/dev/mapper/root''' ''/mount/point/backup_root.img''
 
# xfs_copy -db '''/dev/mapper/root''' ''/mount/point/backup_root.img''
   
{{Note|The {{ic|-d}} flag preserves UUIDs and {{ic|-b}} ensures direct IO is not attempted to any of the target files.}}
+
{{Note|{{ic|-d}} フラグは UUID を保持し、{{ic|-b}} はターゲットファイルに直接 IO を試みないことを保証します。}}
   
  +
''dd'' を使用して:
Using ''dd'':
 
   
 
# dd if='''/dev/mapper/root''' of=''/mount/point/backup_root.img''
 
# dd if='''/dev/mapper/root''' of=''/mount/point/backup_root.img''
   
=== Undo encryption ===
+
=== 暗号化の解除 ===
   
  +
これは戻ることのできないポイントです。このステップに進む準備ができていることを確認してください。後でこれを元に戻す計画がある場合、ほぼ一から始めなければなりません。
This is the point of no return. Make sure that you are ready for this step. If you plan to undo this later, you will have to start almost from scratch.
 
   
 
# cryptsetup luksClose root
 
# cryptsetup luksClose root
 
# lvm lvremove '''myvg/cryptroot'''
 
# lvm lvremove '''myvg/cryptroot'''
   
=== Restore data ===
+
=== データの復元 ===
   
  +
新しい論理ボリュームを作成してルートファイルシステムを収容し、その後ファイルシステムを復元します。
We have to create a new logical volume to house our root filesystem, then we restore our filesystem.
 
   
 
# lvm lvcreate '''-l 100%FREE -n root myvg'''
 
# lvm lvcreate '''-l 100%FREE -n root myvg'''
 
# xfs_copy -db ''/mount/point/backup_root.img'' '''/dev/myvg/root'''
 
# xfs_copy -db ''/mount/point/backup_root.img'' '''/dev/myvg/root'''
   
  +
第二のドライブ名が変更されます。
The second drive name is changed now.
 
  +
  +
=== 設定の調整 ===
   
  +
システムにブートして、{{ic|/etc/crypttab}}, {{ic|/etc/mkinitcpio.conf}}, {{ic|/etc/fstab}}, および場合によっては {{ic|/boot/grub/menu.lst}} を編集する必要があります。
=== Adjust configurations ===
 
   
  +
{{TranslationStatus|Removing system encryption|2024-06-27|801297}}
You need to boot into your system and edit {{ic|/etc/crypttab}}, {{ic|/etc/mkinitcpio.conf}}, {{ic|/etc/fstab}}, and possibly {{ic|/boot/grub/menu.lst}}.
 

2024年6月27日 (木) 23:14時点における版

この記事あるいはセクションで使われている用語や表現には問題が存在します。
議論: written in first person, other style issues. (議論: トーク:システム暗号化の解除#)

dm-crypt と LUKSを使用してシステム暗号化を解除します。

LUKS暗号化のインプレース解除

概要

データをバックアップして、再フォーマットされたデバイスに復元するほど安全ではありませんが、cryptsetup はデバイスから LUKS 暗号化をインプレースで永久に解除することを可能にします。例えば、LUKS 暗号化されたパーティションの中に ext4 ファイルシステムが存在する場合、インプレース復号化を行うと LUKS シグネチャが削除され、パーティション上に直接 ext4 ファイルシステムが配置され、直接マウントできるようになります。何も問題が発生しなければ、ファイルシステム内のファイルはそのまま維持されます。cryptsetup のドキュメントで使用されている用語は「復号化」とされています。

cryptsetup-reencrypt(8) マニュアルを参照して、--decrypt オプションについて確認してください。

LUKS1 デバイスの非破壊オフライン復号化は、2012年にリリースされた cryptsetup バージョン 1.5.0 から利用可能になりました。LUKS1の復号化はオフラインモードでのみサポートされています。

LUKS2 デバイスの場合、オフラインおよびオンライン(アンマウント不要)の復号化がサポートされています。

警告: 以下の手順は本質的にリスキーであり、大規模なデータ損失を引き起こす可能性があります。復号化中の事故からデータを保護するために、常にドライブと LUKS ヘッダのバックアップを行ってください。

LUKS1 デバイスのインプレース復号化

LUKS1 デバイスの復号化はオフラインモードで行われます。つまり、開いてマウントしてはいけません。システムドライブを復号化したい場合は、USB ライブ環境で再起動してください。それ以外の場合は、unmount に続いて cryptsetup close dm-name を使用してください。

まず、blkid または lsblk を使用して device_path を特定します。

次に、以下のコマンドで復号化を実行します:

# cryptsetup reencrypt --decrypt device_path
Enter any existing passphrase: 
Finished, time 02m05s, 19 GiB written, speed 162.6 MiB/s

自動的に LUKS1 ヘッダーバージョンを識別し、開いているデバイスの場合は進行しません。プロセスには時間がかかることがありますが、進行状況のメーターが表示されます。問題が発生しなければ、デバイス上のファイルシステムを直接マウントできます。

LUKS2 デバイスのインプレース復号化

復号化は、cryptsetup コマンドを使用して、オフラインまたはオンラインモードのいずれかで行うことができます。cryptsetup バージョン 2.5.0 (2022) から、LUKS2 は LUKS2 ヘッダーを別のファイルに移行することによって復号化をサポートしています。

復号化の初期段階で、LUKS2 ヘッダーが移行される new_file は存在してはいけません。

# cryptsetup reencrypt --decrypt --header new_file device_path
警告: エクスポートされたヘッダーは、インプレース復号化されるデバイスがホストするファイルシステムの外に配置する必要があります。そうでないとデッドロックが発生するか、復号化プロセスが中断された場合に再開することができません。

LUKS2 のインプレース復号化が中断された場合は、次のコマンドを発行するだけです:

# cryptsetup reencrypt --decrypt --resume-only --header migrated_header_file device_path

オンライン復号化が成功し、アクティブデバイス上で完了した場合、マップされたデバイスは遅延で非アクティブ化され、使用しなくなったときに自動的に線形マッピングが解除されます。その後、元の device_path をデバイスマッパーマッピングなしで使用できます。

ノート: 移行されたヘッダーを使用して中断された LUKS2 復号化デバイスは、cryptsetup バージョン < 2.5.0 では再開できません

システムファイルのクリーニング

復号化によりデバイス名や UUID が変更される可能性があり、関連する設定ファイルを更新する必要があります。更新が必要なファイルとしては、/etc/crypttab, /etc/fstab, および、最近復号化されたデバイスがカーネルコマンドライン上に表示された場合は、ブートローダーの設定(例:/etc/default/grub)があります。後者を編集する場合は、GRUBに記載されている通りに grub 設定を再生成することを忘れないでください。

バックアップ-フォーマット-復元による LUKS の削除

必要条件

  • 復号化したい暗号化されたルートファイルシステム。
  • バックアップを保存するための十分なドライブスペース。
  • Arch Linux(またはその他の)ライブCD/USB。
  • 数時間。

ライブ環境にブート

最新の Arch ISO を CD または USB にダウンロードして焼き、システムを再起動し、cd からブートします。

パーティションのアクティブ化

異なるセットアップに関する注記

ここに示される例のセットアップは以下のとおりです:

Disk
NTFS myvg(lvm) NTFS
Other OS cryptswap(lv) cryptroot(lv) Shared
luks luks
swap root(xfs)

グレーのパーティションは参照枠として無視できます。 黄色のパーティションはストレージスペースとして使用され、必要に応じて変更可能です。 緑のパーティションは変更されます。太字のテキストはシステムの設定に合わせてください。

例のシステムでは: myvg には cryptrootcryptswap と呼ばれる lvs が含まれています。これらは /dev/myvg/cryptroot/dev/myvg/cryptswap に位置しています。起動時に、LUKS といくつかの crypttab エントリを使用して /dev/mapper/root/dev/mapper/swap を作成します。

このガイドの一環として、スワップの暗号化は解除されません。スワップの暗号化を解除するには複雑なバックアップや復元は必要ありません。

例のシステムはすべてのシステムを示すものではありません。異なるファイルシステムはデータを効果的にバックアップおよび復元するために異なるツールを必要とします。LVM は使用されていない場合は無視できます。

ノート: XFS は効果的なバックアップと復元を確保するために xfs_copy を必要とします。dd は不十分です。ext2、3、および 4 では dd を使用することができます。

パーティションが特定されたら

必要なモジュールをロードします。デバイスマッパー/LVM の場合:

# modprobe dm-mod 

LUKS の場合:

# modprobe dm-crypt

物理ボリューム、ボリュームグループ、および論理ボリュームをスキャンします:

# pvscan; vgscan; lvscan

LVM ボリュームグループをアクティブにします:

# lvchange -ay myvg/cryptroot

暗号化されたファイルシステムを LUKS で開き、読み取り可能にします:

# cryptsetup luksOpen /dev/myvg/cryptroot root

パスワードを入力します。

ノート: この時点で操作されるべきパーティションはバックアップパーティションのみです。バックアップパーティション以外のパーティションがすでにマウントされている場合、それを安全にアンマウントできます。
バックアップスペースのマウント

バックアップに NTFS を使用する場合のみ、ntfs-3g をインストールします。

バックアップストレージの次のステップが重要です。

# mount -t ntfs-3g -o rw /dev/sdXY /mount/point/

または、バックアップをリモートシステムに保存するために netcat を使用します。

データのバックアップ

xfs_copy を使用して:

# xfs_copy -db /dev/mapper/root /mount/point/backup_root.img
ノート: -d フラグは UUID を保持し、-b はターゲットファイルに直接 IO を試みないことを保証します。

dd を使用して:

# dd if=/dev/mapper/root of=/mount/point/backup_root.img

暗号化の解除

これは戻ることのできないポイントです。このステップに進む準備ができていることを確認してください。後でこれを元に戻す計画がある場合、ほぼ一から始めなければなりません。

# cryptsetup luksClose root
# lvm lvremove myvg/cryptroot

データの復元

新しい論理ボリュームを作成してルートファイルシステムを収容し、その後ファイルシステムを復元します。

# lvm lvcreate -l 100%FREE -n root myvg
# xfs_copy -db /mount/point/backup_root.img /dev/myvg/root

第二のドライブ名が変更されます。

設定の調整

システムにブートして、/etc/crypttab, /etc/mkinitcpio.conf, /etc/fstab, および場合によっては /boot/grub/menu.lst を編集する必要があります。

翻訳ステータス: このページは en:Removing system encryption の翻訳バージョンです。最後の翻訳日は 2024-06-27 です。もし英語版に 変更 があれば、翻訳の同期を手伝うことができます。