くろひょうのぶろぐ

【自分用】ArchLinuxのインストール手順 (2021年12月)
2021-12-11 21:36 ( edited 2021-12-11 23:41 )

VultrにArchLinuxをインストールするための、自分用メモ。正しいインストール手順は、Installation guide - ArchWiki を参照してください。

ISOイメージの準備

SSHログインの準備

If you do not have a US keyboard, you may see incorrect characters while typing or have trouble with your password. The web console expects a US keyboard and an English layout. When using the web console, temporarily install a US keyboard or switch your input language to English and then use the on-screen keyboard.

# passwd
New password: <Password>
Retype new password: <Password>

インストール

% ssh root@***.***.***.***
Warning: Permanently added '***.***.***.***' (ED25519) to the list of known hosts.
(root@***.***.***.***) Password: 
To install Arch Linux follow the installation guide:
https://wiki.archlinux.org/title/Installation_guide

For Wi-Fi, authenticate to the wireless network using the iwctl utility.
For mobile broadband (WWAN) modems, connect with the mmcli utility.
Ethernet, WLAN and WWAN interfaces using DHCP should work automatically.

After connecting to the internet, the installation guide can be accessed
via the convenience script Installation_guide.

Last login: Sat Dec 11 07:44:46 2021
# 
# uname -srvmo
Linux 5.15.5-arch1-1 #1 SMP PREEMPT Thu, 25 Nov 2021 22:09:33 +0000 x86_64 GNU/Linux
# cat /etc/os-release 
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux-logo
IMAGE_ID=archlinux
IMAGE_VERSION=2021.12.01
ls /usr/share/kbd/keymaps/**/*.map.gz | grep jp
/usr/share/kbd/keymaps/i386/qwerty/jp106.map.gz
# localectl list-keymaps| grep jp
jp106
# loadkeys jp106
#  ls /sys/firmware/efi/efivars
ls: cannot access '/sys/firmware/efi/efivars': No such file or directory
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
3: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
# timedatectl status
               Local time: Sat 2021-12-11 07:50:53 UTC
           Universal time: Sat 2021-12-11 07:50:53 UTC
                 RTC time: Sat 2021-12-11 07:50:54
                Time zone: UTC (UTC, +0000)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no
# timedatectl set-ntp true
# timedatectl status
               Local time: Sat 2021-12-11 07:51:25 UTC
           Universal time: Sat 2021-12-11 07:51:25 UTC
                 RTC time: Sat 2021-12-11 07:51:25
                Time zone: UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
# fdisk -l
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop0: 701.33 MiB, 735399936 bytes, 1436328 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
# fdisk /dev/vda 

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x0b9a45d3.

Command (m for help): p
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
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: 0x0b9a45d3

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-52428799, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-52428799, default 52428799): +1G

Created a new partition 1 of type 'Linux' and of size 1 GiB.

Command (m for help): p
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
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: 0x0b9a45d3

Device     Boot Start     End Sectors Size Id Type
/dev/vda1        2048 2099199 2097152   1G 83 Linux

Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'.

Command (m for help): p
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
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: 0x0b9a45d3

Device     Boot Start     End Sectors Size Id Type
/dev/vda1        2048 2099199 2097152   1G 82 Linux swap / Solaris

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 (2099200-52428799, default 2099200): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-52428799, default 52428799): 

Created a new partition 2 of type 'Linux' and of size 24 GiB.

Command (m for help): p
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
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: 0x0b9a45d3

Device     Boot   Start      End  Sectors Size Id Type
/dev/vda1          2048  2099199  2097152   1G 82 Linux swap / Solaris
/dev/vda2       2099200 52428799 50329600  24G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk -l        
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
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: 0x0b9a45d3

Device     Boot   Start      End  Sectors Size Id Type
/dev/vda1          2048  2099199  2097152   1G 82 Linux swap / Solaris
/dev/vda2       2099200 52428799 50329600  24G 83 Linux


Disk /dev/loop0: 701.33 MiB, 735399936 bytes, 1436328 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
# free -h 
               total        used        free      shared  buff/cache   available
Mem:           970Mi       122Mi       286Mi       174Mi       560Mi       534Mi
Swap:             0B          0B          0B
# mkswap /dev/vda1 
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=4ce8ea7b-5c2a-4df6-85d8-8b7b597acf1a
# swapon /dev/vda1 
# free -h
               total        used        free      shared  buff/cache   available
