くろひょうのぶろぐ

【自分用】ArchLinuxのインストール手順
2021-05-15 12:45

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

ISOイメージの準備

SSHログインの準備

root@archiso ~ # systemctl start sshd
root@archiso ~ # passwd
New password: <Password>
Retype new password: <Password>

インストール

 __________________________________________________________________________
/ To install Arch Linux follow the installation guide:                     \
| https://wiki.archlinux.org/index.php/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.                           /
 --------------------------------------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Last login: Wed Apr 10 11:12:13 2021
root@archiso ~ # 
root@archiso ~ # ls /usr/share/kbd/keymaps/**/*.map.gz | grep jp
/usr/share/kbd/keymaps/i386/qwerty/jp106.map.gz
root@archiso ~ # loadkeys jp106
root@archiso ~ # ls /sys/firmware/efi/efivars
ls: cannot access '/sys/firmware/efi/efivars': No such file or directory
root@archiso ~ # 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: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 7a:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    altname enp0s3
3: ens7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 76:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    altname enp0s7
root@archiso ~ # timedatectl
               Local time: Wed 2021-04-10 13:11:42 UTC
           Universal time: Wed 2021-04-10 13:11:42 UTC
                 RTC time: Wed 2021-04-10 13:11:42    
                Time zone: UTC (UTC, +0000)           
System clock synchronized: no                         
              NTP service: inactive                   
          RTC in local TZ: no 
root@archiso ~ # timedatectl set-ntp true
root@archiso ~ # timedatectl             
               Local time: Wed 2021-04-10 13:11:12 UTC
           Universal time: Wed 2021-04-10 13:11:12 UTC
                 RTC time: Wed 2021-04-10 13:11:12    
                Time zone: UTC (UTC, +0000)           
System clock synchronized: yes                        
              NTP service: active                     
          RTC in local TZ: no  
root@archiso ~ # 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: 618.27 MiB, 648298496 bytes, 1266208 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
root@archiso ~ # fdisk /dev/vda 

