ArchLinux 2017.10.01: Install ArchLinux 2017.10.01


Table of Contents

1 Download LiveDVD

Download archlinux-2017.10.01-x86_64.iso from ArchLinux download page.

2 Run LiveDVD

LiveDVD will display the following menu. Press ENTER key at “Boot Arch Linux (x86_64)”.

0001_LiveDVD-BootLoaderMenu.png

Automatically login as root user.

0002_LiveDVD-LoginPrompt.png

2.1 Serial console

You can use copy and paste on serial console. Because the bootloader in install media supports serial console, connecting to serial console outputs bootloader menu.

0003_SerialConsole-BootLoaderMenu.png

Press TAB key and append “console=ttyS0,115200” to kernel parameter. And then press ENTER key.

0004_SerialConsole-AppendKernelParameter.png

You can login with root user without password.

0005_SerialConsole-LoginPrompt.png

3 Configuration with LiveDVD

This section will describe a configuration on LiveDVD before arch-chroot.

3.1 Disk partitions

/proc/partions before running fdisk are as the following. Change /dev/vda to your block device like /dev/sda.

root@archiso ~ # cat /proc/partitionsmajor minor #blocks name 254 0 10485760 vda 11 0 535552 sr0 7 0 417876 loop0

Run fdisk to /dev/vda.

root@archiso ~ # fdisk /dev/vdaWelcome to fdisk (util-linux 2.30.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 0xae297af2.Command (m for help):

Create a partion for /boot which size is 256MByte.

Command (m for help): nPartition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions)Select (default p): pPartition number (1-4, default 1): 1First sector (2048-20971519, default 2048): 2048Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): +256MCreated a new partition 1 of type ‘Linux’ and of size 256 MiB.

Create a partion for LVM which uses rest of size.

Command (m for help): nPartition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions)Select (default p): pPartition number (2-4, default 2): 2First sector (526336-20971519, default 526336): 526336Last sector, +sectors or +size{K,M,G,T,P} (526336-20971519, default 20971519):Created a new partition 2 of type ‘Linux’ and of size 9.8 GiB.

Append boot label to /boot partion.

Command (m for help): aPartition number (1,2, default 2): 1The bootable flag on partition 1 is enabled now.

Change label of LVM partition to “Linux LVM”.

Command (m for help): tPartition number (1,2, default 2): 2Partition type (type L to list all types): 8eChanged type of partition ‘Linux’ to ‘Linux LVM’.

Update partitions.

Command (m for help): wThe partition table has been altered.Calling ioctl() to re-read partition table.Syncing disks.

The partions after running fdisk are as below.

root@archiso ~ # fdisk -l /dev/vdaDisk /dev/vda: 10 GiB, 10737418240 bytes, 20971520 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x7f1f7d19Device Boot Start End Sectors Size Id Type/dev/vda1 * 2048 526335 524288 256M 83 Linux/dev/vda2 526336 20971519 20445184 9.8G 8e Linux LVM

3.2 LVM

Create physical volue on /dev/vda2.

root@archiso ~ # pvcreate /dev/vda2 Physical volume “/dev/vda2” successfully created.

Create volume group which names vg_archlinux with /dev/vda2.

root@archiso ~ # vgcreate vg_archlinux /dev/vda2 Volume group “vg_archlinux” successfully created

Create logical volume which names lv_swap from vg_archlinux.

root@archiso ~ # lvcreate -L 1G -n lv_swap vg_archlinux Logical volume “lv_swap” created.

Create logical volume which names lv_root from vg_archlinux.

root@archiso ~ # lvcreate -l 100%FREE -n lv_root vg_archlinux Logical volume “lv_root” created.

The logical volumes are as below.

