pockestrap

Programmer's memo

ThinkPad X1 ExtremeにArch Linuxをインストールする

備忘録

前回までのお話をだいたいそのままやっている。

https://pocke.hatenablog.com/entry/2016/06/18/180914

wifi

Wifiに接続

wifi-menu

SSH server を起動

SSH server を起動して、外からSSHしてインストール出来るようにする。
コマンドのコピペが効くので楽。

ついでにパスワードも設定しておく。

passwd
systectl start sshd

ip a で表示されたアドレスに対して、rootユーザーでsshをつなぐ。

時刻調整

timedatectl set-ntp true

パーティション、フォーマット

Windowsを消し飛ばすので注意

インストール対象のディスクを確認。今回は/dev/nvme0だった。いつもsdXだったから新鮮。

$ fdisk -l

パーティション作成

root@archiso ~ # gdisk /dev/nvme0 
GPT fdisk (gdisk) version 1.0.4

The specified path is a character device!
root@archiso ~ # gdisk /dev/nvme0n1 
GPT fdisk (gdisk) version 1.0.4

The protective MBR's 0xEE partition is oversized! Auto-repairing.

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): ?
b   back up GPT data to a file
c   change a partition's name
d   delete a partition
i   show detailed information on a partition
l   list known partition types
n   add a new partition
o   create a new empty GUID partition table (GPT)
p   print the partition table
q   quit without saving changes
r   recovery and transformation options (experts only)
s   sort partitions
t   change a partition's type code
v   verify disk
w   write table to disk and exit
x   extra functionality (experts only)
?   print this menu

Command (? for help): p
Disk /dev/nvme0n1: 2000409264 sectors, 953.9 GiB
Model: SAMSUNG MZVLB1T0HALR-000L7              
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 9D905CB8-0D4D-4B83-94BA-A1619719F61F
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 2000409230
Partitions will be aligned on 2048-sector boundaries
Total free space is 2669 sectors (1.3 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          534527   260.0 MiB   EF00  EFI system partition
   2          534528          567295   16.0 MiB    0C01  Microsoft reserved ...
   3          567296      1998360575   952.6 GiB   0700  Basic data partition
   4      1998360576      2000408575   1000.0 MiB  2700  Basic data partition

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-2000409230, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-2000409230, default = 2000409230) or {+-}size{KMGTP}: +512M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to 'EFI System'

Command (? for help): n
Partition number (2-128, default 2): 
First sector (34-2000409230, default = 1050624) or {+-}size{KMGTP}: 
Last sector (1050624-2000409230, default = 2000409230) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/nvme0n1: 2000409264 sectors, 953.9 GiB
Model: SAMSUNG MZVLB1T0HALR-000L7              
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): E083231A-9618-4D73-8FFF-30A378A13096
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 2000409230
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00  EFI System
   2         1050624      2000409230   953.4 GiB   8300  Linux filesystem

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.
The operation has completed successfully.

注意すべき点は、boot用パーティション+512M, ef00で作成すること。他はEnter連打でよい。

フォーマット

$ mkfs.fat -F32 /dev/nvme0n1p1
$ mkfs.ext4 /dev/nvme0n1p2

マウント

mkdir /mntがいつのまにかいらなくなっていた

root@archiso ~ # mount /dev/nvme0n1p2 /mnt
root@archiso ~ # mkdir /mnt/boot
root@archiso ~ # mount /dev/nvme0n1p1 /mnt/boot

ミラーの選択

vim /etc/pacman.d/mirrorlist

ベースシステムのインストール

適当に便利そうなパッケージを突っ込む。インターネットが遅かったから1時間かかってアニメを2話見た。

pacstrap /mnt base base-devel vim zsh

fstab

genfstab -U /mnt >> /mnt/etc/fstab

chroot

arch-chroot /mnt /bin/bash

locale

vim /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf

時間

/etc/localtimeがデフォルトだとUTCへのsymlinkになっていた

rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
hwclock --systohc --utc

ホスト名

echo Sophie > /etc/hostname

ネットワーク

パッケージだけ入れる

pacman -S iw wpa_supplicant dialog

ルートパスワード

passwd

ブートローダ

bootctl --path=/boot install


mkdir /etc/pacman.d/hooks/
vim /etc/pacman.d/hooks/systemd-boot.hook
[Trigger]
Type = Package
Operation = Upgrade
Target = systemd

[Action]
Description = Updating systemd-boot
When = PostTransaction
Exec = /usr/bin/bootctl update
vim /boot/loader/entries/arch.conf
title   Arch Linux
linux   /vmlinuz-linux
initrd  /initramfs-linux.img
options root=UUID=<UUID> rw

<UUID>には、lsblk -fして出てきたUUIDを入れる。/にマウントするパーティションのもの。

reboot

exit # exit from chroot
reboot

ネットワーク

wifi-menu

一般ユーザーの作成

useradd -m -g users -s /bin/zsh pocke
passwd pocke
gpasswd -a pocke wheel
visudo

GUI

pacman -S xf86-video-intel xorg-xinit xorg-server awesome

git

pacman -S git

このへんから一般ユーザーに切り替える

dotfiles

git clone https://github.com/pocke/dotfiles
sudo pacman -S ruby openssh
gem install itamae
cd dotfiles
/home/pocke/.gem/ruby/2.6.0/bin/itamae local itamae/roles/main.rb
mkdir -p ~/ghq/github.com/pocke
git clone https://github.com/pocke/dotfiles-private ~/ghq/github.com/pocke/dotfiles-private

このあと色々作業した記憶があるけど覚えてない。BIOSでグラフィックボードの設定をいじってやっとXが起動した記憶がある。