2025年業務PCセットアップ
This content is a draft and will not be included in production builds.
最近は cat でいいらしい。
cat archlinux-2025.02.01-x86_64.iso /dev/disk/by-id/usb-xxxxrun0 sync従来の方法も使えるが遅い。
run0 dd bs=4M if=archlinux-2025.02.01-x86_64.iso of=/dev/sdc conv=fsync oflag=direct status=progressboot
iwctltimedatectl set-ntp true- nvme0n1p1 … EFI(ef00)
- nvme0n1p2 … LUKS “cryptswap” (8309)
- nvme0n1p3 … LUKS “cryptroot” (8309)
lsblk
mkfs.fat -F 32 /dev/nvme0n1p1
cryptsetup -y -v luksFormat /dev/nvme0n1p3cryptsetup open /dev/nvme0n1p3 cryptrootmkfs.btrfs -L rootfs /dev/mapper/cryptrootmount /dev/mapper/cryptroot /mntmount --mkdir /dev/nvme0n1p1 /mnt/boot
pacstrap /mnt base btrfs-progs linux linux-firmwaregenfstab -U /mnt >>/mnt/etc/fstabarch-chroot /mnt
pacman -S intel-ucode# amd-ucode
pacman -S iwd vibootctl --path=/boot installvi /boot/loader/entries/arch.confvi /boot/loader/loader.confvi /etc/fstabvi /etc/pacman.d/hooks/systemd-boot.hook
pacman -S --asdeps polkit # run0の実行等に必要
passwdsystemctl poweroffsystemctl enable fstrim.timersystemctl enable btrfs-scrub@-.timer
hostnamectl set-hostname lufia-pcvi /etc/systemd/network/20-wlan0.network # DHCP=yessystemctl enable --now iwd.servicesystemctl enable --now systemd-networkd.servicesystemctl enable --now systemd-resolved.serviceln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.confln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtimehwclock --systohctimedatectl set-ntp truevi /etc/systemd/timesyncd.conf
vi /etc/locale.genlocale-gen
systemctl enable --now systemd-homed.service# GUIが無い時に困るのでlocale.confではなくユーザーごとに--languageでロケールを設定する# システム全体で設定する場合はlocalectl set-locale LANG=en_US.UTF-8homectl create lufia --member-of=wheel --language=ja_JP.UTF-8pacman -S sudovisudo
# LidSwitchvi /etc/systemd/logind.confiwdは systemd-creds を使って暗号化プロファイルを作れるようになったらしい。試していない。
Secure sbctl の使い方はsbctlでセキュアブート環境を構築するに書いた。efibootmgr は使わないけれど、EFIエントリを操作するでみたように調査のため有用なので入れておく。
pacman -S sbctl efibootmgr
sbctl create-keyssbctl enroll-keys -msbctl verifysbctl sign -s FILE
vi /etc/pacman.d/hooks/systemd-boot.hookTPMと連携してパスフレーズ入力を省略する。BitLocker recovery: known issuesによると、WindowsのBitLockerはPCR7+11らしいので、それと同じでいいか。TPMが変化するときの計算式とイベントも書いた。
In its default configuration on such systems, BitLocker binds to PCR 7 and PCR 11 if PCR 7 and Secure Boot are correctly configured.
pacman -S tpm2-tools(optional) homectl update --member-of=wheel,input,tss lufiasystemd-cryptenroll /dev/nvme0n1p3 --tpm2-device=auto --tpm2-pcrs=7+11 [--wipe-slot=tpm2]vi /etc/mkinitcpio.confmkinitcpio -p linux[! Note] 今はsystemdに付属するコマンドで書いたように systemd-pcrlock を使う方が良いらしい?
更新するときはこっち
systemd-cryptenroll /dev/nvme0n1p3 --wipe-slot=tpm2 --tpm2-device=auto --tpm2-pcrs=7+11それぞれの機能が何を防ぐのかは暗号化やセキュアブートが何を防ぐのかでまとめた。
wire 各種firmwareを入れないとVAIO筐体から音が鳴らせなかった。
pacman -S alsa-firmware sof-firmwarepacman -S --asdeps pipewire-alsa pipewire-pulse [pipewire-jack]wpctl statuswpctl set-mute @DEFAULT_AUDIO_SINK@ togglewpctl set-mute @DEFAULT_AUDIO_SOURCE@ togglebluetooth
pacman -S bluez bluez-utilsvi /etc/bluetooth/main.conf
systemctl enable --now bluetooth.servicebluetoothctl
scan ondevicesconnect E3:xx # HHKB[agent] Passkey: 012345 # これをキーボードで入力sway
pacman -S sway wl-clipboardpacman -S --asdeps polkit waybar mako swaybg swayidle swaylock brightnessctlpacman -S --asdeps noto-fonts-cjk xorg-xwaylandpacman -S wofi slurpsystemctl --user enable --now mako.service
#pacman -S ibus-skk skk-jisyo ghosttypacman -S fcitx5-mozc ghosttyhomectl update lufia \ #--setenv GTK_IM_MODULE=ibus \ #--setenv XMODIFIERS=@im=ibus \ --setenv QT_IM_MODULE=fcitx # no 5 suffixcat /var/lib/systemd/home/$USER.identity#ibus-setup#ibus list-engine#ibus engine#ibus engine skk
# exec ibus-daemon --xim(-x) --daemonize(-d) -r# exec ibus-daemon -rxRd# https://wiki.archlinux.org/title/IBus
pacman -S xdg-desktop-portal-wlr
mkdir -p ~/.config/swaycp /etc/sway/config ~/.config/sway/firefox
pacman -S firefox-i18n-ja# MOZ_ENABLE_WAYLAND=1は不要
gsettings set org.gnome.desktop.interface gtk-key-theme Emacsxdg-settings set default-web-browser firefox.desktop# /usr/share/applications または .local/share/applications 以下のファイルswap
cryptsetup -y -v luksFormat /dev/nvme0n1p2cryptsetup open /dev/nvme0n1p2 cryptswapmkswap /dev/mapper/cryptswap
systemd-cryptenroll /dev/nvme0n1p2 --tpm2-device=auto --tpm2-pcrs=7+11 [--wipe-slot=tpm2]vi /boot/loader/entries/arch.conf# options luks.name=<uuid>=cryptswap# optionsは複数行書いても結合してくれるvi /etc/fstab# UUID=<uuid> none swap sw 0 0cryptroot のLUKSヘッダをバックアップしておく。cryptswap のほうは紛失しても困らない。
cryptsetup luksHeaderBackup /dev/nvme0n1p3 --header-backup-file luks-vaio.imggcc
pacman -S gcc makeiptables
cd dotfilesrun0 cp cfg/iptables/iptables.rules /etc/iptables/iptables.rulesrun0 systemctl enable --now iptables.service設定が正しいかどうかの確認はiptablesのconfigをテストする方法に書いた。
docker
pacman -S dockerpacman -Sd docker-buildxcommands
Section titled “commands”AUR
pacman -S fakeroot debugeditFlatpak
pacman -S git less go flatpakpacman -S xdg-desktop-portal-gtk # Slackに必要?# No such interface "org.freedesktop.portal.FileChooser" でエラーが出ていた
flatpak install com.slack.Slackflatpak install com.visualstudio.codeflatpak install com.google.Chrome # Slackに必要flatpak install md.obsidian.Obsidian
flatpak --user override --socket=wayland com.visualstudio.codeFlatpakのElectronアプリで日本語入力を行う方法
services
Section titled “services”- 1Password
- (Argent X)
- okta
- Slack
- GitHub
- gcloud
config
Section titled “config”mkdir ~/.local/share/backgroundslid:on/lid:off設定
settings
Section titled “settings”GOPATH=~ go install github.com/lufia/dotsync
git clone https://github.com/lufia/dotfiles.git
copy firefox bookmarks
create Obsidian Vault
run0 pacman -S udisks2# systemctl enable --now udisks2.service は不要
run0 pacman -S github-cli jqgh extension install lufia/gh-announce
# 既存の環境変数は/var/lib/systemd以下から読んで同じ値を設定するhomectl update lufia --setenv GNUPGHOME=$HOME/.local/share/gnupggpg
基本的にはGPG鍵束の復旧でマスターキー取り込みとサブキーの作成を行って、既存の鍵をGitHubにGPG鍵を登録するのように取り込めばいい。