root@archiso ~ # lvdisplay — Logical volume — LV Path /dev/vg_archlinux/lv_swap LV Name lv_swap VG Name vg_archlinux LV UUID ooRdRU-Z1sm-3oZZ-lWK5-ntE3-2bAp-Vcgf6V LV Write Access read/write LV Creation host, time archiso, 2017-10-06 06:25:12 +0000 LV Status available # open 0 LV Size 1.00 GiB Current LE 256 Segments 1 Allocation inherit Read ahead sectors auto – currently set to 256 Block device 253:0 — Logical volume — LV Path /dev/vg_archlinux/lv_root LV Name lv_root VG Name vg_archlinux LV UUID yvvRsQ-3ELb-yIdd-kLbC-8hlQ-gdXE-HVpU4D LV Write Access read/write LV Creation host, time archiso, 2017-10-06 06:25:34 +0000 LV Status available # open 0 LV Size <8.75 GiB Current LE 2239 Segments 1 Allocation inherit Read ahead sectors auto – currently set to 256 Block device 253:1

3.3 Filesystem

Format /dev/vda1 with ext4.

root@archiso ~ # mkfs.ext4 /dev/vda1mke2fs 1.43.6 (29-Aug-2017)Creating filesystem with 262144 1k blocks and 65536 inodesFilesystem UUID: 1ae02bc4-24eb-4b0f-b2e5-53f3a295cdfaSuperblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185Allocating group tables: doneWriting inode tables: doneCreating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: done

Format /dev/vg_archlinux/lv_root with ext4.

root@archiso ~ # mkfs.ext4 /dev/vg_archlinux/lv_rootmke2fs 1.43.6 (29-Aug-2017)Creating filesystem with 2292736 4k blocks and 573440 inodesFilesystem UUID: eb0a11e4-463d-4bec-8fe5-89b856eeec1bSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Allocating group tables: doneWriting inode tables: doneCreating journal (16384 blocks): doneWriting superblocks and filesystem accounting information: done

Create swap on /dev/vg_archlinux/lv_swap.

root@archiso ~ # mkswap /dev/vg_archlinux/lv_swapSetting up swapspace version 1, size = 1024 MiB (1073737728 bytes)no label, UUID=81080828-7edb-4b95-8d88-4ed4d2ee736f

Mount filesystems to /mnt and enable swap.

root@archiso ~ # mount -t ext4 /dev/vg_archlinux/lv_root /mntroot@archiso ~ # mkdir /mnt/bootroot@archiso ~ # mount -t ext4 /dev/vda1 /mnt/bootroot@archiso ~ # swapon /dev/vg_archlinux/lv_swap

3.4 Install packages

Install base, sudo, grub, lvm2 and openssh with pacstrap.

root@archiso ~ # pacstrap /mnt base sudo grub lvm2 openssh==> Creating install root at /mnt==> Installing packages to /mnt:: Synchronizing package databases…

A detail of package group is here.

3.5 Create fstab

Create /etc/fstab with genfstab.

root@archiso ~ # genfstab -p /mnt > /mnt/etc/fstabroot@archiso ~ # cat /mnt/etc/fstab# UUID=eb0a11e4-463d-4bec-8fe5-89b856eeec1b/dev/mapper/vg_archlinux-lv_root / ext4 rw,relatime,data=ordered 0 1# UUID=1ae02bc4-24eb-4b0f-b2e5-53f3a295cdfa/dev/vda1 /boot ext4 rw,relatime,data=ordered 0 2# UUID=81080828-7edb-4b95-8d88-4ed4d2ee736f/dev/mapper/vg_archlinux-lv_swap none swap defaults 0 0

4 Configuration with arch-chroot

Change root to /mnt with arch-chroot.

root@archiso ~ # arch-chroot /mnt[root@archiso /]#

4.1 Enable service

Enable dhcpcd.service and sshd.service. dhcpcd.service is a service for DHCP client.

[root@archiso /]# ln -s /usr/lib/systemd/system/dhcpcd.service /etc/systemd/system/multi-user.target.wants/dhcpcd.service[root@archiso /]# ln -s /usr/lib/systemd/system/sshd.service /etc/systemd/system/multi-user.target.wants/sshd.service

4.2 Set hostname

