ArchLinux: Install ArchLinux

This article will describe installing ArchLinux with using LVM, Xfce and LXDM.

ArchLinux does not have a GUI installer like anaconda, so need to install manually.

 

1 Download LiveDVD

Download archlinux-2016.06.01-dual.iso from ArchLinux download page.

2 Run LiveDVD

LiveDVD will display GRUB menu.

This article will append "console=ttyS0,115200" to kernel option with pressing TAG key.

0001_GRUB.png

A login prompt will be displayed after boot LiveDVD.

[  OK  ] Listening on Load/Save RF Kill Switch Status /dev/rfkill Watch.
[  OK  ] Started Serial Getty on ttyS0.
[  OK  ] Started Getty on tty1.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started Initializes Pacman keyring.
[  OK  ] Reached target Multi-User System.

Arch Linux 4.5.4-1-ARCH (ttyS0)

archiso login: root
Last login: Wed Jun  1 20:56:20 on tty1
root@archiso ~ #

3 LiveDVD configuration

This section will describe a configuration on LiveDVD before chroot.

3.1 Disk partitions

/proc/partions before running fdisk are as below.

root@archiso ~ # cat /proc/partitions
major minor  #blocks  name

 254        0   83886080 vda
  11        0     761856 sr0
   7        0     330856 loop0

Run fdisk to /dev/vda.

root@archiso ~ # fdisk /dev/vda

Welcome to fdisk (util-linux 2.28).
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 0x1a1a375b.

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

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

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

Create a partion for LVM which size is about 79.5GByte.

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):
First sector (1026048-167772159, default 1026048):
lasst sector, +sectors or +size{K,M,G,T,P} (1026048-167772159,
 default 167772159):

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

Append boot label to /boot partion.

Command (m for help): a
Partition number (1,2, default 2): 1

The bootable flag on partition 1 is enabled now.

Change label of LVM partition to "Linux LVM".

Command (m for help): t
Partition number (1,2, default 2): 2
Partition type (type L to list all types): 8e

Changed type of partition 'Linux' to 'Linux LVM'.

Update partitions.

Command (m for help): w
The 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/vda
Disk /dev/vda: 80 GiB, 85899345920 bytes, 167772160 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: 0x1a1a375b

Device     Boot   Start       End   Sectors  Size Id Type
/dev/vda1  *       2048   1026047   1024000  500M 83 Linux
/dev/vda2       1026048 167772159 166746112 79.5G 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 2G -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                xCzJB4-GtEf-IdaE-5zyb-C9jq-o35Q-LMH0fn
  LV Write Access        read/write
  LV Creation host, time archiso, 2016-06-02 08:40:06 +0000
  LV Status              available
  # open                 0
  LV Size                2.00 GiB
  Current LE             512
  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                044QxM-XW3y-fM3Z-gO2K-m6LY-zvCp-spJUlJ
  LV Write Access        read/write
  LV Creation host, time archiso, 2016-06-02 08:42:46 +0000
  LV Status              available
  # open                 0
  LV Size                77.51 GiB
  Current LE             19842
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

3.3 Filesystem

Format /dev/vda1 with ext4. Now GRUB2 can access ext4.

root@archiso ~ # mkfs.ext4 /dev/vda1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 512000 1k blocks and 128016 inodes
Filesystem UUID: f9cfa9b6-e430-4401-83af-01f7d1848fff
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

Format /dev/vg_archlinux/lv_root with ext4.

root@archiso ~ # mkfs.ext4 /dev/vg_archlinux/lv_root
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 20318208 4k blocks and 5087232 inodes
Filesystem UUID: 9370cab0-2929-4c99-8e11-4c50a35f00b9
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632,
2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Create swap on /dev/vg_archlinux/lv_swap.

root@archiso ~ # mkswap /dev/vg_archlinux/lv_swap
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=d9f73db0-770f-4d29-a209-ebfc01080bc7

Mount filesystems to /mnt and enable swap.

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

3.4 Install packages

A pacstrap is a tool for cross installation. You need to use this for at least installing base packages which including pacman which is a tool for host installation.

 

This article will install base, sudo, grub, lvm2, openssh, xfce4, xfce4-goodies and lxdm with a pacstrap.

Because a gdm and a lightdm cannot be run on my virtual machine, this article will use lxdm. Because gnome-terminal have a problem which cannot open a terminal, this article will use xfce4.

root@archiso ~ # pacstrap /mnt base xfce4 xfce4-goodies lxdm \
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 fstab

Generate /etc/fstab with genfstab.

root@archiso ~ # genfstab -p /mnt >> /mnt/etc/fstab
root@archiso ~ # cat /mnt/etc/fstab
#
# /etc/fstab: static file system information
#
# <file system> <dir>   <type>  <options>       <dump>  <pass>
# UUID=9370cab0-2929-4c99-8e11-4c50a35f00b9
/dev/mapper/vg_archlinux-lv_root        /               ext4
rw,relatime,data=ordered  0 1

# UUID=f9cfa9b6-e430-4401-83af-01f7d1848fff
/dev/vda1               /boot           ext4
rw,relatime,data=ordered        0 2

