Here are the steps to take when installing Arch Linux on your own PC. In this article, I will explain how to install Arch Linux and perform the minimum setup required for practical use.
This article is intended for desktop use, not for server use. (However, if you set a fixed IP, it can be derived for server use as well.) In addition, it is assumed that a Japanese environment will be set up, and the locale is set for that purpose.
The installation procedure follows the Arch wiki.
https://wiki.archlinux.org/index.php/Installation_guide
Until a few years ago, the installation was designed to be completed with just the installation guide, but it seems that the policy has changed, and it has become a style to find the necessary information on the necessary page. .. Speaking of Arch, it seems to be Arch, but since there are many choices and it is not linear, it is a little difficult to understand, so I made the procedure linear by reducing the range of choices. Therefore, it is not just a sutra copy on the above page, but an article that supplements the necessary information as appropriate.
There are already a number of articles about installing Arch Linux, but I think that limiting the installation destination to UEFI desktop PCs makes it as simple and linear as possible.
--CPU: Intel Core i series --Graphics: Intel UHD graphics --Boot mode: UEFI --Storage: NVMe SSD --Network: Wired / Dynamic Address (DHCP)
CPU
CPU will be advanced with the 10th generation Intel Core i series instead of the trendy AMD Ryzen. As far as I can tell, it seems that the kernel to be installed must be linux-zen to optimize for Ryzen.
The graphics use Intel UHD graphics. No graphics board is used. Please note that depending on the model number, the graphic function built into the CPU may not be installed and an external GPU may be required.
The boot mode assumes UEFI. Since January 2020, when Windows 7 support has expired, it seems that there are virtually no new PCs (motherboards) that do not support UEFI, so we do not consider motherboards that only support legacy BIOS.
For partitioning, choose modern GPT instead of MBR. The Arch wiki points out that depending on the firmware, the UEFI-MBR may not boot, and there seems to be no benefit to partitioning with the MBR. The storage will be a newly purchased NVMe SSD, which is not formatted at the start of the installation.
We will use wired and dynamic address (DHCP) to connect to the network. Since we do not consider server usage, we will not explain static addresses (fixed IP).
It does not assume dual boot with Windows or other OS. Consider single booting Arch Linux.
Preparations for launching the Arch Linux installer.
Prepare a bootable USB for Arch Linux. This bootable USB allows you to install Arch Linux on a variety of systems with just one. It also functions as a diagnostic tool when the system does not boot for some reason after installation, so it is convenient to stock one dedicated one. A capacity of 4GB is sufficient.
See below for how to create a bootable USB on Windows / Mac.
If you're already using a Linux system, using dd
is a quick way.
https://wiki.archlinux.org/index.php/USB_flash_installation_medium
The ISO file can be obtained from:
https://www.archlinux.jp/download/
Boot UEFI by a motherboard-specific procedure. Please refer to the instruction manual of the motherboard or PC. I get the impression that F2, F12, DEL, and ESC keys are often required.
Boot from USB memory is the highest priority with Boot prioirty.
When the UEFI boot screen appears on Arch Linux, proceed with the installation.
Once the installer is up, install Arch Linux on your system.
Make the minimum necessary settings for installation, such as keyboard layout settings and network connection confirmation. It also partitions, formats, and mounts the storage.
By default, it is set to the US keyboard, so if you are using a JP keyboard
# loadkeys jp106
And change the settings. Appropriate keyboard layout settings are important because the work is centered on the terminal and there are many irreversible operations.
Make sure you are booting in UEFI. If you are in the UEFI screen when you start the installer, you should be fine.
# ls /sys/firmware/efi/efivarss
If this is also connected by wired LAN, in most cases it is already connected, but for the time being, check with ping
.
# ping -c 3 archlinux.jp
Use timedatectl
to get the system clock accurate.
# timedatectl set-ntp true
Use gdisk
to partition the storage.
For UEFI-GPT, partitioning and proper formatting are required.
You need about 500MB for / boot
.
This time, assign all the remaining partitions to the root /
.
First, use lsblk
to check the device name.
Now that we have found a device named / dev / nvme0n1
, we will use the partitioning tool gdisk
to partition it.
The device name depends on the type of storage connection and is displayed as / dev / sda
for SATA connections.
Open the device with gdisk
:
# gdisk /dev/nvme0n1
It seems to be automatically formatted for GPT just by opening it.
Assign the first partition to / boot
and the second partition to/
.
The first partition is labeled "EFI system partition" and the second is labeled the default "Linux File system".
gdisk
is an interactive UI, so if you don't understand it, call for help with?
.
When you're done partitioning and labeling, write with w
to finish.
If you check with lsblk
, you should be able to partition.
See below for how to use gdisk
:
https://wiki.archlinux.jp/index.php/Fdisk
For /
, use ext4, and for / boot
, use vfat.
# mkfs.ext4 /dev/nvme0n2
# mkfs.fat -F32 /dev/nvme0n1p1
Then mount the device to the file system. First, mount the route.
# mount /dev/nvme0n1p2 /mnt
Create the / boot
directory and then mount it.
# mkdir /mnt/boot
# mount /dev/nvme0n1p1 /mnt
After mounting the partitioned storage area, install Arch Linux.
Select the mirror on which you want to install Arch Linux.
Installation will be faster by selecting a server in Japan.
Edit /etc/pacman.d/mirrorlist
to bring the address of the domestic server to the beginning of the file.
The editor is often vi
or nano
.
Nano
is recommended for beginners.
nano
has command shortcuts at the bottom, but here are some useful commands:
Ctrl-w
: word search, ʻAlt-6: copy line,
Ctrl-u`: paste
Use pacstrap
to install the system at the mounted root.
# pacstrap \mnt base base-devel linux linux-firmware
base-devel
is not required, but I think most will be needed soon so I'll include it here.
You have built the Arch Linux file system and installed the minimum required packages. In addition, you need to do localization, network settings, and install a bootloader to boot your system.
Create fstab
.
# genfstab -U /mnt >> /mnt/etc/fstab
Check if it was generated properly.
# cat /mnt/etc/fstab
arch-chroot
Chroot to the newly installed system:
# arch-chroot /mnt
Set the time zone:
# ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
Run hwclock
to generate / etc / adjtime
:
# hwclock --systohc
Set the locale.
ʻEn_US.UTF-8and
ja_JP.UTF-8are generated. If you don't need to set up the Japanese environment, you don't need to generate and enable
ja_JP.UTF-8`,
We are planning to build a Japanese environment in the future, so set it here.
First, edit /etc/locale.gen
to uncomment ʻen_US.UTF-8 UTF-8 and
ja_JP.UTF-8 UTF-8`.
Run the following command to generate the locale:
# locale-gen
Then create a /etc/locale.conf
file and set the LANG
environment variable.
LANG=en_US.UTF-8
# LANG=ja_JP.UTF-8
If you suddenly set ja_JP.UTF-8
, the message on the virtual console will be garbled when you restart later, so I commented it out.
It will be activated later after installing the desktop environment and Japanese fonts.
If you are using a Japanese keyboard, set the console keymap to /etc/vconsole.conf
.
KEYMAP=jp106
If you don't do this, you'll end up hitting loadkey jp106
every time you boot the system.
Since it is a keymap setting for the virtual console, it needs to be set separately when installing a GUI such as the X Window system.
Set the host name and DHCP service.
First, set the host name.
Create / etc / hostname
and write an appropriate hostname.
myhostname
There seems to be a limit to the characters that can be used in the host name.
It seems recommended to use only the alphabet and hyphen -
and dot .
.
Write the same hostname in hosts
:
127.0.0.1 localhost
::1 localhost
127.0.1.1 myhostname.localdomain myhostname
Next, use DHCP to make settings for automatically connecting to the network when you start up.
Install dhcpcd
and enable the service.
Installing dhcpcd
:
# pacman -S dhcpcd
Check network interface:
# ip link
The name just to the right of the number displayed is the name of the interface.
In this environment, we can confirm that the device name is ʻeno1`, so specify the device name to enable the service:
# systemctl enable [email protected]
This will automatically connect you to the network after a reboot.
Initramfs
It is not necessary this time because it does not build LVM, system encryption, or RAID environment.
Set the root password.
# passwd
If you forget this procedure, you will not be able to log in to the system.
If you forget it, you will need to launch the installer again, mount
the partition, ʻarch-chroot`, and then set the password.
Install the boot loader.
This time, I will use grub
.
Install grub
and ʻefibootmgr`:
# pacman -S grub efibootmgr
Install grub:
# grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub
Generate configuration file:
# grub-mkconfig -o /boot/grub/grub.cfg
For grub
, see below.
Information is also scattered a little here, and I feel that it is difficult for beginners to understand.
https://wiki.archlinux.jp/index.php/GRUB
To exit the chroot
environment, type ʻexit or press
Ctrl + d. Then optionally unmount all partitions and reboot with the
reboot` command.
If you do not remove the installation media when restarting, the installer may start again.
If you see the Arch Linux login screen, you are successful.
For practical purposes, set user settings and sudo
as the minimum required settings.
After rebooting, after logging in as root
The system can be updated with the following command:
# pacman -Syu
Immediately after installation, it is really minimal and even vi
is not installed.
So try installing vi
or nano
(or both).
# pacman -S vi nano
You should be able to run the vi
or nano
command.
It is no exaggeration to say that the root of Arch Linux lies in the package manager pacman
.
I think it's simpler to use than others.
Detailed usage is described below.
https://wiki.archlinux.jp/index.php/Pacman
For security reasons, it is not desirable to work as the root user.
Therefore, add a general user and register to sudo
.
Add user first:
# useradd -m -s /bin/bash user
The -m
option creates the user's directory / home / user
and
The -s
option specifies the login shell.
The standard bash
is used here, but if you want to use another shell, you should install it in advance.
Set user password:
# passwd user
For more information on adding users, see: https://wiki.archlinux.org/index.php/Users_and_groups
Register users with sudo
using visudo
:
# visudo
Log out, log back in as a regular user, and then perform a system update:
$ sudo pacman -Syu
The first time you use sudo
, you'll get a note, but don't worry about it.
See below for sudo
:
https://wiki.archlinux.jp/index.php/Sudo
I installed Arch Linux on my own PC and did the minimum setup. If you make your own PC, the partition procedure will be a little easier because the OS is not installed in the storage.
I would like to explain the GUI, Japanese environment, application installation, etc. in another article.
Recommended Posts