LoginSignup
2
1

More than 1 year has passed since last update.

Arch Linux Install Memo(令和3年版)

Last updated at Posted at 2021-08-26

Arch Linux Install Memo(令和3年版)

はじめに

この文書は私が環境を構築した際のメモ書きです。

これからセットアップを開始する人はArch Wikiインストールガイドを一読することをお勧めします。

その上でこのメモを参考にしていただければと思います。

インストールメモ

インストールメディアの準備、ブート

Arch Linux Downloadsよりダウンロード。

次のコマンドでUSBメモリに書き込む。

# dd bs=4M if=/path/to/archlinux.iso of=/deb/sdx status=progress && sync

準備したUSBメモリを利用してマシンをブート。

(optional)コンソールフォントの変更

デバイスによっては画面の解像度に対しフォントが小さくインストール作業が困難な場合がある。そのようなときは次のコマンドでコンソールフォントを変更。

# setfont latarcryheb-sun32

(optional)SSH 接続

インストールメディアからブートした状態でSSHデーモンが稼働している。rootユーザにパスワードを設定し、IPアドレスを調べ別のマシンからSSH接続して作業をすると便利。

root@archiso ~ # passwd
New password:
Retype new password:
passwd: password updated successfully
root@archiso ~ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:e0:d0:0c brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.232.135/24 metric 100 brd 192.168.232.255 scope global dynamic ens33
       valid_lft 1481sec preferred_lft 1481sec
    inet6 fe80::20c:29ff:fee0:d00c/64 scope link
       valid_lft forever preferred_lft forever

パーティションの作成

512MB を/bootに、残りを/に割り当てを念頭にパーティションを作成。

root@archiso ~ # gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.8

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

Creating new GPT entries in memory.

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

Command (? for help): n
Partition number (2-128, default 2):
First sector (34-16777182, default = 1050624) or {+-}size{KMGTP}:
Last sector (1050624-16777182, default = 16777182) or {+-}size{KMGTP}:
Current type is 8300 (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/sda: 16777216 sectors, 8.0 GiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): FCD60321-F032-4903-A54C-B7C05086CE2C
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 16777182
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 partition
   2         1050624        16777182   7.5 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/sda.
The operation has completed successfully.
root@archiso ~ # gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.8

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 16777216 sectors, 8.0 GiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): FCD60321-F032-4903-A54C-B7C05086CE2C
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 16777182
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 partition
   2         1050624        16777182   7.5 GiB     8300  Linux filesystem

ファイルシステムの作成、マウント

/dev/sda1をFAT32で、/dev/sda2をext4でファイルシステムを作成。

root@archiso ~ # mkfs.fat -F 32 /dev/sda1
mkfs.fat 4.2 (2021-01-31)
root@archiso ~ # mkfs.ext4 /dev/sda2
mke2fs 1.46.3 (27-Jul-2021)
Creating filesystem with 1965819 4k blocks and 491520 inodes
Filesystem UUID: 19d47391-2745-41ee-b87c-04a6b476b8e4
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

/dev/sda2を/mntに、/dev/sda1を/mnt/bootにマウント。

root@archiso ~ # mount /dev/sda2 /mnt
root@archiso ~ # mkdir /mnt/boot
root@archiso ~ # mount /dev/sda1 /mnt/boot
root@archiso ~ # df
Filesystem     1K-blocks   Used Available Use% Mounted on
dev               441204      0    441204   0% /dev
run               481524 160924    320600  34% /run
/dev/sr0          851276 851276         0 100% /run/archiso/bootmnt
cowspace          262144    776    261368   1% /run/archiso/cowspace
/dev/loop0        678912 678912         0 100% /run/archiso/airootfs
airootfs          262144    776    261368   1% /
tmpfs             481524      0    481524   0% /dev/shm
tmpfs             481528      0    481528   0% /tmp
tmpfs             481524   2112    479412   1% /etc/pacman.d/gnupg
tmpfs              96304      0     96304   0% /run/user/0
/dev/sda2        7639784     28   7230212   1% /mnt
/dev/sda1         523244      4    523240   1% /mnt/boot

ミラーリストの取得、編集

reflectorを使うと便利。

root@archiso ~ # reflector --sort rate --country Japan --latest 10 --save /etc/pacman.d/mirrorlist
root@archiso ~ # cat /etc/pacman.d/mirrorlist
################################################################################
################# Arch Linux mirrorlist generated by Reflector #################
################################################################################

# With:       reflector --sort rate --country Japan --latest 10 --save /etc/pacman.d/mirrorlist
# When:       2021-08-26 12:54:35 UTC
# From:       https://archlinux.org/mirrors/status/json/
# Retrieved:  2021-08-26 12:54:27 UTC
# Last Check: 2021-08-26 03:33:00 UTC

Server = https://mirrors.cat.net/archlinux/$repo/os/$arch
Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
Server = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch
Server = rsync://ftp.tsukuba.wide.ad.jp/archlinux/$repo/os/$arch
Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
Server = https://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
Server = rsync://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch

必須パッケージのインストール

root@archiso ~ # pacstrap /mnt base base-devel linux linux-firmware
(省略)
pacstrap /mnt base base-devel linux linux-firmware  7.95s user 10.72s system 63% cpu 29.400 total

fstab の生成