Welcome to fdisk (util-linux 2.36.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 0xxxxxxxx3.

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: 0xxxxxxxx3

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: 0xxxxxxxx3

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

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: 0xxxxxxxx3

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

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: 0xxxxxxxx3

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

Command (m for help): t
Partition number (1,2, default 2): 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: 0xxxxxxxx3

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.
root@archiso ~ # mkswap /dev/vda1 
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=11xx4996-3456-9999-ssss-2e55f9xxxxxx
root@archiso ~ # swapon /dev/vda1 
root@archiso ~ # mkfs.ext4 /dev/vda2 
mke2fs 1.46.2 (28-Feb-2021)
Discarding device blocks: done                            
Creating filesystem with 6291200 4k blocks and 1572864 inodes
Filesystem UUID: xxxx774d-5555-3333-xxxx-99xxxxx00css
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  
root@archiso ~ # df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             457M     0  457M   0% /dev
run             488M  149M  339M  31% /run
/dev/sr0        751M  751M     0 100% /run/archiso/bootmnt
cowspace        256M  764K  256M   1% /run/archiso/cowspace
/dev/loop0      619M  619M     0 100% /run/archiso/airootfs
airootfs        256M  764K  256M   1% /
tmpfs           488M     0  488M   0% /dev/shm
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs           488M     0  488M   0% /tmp
tmpfs           488M  2.1M  486M   1% /etc/pacman.d/gnupg
tmpfs            98M     0   98M   0% /run/user/0
root@archiso ~ # mount /dev/vda2 /mnt 
root@archiso ~ # df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             457M     0  457M   0% /dev
run             488M  149M  339M  31% /run
/dev/sr0        751M  751M     0 100% /run/archiso/bootmnt
cowspace        256M  764K  256M   1% /run/archiso/cowspace
/dev/loop0      619M  619M     0 100% /run/archiso/airootfs
airootfs        256M  764K  256M   1% /
tmpfs           488M     0  488M   0% /dev/shm
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs           488M     0  488M   0% /tmp
tmpfs           488M  2.1M  486M   1% /etc/pacman.d/gnupg
tmpfs            98M     0   98M   0% /run/user/0
/dev/vda2        24G   24K   23G   1% /mnt
root@archiso ~ # vim /etc/pacman.d/mirrorlist 
root@archiso ~ # cat /etc/pacman.d/mirrorlist
##
## Arch Linux repository mirrorlist
## Filtered by mirror score from mirror status page
## Generated on 2021-05-14
##

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

システム設定

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

# <file system> <dir> <type> <options> <dump> <pass>
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/vda2
UUID=xxxxxx4d-1ww3-4aac-91fd-b0cxxxxxxcss   /           ext4        rw,relatime 0 1

# /dev/vda1
UUID=xxxxxx86-7aa8-4998-b4a8-2e2xxxxxx5tt   none        swap        defaults    0 0
root@archiso ~ # arch-chroot /mnt
[root@archiso /]# 
[root@archiso /]# ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
[root@archiso /]# date
Wed Apr 10 11:12:13 JST 2021
[root@archiso /]# hwclock --systohc
[root@archiso /]# pacman -S vim --noconfirm
[root@archiso /]# vim /etc/locale.gen
[root@archiso /]# locale-gen 
Generating locales...
  en_US.UTF-8... done
Generation complete.
[root@archiso /]# echo LANG=en_US.UTF-8 > /etc/locale.conf
[root@archiso /]# cat /etc/locale.conf 
LANG=en_US.UTF-8
[root@archiso /]# echo jp106  > /etc/vconsole.conf
[root@archiso /]# cat /etc/vconsole.conf 
jp106
[root@archiso /]# echo example.blackle0pard.local > /etc/hostname
[root@archiso /]# cat /etc/hostname 
example.blackle0pard.local
[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
127.0.0.1       example.blackle0pard.local example
[root@archiso /]# mkinitcpio -P
[root@archiso /]# passwd
New password: 
Retype new password: 
passwd: password updated successfully
[root@archiso /]# useradd -m hoge
[root@archiso /]# id hoge
uid=1000(hoge) gid=1000(hoge) groups=1000(hoge) 
[root@archiso /]# passwd hoge
New password: 
Retype new password: 
passwd: password updated successfully
[root@archiso /]# systemctl enable systemd-networkd
[root@archiso /]# systemctl enable systemd-resolved
[root@archiso /]# vim /etc/systemd/network/ens3.network
[root@archiso /]# cat /etc/systemd/network/ens3.network
[Match]
Name=ens3

[Network]
Address=xxx.xxx.xxx.xxx/xx
Gateway=xxx.xxx.xxx.xxx
DNS=xxx.xxx.xxx.xxx
LinkLocalAddressing=no
IPv6AcceptRA=no

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

[root@archiso /]# vim /etc/systemd/network/ens7.network
[root@archiso /]# cat /etc/systemd/network/ens7.network
[Match]
Name=ens7

[Link]
MTUBytes=1450

[Network]
Address=xxx.xxx.xxx.xxx/xx
LinkLocalAddressing=no
IPv6AcceptRA=no
[root@archiso /]# pacman -S openssh --noconfirm
[root@archiso /]# systemctl enable sshd
[root@archiso /]# pacman -S grub --noconfirm
[root@archiso /]# grub-install --target=i386-pc /dev/vda
[root@archiso /]#  grub-mkconfig -o /boot/grub/grub.cfg
[root@archiso /]# exit
exit
arch-chroot /mnt  14.56s user 5.14s system 0% cpu 40:48.42 total
root@archiso ~ # 
root@archiso ~ # umount /mnt 
root@archiso ~ # df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             457M     0  457M   0% /dev
run             488M  149M  339M  31% /run
/dev/sr0        751M  751M     0 100% /run/archiso/bootmnt
cowspace        256M  792K  256M   1% /run/archiso/cowspace
/dev/loop0      619M  619M     0 100% /run/archiso/airootfs
airootfs        256M  792K  256M   1% /
tmpfs           488M     0  488M   0% /dev/shm
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs           488M     0  488M   0% /tmp
tmpfs           488M  2.1M  486M   1% /etc/pacman.d/gnupg
tmpfs            98M     0   98M   0% /run/user/0

確認

# ArchLinux # Vultr