# UUID=d9f73db0-770f-4d29-a209-ebfc01080bc7
/dev/mapper/vg_archlinux-lv_swap        none            swap
defaults        0 0

4 chroot configuration

Change root to /mnt with arch-chroot.

root@archiso ~ # arch-chroot /mnt
sh-4.3#

4.1 hostname

Create /etc/hostname.

sh-4.3# echo "archlinux" > /etc/hostname

4.2 locale

Create /etc/locale.gen and /etc/locale.conf. This article will use Japanese UTF-8 locale.

sh-4.3# locale-gen
Generating locales...
Generation complete.
sh-4.3# echo "LANG=ja_JP.UTF-8" > /etc/locale.conf

4.3 sudo

Edit /etc/sudoers with visudo. Remove comment before %wheel as below.

sh-4.3# EDITOR=nano visudo
sh-4.3# diff -uprN /etc/sudoers{.org,}
--- /etc/sudoers.org    2016-06-02 20:42:43.913333333 +0000
+++ /etc/sudoers        2016-06-02 20:43:28.186666661 +0000
@@ -82,7 +82,7 @@ root ALL=(ALL) ALL
 # %wheel ALL=(ALL) ALL

 ## Same thing without a password
-# %wheel ALL=(ALL) NOPASSWD: ALL
+%wheel ALL=(ALL) NOPASSWD: ALL

 ## Uncomment to allow members of group sudo to execute any command
 # %sudo        ALL=(ALL) ALL

4.4 root password

Change root password.

sh-4.3# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

4.5 Create user

Create user who can run sudo.

sh-4.3# useradd -m hiroom2
sh-4.3# gpasswd -a hiroom2 wheel
Adding user hiroom2 to group wheel
sh-4.3# passwd hiroom2
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
sh-4.3# su - hiroom2
[hiroom2@archiso ~]$ ls -la
total 20
drwx------ 2 hiroom2 hiroom2 4096 Jun  2 09:37 .
drwxr-xr-x 3 root    root    4096 Jun  2 09:37 ..
-rw-r--r-- 1 hiroom2 hiroom2   21 Nov 23  2015 .bash_logout
-rw-r--r-- 1 hiroom2 hiroom2   57 Nov 23  2015 .bash_profile
-rw-r--r-- 1 hiroom2 hiroom2  141 Nov 23  2015 .bashrc
[hiroom2@archiso ~]$ sudo ls -a /root
.  ..  .bash_history  .gnupg
[hiroom2@archiso ~]$ exit

4.6 GRUB

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

sh-4.3# diff -uprN /etc/default/grub{.org,}
--- /etc/default/grub.org       2016-06-02 21:05:42.826666637 +0000
+++ /etc/default/grub   2016-06-02 21:05:56.266666657 +0000
@@ -27,7 +27,7 @@ GRUB_GFXPAYLOAD_LINUX=keep

 # Uncomment if you want GRUB to pass to the Linux kernel the old
 # parameter
 # format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
-#GRUB_DISABLE_LINUX_UUID=true
+GRUB_DISABLE_LINUX_UUID=true

 # Uncomment to disable generation of recovery mode menu entries
 GRUB_DISABLE_RECOVERY=true

Install GRUB to /boot and MBR of /dev/vda. Because a grub-install command have a issue with searching valid "root=xxx" for grub.cfg, update grub.cfg with grub-mkconfig.

sh-4.3# grub-install --boot-directory=/boot /dev/vda
Installing for i386-pc platform.
Installation finished. No error reported.
sh-4.3# grub-mkconfig -o /boot/grub/grub.cfg

4.7 initramfs

Add a lvm2 script to initramfs.

sh-4.3# diff -uprN /etc/mkinitcpio.conf{.org,}
--- /etc/mkinitcpio.conf.org    2016-06-02 21:10:11.310000004 +0000
+++ /etc/mkinitcpio.conf        2016-06-02 21:10:39.563333326 +0000
@@ -49,7 +49,7 @@ FILES=""
 #
 ##   NOTE: If you have /usr on a separate partition, you MUST include the
 #    usr, fsck and shutdown hooks.
-HOOKS="base udev autodetect modconf block filesystems keyboard fsck"
+HOOKS="base udev autodetect modconf block filesystems keyboard fsck lvm2"

 # COMPRESSION
 # Use this to compress the initramfs image. By default, gzip compression

Create initramfs with mkinitcpio.

sh-4.3# mkinitcpio -p linux
==> Building image from preset: /etc/mkinitcpio.d/linux.preset:

Reboot system and boot ArchLinux from /dev/vda.

sh-4.3# exit
root@archiso ~ # umount /mnt/boot
root@archiso ~ # umount /mnt
root@archiso ~ # reboot

5 ArchLinux configuration

A tty console will be displayed after booting archlinux because lxdm is not enabled.

 

Enable lxdm.

[root@archlinux ~]# systemctl enable lxdm

Enable dhcpcd which provides dhcp client.

[root@archlinux ~]# systemctl enable dhcpcd

Enable sshd.

[root@archlinux ~]# systemctl enable sshd

Reboot ArchLinux.

[root@archlinux ~]# reboot

LXDM login manager is displayed.

0002_LXDM.png

Xfce desktop runs as below.

0003_Xfce.png