root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab
root@archiso ~ # cat /mnt/etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/sda2
UUID=19d47391-2745-41ee-b87c-04a6b476b8e4       /               ext4            rw,relatime     0 1

# /dev/sda1
UUID=AF45-0EFA          /boot           vfat            rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro   0 2

chroot

root@archiso ~ # arch-chroot /mnt

ログインユーザの作成

ログインユーザを作成、sudoでroot権限を扱えるようにwheelグループに所属させる。
また、rootユーザの直接ログインを無効にする。

[root@archiso /]# useradd -m -G wheel hogehoge
[root@archiso /]# passwd hogehoge
[root@archiso /]# passwd -l root
passwd: password expiry information changed.

エディタの準備

以降のセットアップを効率的に進めるため使い慣れたエディタを準備。

[root@archiso /]# pacman -S vim
[root@archiso /]# export EDITOR=/usr/bin/vim

sudoers

wheelグループを許可。

[root@archiso /]# cp -p /etc/sudoers /etc/sudoers.org
[root@archiso /]# visudo
[root@archiso /]# diff -u /etc/sudoers.org /etc/sudoers
--- /etc/sudoers.org    2021-07-27 16:27:04.000000000 +0000
+++ /etc/sudoers        2021-08-26 13:16:39.706710724 +0000
@@ -79,7 +79,7 @@
 root ALL=(ALL) ALL

 ## Uncomment to allow members of group wheel to execute any command
-# %wheel ALL=(ALL) ALL
+%wheel ALL=(ALL) ALL

 ## Same thing without a password
 # %wheel ALL=(ALL) NOPASSWD: ALL

タイムゾーン

[root@archiso /]# ln -sf /usr/share/zoneinfo/Japan /etc/localtime

ロケール

英語、日本語のutf-8を生成し、英語をシステムのロケールに設定しておく。

[root@archiso /]# cat /etc/locale.gen | grep -v ^#
en_US.UTF-8 UTF-8
ja_JP.UTF-8 UTF-8
[root@archiso /]# locale-gen
Generating locales...
  en_US.UTF-8... done
  ja_JP.UTF-8... done
Generation complete.
[root@archiso /]# vim /etc/locale.conf
[root@archiso /]# cat /etc/locale.conf
LANG=en_US.utf-8

hostname & hosts

[root@archiso /]# vim /etc/hostname
[root@archiso /]# cat /etc/hostname
archdayo
[root@archiso /]# vim /etc/hosts
[root@archiso /]# cat /etc/hosts
# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1       localhost
::1             localhost
127.0.1.1       archdayo.localdomain, archdayo

ブート

参考:systemd-boot

ブートマネージャのインストール

[root@archiso /]# bootctl install

(optional)intelプロセッサ向けマイクロコード

[root@archiso /]# pacman -S intel-ucode

(optional)amdプロセッサ向けマイクロコード

[root@archiso /]# pacman -S amd-ucode

ローダーの追加

intel-ucodeの箇所はインストールしたマイクロコードに合わせて変更。

[root@archiso /]# vim /boot/loader/entries/arch.conf
[root@archiso /]# cat /boot/loader/entries/arch.conf
title   Arch Linux
linux   vmlinuz-linux
initrd  intel-ucode
initrd  initramfs-linux.img
options root=UUID=19d47391-2745-41ee-b87c-04a6b476b8e4 rw

ローダーの設定

[root@archiso /]# vim /boot/loader/loader.conf
[root@archiso /]# cat /boot/loader/loader.conf
default arch
timeout 3
editor  no

デスクトップ環境の構築

これでArchの基本的なセットアップはできている・・・が、再起動してもネットワークにつなぐのも一手間かかる。

最低限の環境としてネットワークマネージャおよびデスクトップ環境をセットアップする。
- NetworkManager
- cinnamon
- lightdm
- lightdm-webkit2-greeter
- alacritty

Network Manager

[root@archiso /]# pacman -S networkmanager
[root@archiso /]# systemctl enable NetworkManager

xorg-serber

[root@archiso /]# pacman -S xorg-server

Cinnamon

[root@archiso /]# pacman -S cinnamon

lightdm, lightdm-webkit2-greeter

[root@archiso /]# pacman -S lightdm lightdm-webkit2-greeter
[root@archiso /]# cp -p /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.org
[root@archiso /]# vim /etc/lightdm/lightdm.conf
[root@archiso /]# diff -u /etc/lightdm/lightdm.conf.org /etc/lightdm/lightdm.conf
--- /etc/lightdm/lightdm.conf.org       2020-08-14 21:54:32.000000000 +0900
+++ /etc/lightdm/lightdm.conf   2021-08-26 23:15:44.943424475 +0900
@@ -99,7 +99,7 @@
 #xdmcp-manager=
 #xdmcp-port=177
 #xdmcp-key=
-#greeter-session=example-gtk-gnome
+greeter-session=lightdm-webkit2-greeter
 #greeter-hide-users=false
 #greeter-allow-guest=true
 #greeter-show-manual-login=false
[root@archiso /]# systemctl enable lightdm.service

alacritty

好きです。alacritty。

[root@archiso /]# pacman -S alacritty

おしまい

chroot環境を抜けて、リブート。

[root@archiso /]# exit
exit
arch-chroot /mnt  10.12s user 9.18s system 0% cpu 1:17:48.01 total
root@archiso ~ # reboot

arch install test-2021-08-26-14-29-45.png

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1