はじめに
この記事はArch Linuxをインストールするための備忘録的なものです.同じような環境であれば参考になるはずです.
免責事項
本記事では情報の正確性を心がけていますが,完全な正確性を保証するものではありません.また,読者が本記事の内容を実行し損害が生じても,それに対する責任を筆者は一切負いません.すべて読者の自己責任でお願いいたします.
構成
- OS: Arch Linux
- Kernel: linux-lts
- デスクトップ環境: KDE Plasma
- スワップ領域: なし
- ルートファイルシステム: btrfs
- シングルブート
- dm-cryptによるデバイスの暗号化
- ブートローダ: systemd-boot
- ブート: UEFI
- CPU: Intel x86_64
- GPU: NVIDIA
- LAN接続: 無線
- USBドングル: TL-WN725N(チップセット: RTL8188EUS)
インストール
インストールメディアの作成
以下のリンクから所望のISOファイルをダウンロードし,インストールメディアを作成してください.
USBメモリを用いたインストールメディアの作成方法は以下のリンクを参考にしてください.
インストールメディアを作成し終わったら,インストールメディアからライブ環境を起動してください.
ライブ環境起動後
# loadkeys jp106
ワイヤレス設定
# ip l
1: lo: ...
2: enp3s0: <...,UP> ... state DOWN
3: wlan0: <...,UP> ... state DOWN
# iw dev
# iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: ...
ESSID: "MySSID"
...
IE: IEEE 802.11i/WPA2 ...
iw
ではインターフェイスが認識されていませんが,iwlist
(wireless_tools)では認識されています.よって,nl80211ドライバではなくWEXTドライバを用いる必要があります.また,所望のアクセスポイントはWPA2を用いて暗号化しているため,WEXTドライバとWPA2に対応しているwpa_supplicant
を使用してアクセスポイントに接続します.詳しくは以下のリンクを参照してください.
# vim /etc/wpa_supplicant/wifi.conf
network={
ssid="MySSID"
psk="MyPSK"
}
# wpa_supplicant -B -i wlan0 -D wext -c /etc/wpa_supplicant/wifi.conf
Successfully initialized wpa_supplicant
rfkill: Cannot get wiphy information
ioctl[SIOCSIWAP]: Operation not permitted
...
エラーメッセージが出力されましたが,実用上特に問題ないのでスルーします.
# ip a
...
3: wlan0: ... state UP
inet 192.168...
# ping archlinux.jp
PING archlinux.jp (...
64 bytes from ...
UEFIの確認
# ls /sys/firmware/efi/efivars
...
変数が多数見つかったので,UEFIで起動されていることがわかります.
パーティショニング
# ls -l /dev/disk/by-id
インストールしたいディスクを慎重に選んでください.以下では,インストールしたいディスクを/dev/sdaとします.
# cfdisk /dev/sda
また,メモリを20GB以上積んであるのでスワップ領域やスワップファイルは作成しません.
パーティション | マウントポイント | 容量 | タイプ |
---|---|---|---|
/dev/sda1 | /boot | 300MB | EFI System |
/dev/sda2 | / | 残りすべて | Linux Filesystem |
dm-cryptで/dev/sda2
を暗号化
# modprobe dm-crypt
# cryptsetup -v luksFormat -s 512 /dev/sda2
WARNING!
...
Are you sure? (Type...: YES
Enter passphrase ...: enter your password
Veryfy passphrase: enter same password
Key slot 0 created.
Command successful.
# cryptsetup open /dev/sda2 cryptroot
ファイルシステムでフォーマット
# mkfs.fat -F 32 /dev/sda1
# mkfs.btrfs /dev/mapper/cryptroot
マウント
# mount -o noatime,compress=lzo,ssd,discard /dev/mapper/cryptroot /mnt
# mkdir /mnt/boot
# mount /dev/sda1 /mnt/boot
pacman用ミラーリストを最適化
# vim /etc/pacman.d/mirrorlist
Server = https://mirrors.cat.net/archlinux/$repo/os/$arch
pacmanの設定
# vim /etc/pacman.conf
...
# Misc options
...
Color
...
ParallelDownloads = 5 #このパラメータを有効にするとダウンロードを5並列で行えます.
...
Arch Linuxのインストール
# pacstrap /mnt base base-devel linux-lts linux-lts-headers linux-firmware intel-ucode \
vim networkmanager git zsh dkms btrfs-progs
fstabを生成
# genfstab -U /mnt >> /mnt/etc/fstab
pacmanの設定を引き継ぎ
# cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
# vim /mnt/etc/pacman.conf
pacmanのバージョンによってconfファイルの仕様が変更されるかもしれないので,コピーせず直接編集します.
...
# Misc options
...
Color
...
ParallelDownloads = 5
...
システム設定
# arch-chroot /mnt
# ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
# hwclock --systohc
# vim /etc/locale.gen
...
en_US.UTF-8 UTF-8
...
ja_JP.UFT-8 UTF-8
...
# locale-gen
# echo LANG=en_US.UTF-8 > /etc/locale.conf
# echo KEYMAP=jp106 > /etc/vconsole.conf
# echo archlinux > /etc/hostname
# vim /etc/hosts
127.0.0.1 localhost archlinux
::1 localhost archlinux
# passwd
ユーザの追加
# useradd -D -s /bin/zsh
# useradd -m usr
# passwd usr
# visudo
...
Defaults rootpw
...
usr ALL=(ALL:ALL) ALL
...
RTL8188EUSドライバの更新
現在(2022/06/13),USBドングルのチップセットRTL8188EUS用ドライバはstaging treeに含まれており自分でドライバを導入せずとも使用できます.しかし,転送速度が著しく低下する問題(バグ?)が発生するため,最新のドライバを導入します.
# su - usr
$ git clone https://aur.archlinux.org/8188eu-aircrack-dkms-git.git
$ cd 8188eu-aircrack-dkms-git
$ makepkg -sri
$ cd ..
$ rm -rf 8188eu-aircrack-dkms-git
$ exit
Initramfs
起動時に暗号化されたデバイスを復号する必要があるため,次のようにフックを設定します.
# vim /etc/mkinitcpio.conf
...
HOOKS=(base udev autodetect modconf keyboard block encrypt filesystems fsck)
...
# mkinitcpio -P
ブートローダをインストール
本記事では,ブートローダとしてGRUBの代わりにsystemd-bootを用います.
# bootctl install
# vim /boot/loader/loader.conf
default arch
console-mode max
editor no
# vim /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux-lts
initrd /intel-ucode.img
initrd /initramfs-linux-lts.img
options cryptdevice=/dev/sda2:cryptroot root=/dev/mapper/cryptroot rw
chrootから抜け再起動
# exit
# reboot
Arch Linux自体のインストールはこれで終了です.
インストール後
システムを起動しシステム暗号化用のパスワードを入力します.
A password is ...
Enter passphrase for /dev/sda2: enter the password
usrとしてログインします.
archlinux login: usr
Password:
$ sudo systemctl enable systemd-boot-update
$ sudo systemctl enable NetworkManager
$ sudo systemctl start NetworkManager
$ sudo nmcli dev wifi connect MySSID password MyPSK
$ ping archlinux.jp
PING archlinux.jp (...
64 bytes from ...
Yayをインストール
$ sudo pacman -Syu
$ git clone https://aur.archlinux.org/yay.git
$ cd yay
$ makepkg -rsi
$ cd ..
$ rm -rf yay
デスクトップ環境とその他をインストール
- Xorg,SDDM,Plasma,KDE applications(必要なものだけ),Firefox,Alacritty,NVIDIAドライバ,Notoフォント,Fcitx+Mozc
$ yay
$ yay -S xorg sddm plasma-meta dolphin dragon okular ark gwenview kwalletmanager kate \
kcalc filelight firefox alacritty nvidia-lts noto-fonts noto-fonts-cjk \
noto-fonts-emoji fcitx5-im fcitx5-mozc
すべてEnter.NVIDIAドライバについては以下のリンク参照.
各種設定
$ sudo systemctl enable sddm
$ vim .xprofile
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
ビープ音を消す
$ sudo vim /etc/modprobe.d/nobeep.conf
blacklist pcspkr
ミラーリストを起動時に更新
$ sudo vim /etc/xdg/reflector/reflector.conf
--save /etc/pacman.d/mirrorlist
--protocol http,https
--country Japan
--latest 5
--sort rate
$ sudo systemctl enable reflector
$ reboot
SDDMにてusrとしてログイン
System Settings
Regional Settings
- Language
日本語
ロケール設定
$ localectl set-x11-keymap jp jp106
$ reboot
KWalletManager
- パスワードを変更
空白のままOK
KDEシステム設定
外観
- 起動フィードバック
Cursor: No Feedback - スプラッシュスクリーン
なし
ワークスペースの挙動
- 全体的な挙動
ファイルやフォルダをクリックした際の挙動: 選択する
ウインドウの操作
- ウインドウの挙動
- 詳細設定
Window placement: Minimal Overlapping
- 詳細設定
起動と終了
- ログイン画面(SDDM)
- Behavior
- Automatically log in: チェック
これにより,起動時にパスワードを一度入力するだけでログインできます.
- Automatically log in: チェック
- Behavior
地域の設定
- 入力メソッド
- 現在の入力メソッド
上から
キーボード - 日本語
Mozc
となるように設定します.
- 現在の入力メソッド
接続
- Wi-Fi
- Wi-Fi セキュリティ
- すべてのユーザにパスワードを保存(暗号化なし)->このユーザにのみパスワードを保存する(暗号化済み)
- Wi-Fi セキュリティ
Zsh+prezto
$ git clone git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
$ for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
$ vim .zpreztorc
長いので巻末に示します.
$ yay -S pkgfile
$ sudo pkgfile -u
$ vim .zshrc
...
source /usr/share/doc/pkgfile/command-not-found.zsh
参考
付録
.zpreztorc
#
# General
#
# Set case-sensitivity for completion, history lookup, etc.
# zstyle ':prezto:*:*' case-sensitive 'yes'
# Color output (auto set to 'no' on dumb terminals).
zstyle ':prezto:*:*' color 'yes'
# Add additional directories to load prezto modules from
# zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib
# Allow module overrides when pmodule-dirs causes module name collisions
# zstyle ':prezto:load' pmodule-allow-overrides 'yes'
# Set the Zsh modules to load (man zshmodules).
zstyle ':prezto:load' zmodule 'attr' 'stat'
# Set the Zsh functions to load (man zshcontrib).
zstyle ':prezto:load' zfunction 'zargs' 'zmv'
# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
'environment' \
'archive' \
'terminal' \
'editor' \
'history' \
'directory' \
'spectrum' \
'utility' \
'completion' \
'fasd' \
'history-substring-search' \
'git' \
'syntax-highlighting' \
'autosuggestions' \
'prompt' \
'pacman'
#
# Autosuggestions
#
# Set the query found color.
zstyle ':prezto:module:autosuggestions:color' found ''
#
# Completions
#
# Set the entries to ignore in static '/etc/hosts' for host completion.
# zstyle ':prezto:module:completion:*:hosts' etc-host-ignores \
# '0.0.0.0' '127.0.0.1'
#
# Editor
#
# Set the key mapping style to 'emacs' or 'vi'.
zstyle ':prezto:module:editor' key-bindings 'vi'
# Auto convert .... to ../..
zstyle ':prezto:module:editor' dot-expansion 'yes'
# Allow the zsh prompt context to be shown.
zstyle ':prezto:module:editor' ps-context 'yes'
#
# Git
#
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
zstyle ':prezto:module:git:status:ignore' submodules 'all'
#
# GNU Utility
#
# Set the command prefix on non-GNU systems.
# zstyle ':prezto:module:gnu-utility' prefix 'g'
#
# History
#
# Set the file to save the history in when an interactive shell exits.
# zstyle ':prezto:module:history' histfile "${ZDOTDIR:-$HOME}/.zsh_history"
# Set the maximum number of events stored in the internal history list.
# zstyle ':prezto:module:history' histsize 10000
# Set the maximum number of history events to save in the history file.
# zstyle ':prezto:module:history' savehist 10000
#
# History Substring Search
#
# Set the query found color.
zstyle ':prezto:module:history-substring-search:color' found ''
# Set the query not found color.
zstyle ':prezto:module:history-substring-search:color' not-found ''
# Set the search globbing flags.
zstyle ':prezto:module:history-substring-search' globbing-flags ''
#
# macOS
#
# Set the keyword used by `mand` to open man pages in Dash.app
# zstyle ':prezto:module:osx:man' dash-keyword 'manpages'
#
# Pacman
#
# Set the Pacman frontend.
zstyle ':prezto:module:pacman' frontend 'yay'
#
# Prompt
#
# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'paradox'
# Set the working directory prompt display length.
# By default, it is set to 'short'. Set it to 'long' (without '~' expansion)
# for longer or 'full' (with '~' expansion) for even longer prompt display.
zstyle ':prezto:module:prompt' pwd-length 'long'
# Set the prompt to display the return code along with an indicator for non-zero
# return codes. This is not supported by all prompts.
zstyle ':prezto:module:prompt' show-return-val 'yes'
#
# Python
#
# Auto switch the Python virtualenv on directory change.
# zstyle ':prezto:module:python:virtualenv' auto-switch 'yes'
# Automatically initialize virtualenvwrapper if pre-requisites are met.
# zstyle ':prezto:module:python:virtualenv' initialize 'yes'
#
# Ruby
#
# Auto switch the Ruby version on directory change.
# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'
#
# Screen
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:screen:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:screen:auto-start' remote 'yes'
#
# SSH
#
# Set the SSH identities to load into the agent.
# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github'
#
# Syntax Highlighting
#
# Set syntax highlighters.
# By default, only the main highlighter is enabled.
zstyle ':prezto:module:syntax-highlighting' highlighters \
'main' \
'brackets' \
'pattern' \
'line' \
'cursor' \
'root'
# Set syntax highlighting styles.
zstyle ':prezto:module:syntax-highlighting' styles \
'builtin' 'bg=blue' \
'command' 'bg=blue' \
'function' 'bg=blue'
# Set syntax pattern styles.
zstyle ':prezto:module:syntax-highlighting' pattern \
'rm*-rf*' 'fg=white,bold,bg=red'
#
# Terminal
#
# Auto set the tab and window titles.
zstyle ':prezto:module:terminal' auto-title 'yes'
# Set the window title format.
# zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s'
# Set the tab title format.
# zstyle ':prezto:module:terminal:tab-title' format '%m: %s'
# Set the terminal multiplexer title format.
# zstyle ':prezto:module:terminal:multiplexer-title' format '%s'
#
# Tmux
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:tmux:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'
# Integrate with iTerm2.
# zstyle ':prezto:module:tmux:iterm' integrate 'yes'
# Set the default session name:
# zstyle ':prezto:module:tmux:session' name 'YOUR DEFAULT SESSION NAME'
#
# Utility
#
# Enabled safe options. This aliases cp, ln, mv and rm so that they prompt
# before deleting or overwriting files. Set to 'no' to disable this safer
# behavior.
zstyle ':prezto:module:utility' safe-ops 'yes'