#author("2022-07-24T18:00:56+09:00","","")
*Arch Linux メモ - Install (MBR 暗号化版) [#dd4201e7]
基本的にMBR起動で、かつ暗号化パーティションを用いたものになっています。
-boot パーティションは暗号化してはいけないため、 /dev/sda1 に /boot (ext4) の非暗号化パーティションを用意します
**キーボード/時刻設定 [#c71bb05c]
EFI / BIOS 通常ブートと共通です。
# loadkeys jp106
(日本語キー設定)
# timedatectl set-ntp true
(NTP同期スタート)
# timedatectl set-timezone Asia/Tokyo
(EFI/BIOS時刻を日本時間準拠に)
# timedatectl status
(日本時間設定とNTP同期ONの確認)
**パーティション確保 [#d191ca2d]
ディスクの抹消方法については省略します。wipe-out とか使うといいんじゃないかな。または dd で urandom のデータで上書きしまくるとか。 >実機
# fdisk -l
(ディスク構成確認)
# fdisk /dev/sda
(下記ログはサンプルです。80GB程度のHDDを想定しています)
Command (m for help) : o (※G小文字でGPT オー小文字でDOS/MBRになります)
Command (m for help) : n
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-167772159, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-167772159, default 167772159): +512M
Created a new partition 1 of type 'Linux' and of size 512 MiB.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (1050624-167772159, default 1050624):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-167772159, default 167772159): +64G
Created a new partition 2 of type 'Linux' and of size 64 GiB.
Command (m for help): a
Partition number (1-2, default 2): 1
Command (m for help): p
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Disk model: XXXXXXXX
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xdeadbeef
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 1050623 1048576 512M 83 Linux
/dev/sda2 1050624 135268351 134217728 64G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
基本的には sda1 に boot 用 512MB を作ってる、sda3のswapを省略してる以外はBIOSブートと同じ。
**暗号化して初期化 [#nfc468c6]
-sda2 暗号化
# cryptsetup -v --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/sda2
WARNING!
========
This will overwrite data on /dev/sda2 irrevocably.
Are you sure? (Type 'yes' in capital letters):
( *** YES と「大文字で」入力 *** )
Enter passphrase for /dev/sda2:
Verify passphrase:
Key slot 0 created.
Command successful.
#
-sda1,sda3(通常初期化)とsda2(暗号化初期化)
# mkfs.ext4 /dev/sda1
# mkswap /dev/sda3
# swapon /dev/sda3
( *** sda3 に関しては mkswap / swapon を省略しても良い (メモリ内容がダンプされうるので)
# cryptsetup open --type luks /dev/sda2 cryptroot
cryptsetup open --type luks /dev/sda2 cryptroot
Enter passphrase for /dev/sda2:
# mkfs.ext4 /dev/mapper/cryptroot
(sda2 は cryptroot に転写されるのでそこを初期化)
# mount /dev/mapper/cryptroot /mnt
# mkdir -p /mnt/boot
# mount /dev/sda1 /mnt/boot
( /mnt に暗号化パーティションの雛形をつくる)
**基本システムのインストール without ブート構成 + パーティション構成保存 [#m91972b7]
EFI/BIOSバージョンと基本的には共通
# cd /etc/pacman.d/
# ls
# mv mirrorlist mirrorlist.org
# reflector | grep .jp > ./mirrorlist
# vim ./mirrorlist
(juniorjpdj.pl 鯖の行を全部削除、.jp ドメインだけにする)
# pacstrap /mnt base linux linux-firmware
Linux本体を /mnt に放り込むおまじない
# genfstab -U /mnt >>/mnt/etc/fstab
fstabにsda1+2のパーティション情報保存 (BIOS版と異なり、暗号化されていない boot パーティション sda1 があることに注意)
**暗号化パーティション対応ブートの登録 [#tdc8f243]
***最初に [#wd85cc57]
# arch-chroot /mnt
ルートが /mnt になる
# passwd
rootのパスワード登録(締め出し防止)
# pacman -S grub sudo openssh nano vim bash-completion networkmanager
Grub等をまとめて投入 ※grub以外は1stCustom の内容先取りしてます。
***GRUB編集 [#p9e7b69e]
# nano /etc/default/grub
( GRUB_CMDLINE_LINUX を検索、"" の中に...)
cryptdevice=/dev/sda2:cryptroot と追記する
# nano /etc/mkinitcpio.conf
(この行を)
HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)
(こういうふうに追記する。block / filesystems のまんなかに encrypt)
HOOKS=(base udev autodetect modconf block encrypt filesystems keyboard fsck)
# mkinitcpio -p linux
Image generation successful
# grub-install --target=i386-pc --recheck /dev/sda
(MBRにgrub登録。ここからは共通)
# grub-mkconfig -o /boot/grub/grub.cfg
(grubの設定ファイル書き出し)
***SWAP を / につくる [#l548e8c2]
# cd /
# dd bs=1024 count=4194304 if=/dev/zero of=/swap.img
# mkswap /swap.img
# chmod 600 /swap.img
# swapon /swap.img
#
# pacman -S arch-install-scripts
# genfstab -U / >> /etc/fstab
# vim /etc/fstab
(重複分削除)
# pacman -R arch-install-scripts
***あとしまつ [#h9ec9a70]
# swapoff --all
# exit
(chroot 終了)
# umount /mnt/boot
# umount /mnt
(アンマウント)
# cryptsetup close cryptroot
(暗号ディスクのクローズ)
**システム起動 [#yfd9964a]
A password is required to access the cryptroot volume:
Enter passphrase for /dev/sda2: _
ここで設定したパスワードをいれるとよい。あとは通常時と同じ。