Set hostname to /etc/hostname.

[root@archiso /]# echo archlinux-20171001 > /etc/hostname

4.3 Create locale

Create /etc/locale.gen and /etc/locale.conf. This article uses en_US.UTF-8.

[root@archiso /]# sed -e ‘s/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g’ -i /etc/locale.gen[root@archiso /]# locale-genGenerating locales… en_US.UTF-8… doneGeneration complete.[root@archiso /]# echo “LANG=en_US.UTF-8” > /etc/locale.conf

4.4 Set root password

Set root password.

[root@archiso /]# passwdEnter new UNIX password:Retype new UNIX password:passwd: password updated successfully

4.5 Enable sudo

Remove comment before %wheel.

[root@archiso /]# sed -i /etc/sudoers -e ‘s/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g’

4.6 Create user

Create user.

[root@archiso /]# useradd -m hiroom2

Set user password.

[root@archiso /]# passwd hiroom2Enter new UNIX password:Retype new UNIX password:passwd: password updated successfully

Add user to wheel group which can use sudo.

[root@archiso /]# gpasswd -a hiroom2 wheelAdding user
hiroom2 to group wheel

4.7 Create initramfs

Add a lvm2 script to initramfs.

[root@archiso /]# sed -e ‘s/^HOOKS=”(.*)”/HOOKS=”1 lvm2″/g’ -i /etc/mkinitcpio.conf

Create initramfs with mkinitcpio.

[root@archiso /]# mkinitcpio -p linux==> Building image from preset: /etc/mkinitcpio.d/linux.preset: ‘default’ -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img==> Starting build: 4.13.3-1-ARCH -> Running build hook: [base] -> Running build hook: [udev] -> Running build hook: [autodetect] -> Running build hook: [modconf] -> Running build hook: [block] -> Running build hook: [filesystems] -> Running build hook: [keyboard] -> Running build hook: [fsck] -> Running build hook: [lvm2]==> Generating module dependencies==> Creating gzip-compressed initcpio image: /boot/initramfs-linux.img==> Image generation successful==> Building image from preset: /etc/mkinitcpio.d/linux.preset: ‘fallback’ -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect==> Starting build: 4.13.3-1-ARCH -> Running build hook: [base] -> Running build hook: [udev] -> Running build hook: [modconf] -> Running build hook: [block]==> WARNING: Possibly missing firmware for module: aic94xx==> WARNING: Possibly missing firmware for module: wd719x -> Running build hook: [filesystems] -> Running build hook: [keyboard] -> Running build hook: [fsck] -> Running build hook: [lvm2]==> Generating module dependencies==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-fallback.img==> Image generation successful

4.8 Install GRUB

Change “root=UUID=xxx” of kernel parameter to “root=/dev/xxx”.

[root@archiso /]# sed -i /etc/default/grub -e ‘s/^#GRUB_DISABLE_LINUX_UUID=true/GRUB_DISABLE_LINUX_UUID=true/g’

Install GRUB to /boot and MBR of /dev/vda.

[root@archiso /]# grub-install –boot-directory=/boot /dev/vdaInstalling for i386-pc platform.Installation finished. No error reported.

Update grub.cfg.

[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfgGenerating grub configuration file … WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning. WARNING: Failed to connect to lvmetad. Falling back to device scanning.Found linux image: /boot/vmlinuz-linuxFound initrd image(s) in /boot: initramfs-linux.imgFound fallback initrd image(s) in /boot: initramfs-linux-fallback.imgdone

Reboot system and boot ArchLinux from /dev/vda.

sh-4.3# exitroot@archiso ~ # umount /mnt/bootroot@archiso ~ # umount /mntroot@archiso ~ # reboot

5 Run ArchLinux

GRUB in /dev/vda starts.

0006_GRUB.png

Login prompt is displayed. If DHCP server is running in your network, IP address is assigned with dhcpcd.

0007_LoginPrompt.png

Android | Linux | SDL - Narrow Escape