メインコンテンツまでスキップ

btrfs + grub

Install Arch Linux with the following settings.

Settings
Dual Bootingfalse
FilesystemBtrfs
Boot LoaderGRUB
Disksingle-disk
Disk Encryptionfalse

ISO

Arch Linux Downloads

Install

Keymaps

Change the keymap to the one you use for the installation. For a Japanese keyboard, use jp106.

loadkeys jp106

Time Settings

Execute the following command to use the NTP (Network Time Protocol).

timedatectl set-ntp true

Optimizing Mirrorlist

Optimize the mirror list using reflector to access mirror servers with fast access during installation.

pacman -Syy
pacman -S reflector
reflector -c Japan --sort rate -a 6 --save /etc/pacman.d/mirrorlist

The meaning of the reflector option is as follows.

OptionsDescription
-c JapanRestrict mirrors to selected countries.
--sort rateSort by download rate.
-a 6Restrict to servers synchronized within 6 hours.
--save /etc/pacman.d/mirrorlistSave the mirror list to the specified path.

Disk Partitioning and Formatting

Use gdisk to change the partition. In this example, we assume that Arch Linux is installed in /dev/sda.

gdisk /dev/sda

Allocate the first partition as an EFI partition of about 300MB. The remaining space will be allocated as a Linux Filesystem.

/dev/sda1: EFI system (300M)
/dev/sda2: Linux filesystem

EFI partition is formatted with fat.

mkfs.fat -F32 /dev/sda1

Linux Filesystem is formatted with ext4.

mkfs.btrfs /dev/sda2

Here is a template of the subvolume layout for each snapshot manager used.

mount /dev/sda2 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@snapshots
btrfs subvolume create /mnt/@var_log
umount /mnt
mount -o noatime,compress=zstd,space_cache=v2,subvol=@ /dev/sda2 /mnt
mkdir -p /mnt/{boot,home,.snapshots,var/log}
mount -o noatime,compress=zstd,space_cache=v2,subvol=@home /dev/sda2 /mnt/home
mount -o noatime,compress=zstd,space_cache=v2,subvol=@snapshots /dev/sda2 /mnt/.snapshots
mount -o noatime,compress=zstd,space_cache=v2,subvol=@var_log /dev/sda2 /mnt/var/log
mount /dev/sda1 /mnt/boot

Base Install

Sometimes updating archlinux-keyring is needed.

pacman -Syy
pacman -S archlinux-keyring

Install packages in /mnt.

pacstrap /mnt base linux linux-firmware vim intel-ucode

fstab

Generate the fstab file, which holds the information about which device to mount.

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

Change the Root Directory

Use chroot to set /mnt as the root directory.

arch-chroot /mnt

Localization

Create a symbolic link to /etc/localtime to change the time zone.

ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

Set the hardware clock to the current system clock. The system clock is the clock managed by the OS, and the hardware clock is the clock managed by the motherboard (hardware). when the OS is rebooted, the system clock stored in memory is lost, so the time is obtained from the hardware clock.

hwclock --systohc

To set the locale, first generate the locale. Uncomment the entries you want to use in /etc/locale.gen and run locale-gen.

sed -i 's/#en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
locale-gen

Execute the following command to set the locale of the system.

echo LANG=en_US.UTF-8 >> /etc/locale.conf
echo KEYMAP=jp106 >> /etc/vconsole.conf

Hostname

Register hostname in /etc/hostname.

echo arch > /etc/hostname

Edit /etc/hosts and set IP address corresponding to hostname.

echo -e "127.0.0.1\tlocalhost
::1\t\tlocalhost
127.0.1.1\tarch.localdomain\tarch" >> /etc/hosts

Root Password

Set the password of root user.

passwd

Install Additional Packages

pacman -S grub efibootmgr networkmanager network-manager-applet \
dialog os-prober mtools dosfstools base-devel linux-headers reflector \
git xdg-utils xdg-user-dirs bluez bluez-utils

Configuring mkinitcpio

Change the configurations, and reflect the changes with mkinitcpio.

sed -i 's/MODULES=()/MODULES=(btrfs)/' /etc/mkinitcpio.conf
mkinitcpio -p linux

Bootloader

Install Grub and create config file.

grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

Systemd

Enables NetworkManager.

systemctl enable NetworkManager

Enables Bluetooth.

systemctl enable bluetooth

Enables reflector. The execution options are written in /etc/xdg/reflector/reflector.conf.

systemctl enable reflector.service  # update mirrorlist every boot
systemctl enable reflector.timer    # update mirrorlist weekly

Add User

Add user with useradd and set the password.

useradd -mG wheel mori
passwd mori

Give the user priviledges.

EDITOR=vim visudo
- # %wheel ALL=(ALL) ALL
+ %wheel ALL=(ALL) ALL

Reboot

exit
umount -a
reboot