Mem:           970Mi       122Mi       286Mi       174Mi       561Mi       535Mi
Swap:          1.0Gi          0B       1.0Gi
# mkfs.ext4 /dev/vda2
mke2fs 1.46.4 (18-Aug-2021)
Discarding device blocks: done                            
Creating filesystem with 6291200 4k blocks and 1572864 inodes
Filesystem UUID: d01cd335-604a-4fe3-a27f-e97666d5b666
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   
# df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             452M     0  452M   0% /dev
run             486M  166M  320M  35% /run
/dev/sr0        851M  851M     0 100% /run/archiso/bootmnt
cowspace        256M  4.1M  252M   2% /run/archiso/cowspace
/dev/loop0      702M  702M     0 100% /run/archiso/airootfs
airootfs        256M  4.1M  252M   2% /
tmpfs           486M     0  486M   0% /dev/shm
tmpfs           486M     0  486M   0% /tmp
tmpfs           486M  2.2M  484M   1% /etc/pacman.d/gnupg
tmpfs            98M     0   98M   0% /run/user/0
# mount /dev/vda2 /mnt 
# df -h                
Filesystem      Size  Used Avail Use% Mounted on
dev             452M     0  452M   0% /dev
run             486M  166M  320M  35% /run
/dev/sr0        851M  851M     0 100% /run/archiso/bootmnt
cowspace        256M  4.1M  252M   2% /run/archiso/cowspace
/dev/loop0      702M  702M     0 100% /run/archiso/airootfs
airootfs        256M  4.1M  252M   2% /
tmpfs           486M     0  486M   0% /dev/shm
tmpfs           486M     0  486M   0% /tmp
tmpfs           486M  2.2M  484M   1% /etc/pacman.d/gnupg
tmpfs            98M     0   98M   0% /run/user/0
/dev/vda2        24G   24K   23G   1% /mnt
# vim /etc/pacman.d/mirrorlist 
# cat /etc/pacman.d/mirrorlist 
#
# Arch Linux repository mirrorlist
# Filtered by mirror score from mirror status page
# Generated on 2021-12-11
#

# Japan
Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
# Japan
Server = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch
# Japan
Server = https://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
# Japan
Server = https://mirrors.cat.net/archlinux/$repo/os/$arch
# Japan
Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
# pacstrap /mnt base linux-lts linux-firmware

システム設定

# cat /mnt/etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# genfstab -U /mnt >> /mnt/etc/fstab
# cat /mnt/etc/fstab                
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/vda2
UUID=d01cd335-604a-4fe3-a27f-e97666d5b666   /           ext4        rw,relatime 0 1

# /dev/vda1
UUID=4ce8ea7b-5c2a-4df6-85d8-8b7b597acf1a   none        swap        defaults    0 0
# arch-chroot /mnt
# 
# date
Sat Dec 11 07:59:54 UTC 2021
# ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
# date
Sat Dec 11 18:13:20 JST 2021
# ls /etc/adjtime
ls: cannot access '/etc/adjtime': No such file or directory
# hwclock --systohc
# ls /etc/adjtime
/etc/adjtime
# cat /etc/adjtime
0.000000 1639209682 0.000000
1639209682
UTC
# pacman -S vim --noconfirm
# vim /etc/locale.gen
# locale-gen 
Generating locales...
  en_US.UTF-8... done
Generation complete.
# echo LANG=en_US.UTF-8 > /etc/locale.conf
# cat /etc/locale.conf 
LANG=en_US.UTF-8
# echo jp106  > /etc/vconsole.conf
# cat /etc/vconsole.conf 
jp106
# echo hoge.blackle0pard.local > /etc/hostname
# cat /etc/hostname 
hoge.blackle0pard.local
# vim /etc/hosts
# Static table lookup for hostnames.
# See hosts(5) for details.

127.0.0.1       localhost
127.0.0.1       hoge.blackle0pard.local hoge
# passwd
New password: 
Retype new password: 
passwd: password updated successfully
# useradd -m hoge
# id hoge
uid=1000(hoge) gid=1000(hoge) groups=1000(hoge)
# passwd hoge
New password: 
Retype new password: 
passwd: password updated successfully
# systemctl enable systemd-networkd
# systemctl enable systemd-resolved
# vim /etc/systemd/network/enp1s0.network
# cat /etc/systemd/network/enp1s0.network
[Match]
Name=enp1s0

[Network]
Address=***.***.***.***/23
Gateway=***.***.***.***
DNS=***.***.***.***
LinkLocalAddressing=no
IPv6AcceptRA=no

We recommend configuring an MTU of 1450 on your private network. Using a larger MTU will result in poor performance.

# vim /etc/systemd/network/enp6s0.network
# cat /etc/systemd/network/enp6s0.network
[Match]
Name=enp6s0

[Link]
MTUBytes=1450

[Network]
Address=***.***.***.***/24
LinkLocalAddressing=no
IPv6AcceptRA=no
# pacman -S openssh --noconfirm
# systemctl enable sshd
# pacman -S grub --noconfirm
# grub-install --target=i386-pc /dev/vda
# grub-mkconfig -o /boot/grub/grub.cfg
# exit
exit
arch-chroot /mnt  5.09s user 1.74s system 0% cpu 28:19.37 total
# 
# umount /mnt 
# df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             452M     0  452M   0% /dev
run             486M  166M  320M  35% /run
/dev/sr0        851M  851M     0 100% /run/archiso/bootmnt
cowspace        256M  4.1M  252M   2% /run/archiso/cowspace
/dev/loop0      702M  702M     0 100% /run/archiso/airootfs
airootfs        256M  4.1M  252M   2% /
tmpfs           486M     0  486M   0% /dev/shm
tmpfs           486M     0  486M   0% /tmp
tmpfs           486M  2.2M  484M   1% /etc/pacman.d/gnupg
tmpfs            98M     0   98M   0% /run/user/0

確認

# uname -srvmo
Linux 5.10.84-1-lts #1 SMP Wed, 08 Dec 2021 10:17:01 +0000 x86_64 GNU/Linux
# ArchLinux # Vultr