Friday, July 8, 2016

archlinux - installation

Just another learner's howto install the archlinux on top of VMWare VM.

1. Download from the latest version as of july/2016 (from HK mirror) or choose from the available hosts from

Then boot from ISO to begin proper installation. It will automatically login with root user.

- check whether the internet connection is working:

# ping -c 3

The DHCP daemon is supposed to start automatically when running the live system from ISO. If it does not work, check network configuration page (reference below).

2. Preparing storage (partitioning and formatting)
- Identify the devices where the new system will be installed:

# lsblk

Usually, and I believe for most of cases, the device name is SDA.

- Partitioning: the plan is to make simple partition using GPT format:
/dev/sda1 - BIOS boot partition
/dev/sda1 - boot (512mb) with bootable flag
/dev/sda2 - swap (2gb)
/dev/sda3 - root (remainder)

To achieve this, I am going to use # parted as per below:

# parted /dev/sda

parted prompt:
# mklabel gpt
# mkpart ESP fat32 1MiB 513MiB
# set 1 boot on
# mkpart primary linux-swap 513MiB 2.5GiB
# mkpart primary ext3 2.5GiB 100%
# quit

- Formatting: execute # lsblk to see whether the partitions were created correctly.
# mkfs.fat -F32 /dev/sda1 #first partition - boot
# mkswap /dev/sda2        #second partition - swap
# swapon /dev/sda2        #activate swap
# mkfs.ext4 /dev/sda3     #third partition - root

3. Mounting the partitions:
# mount /dev/sda3 /mnt       #Mount the root partition
# mkdir -p /mnt/boot         
# mount /dev/sda1 /mnt/boot  #Mount the boot partition

4. Installing the base package:
# pacstrap -i /mnt base base-devel grub sudo vim net-tools linux-headers abs 

5. Configuring the system:
- Generate FSTAB
# genfstab -U /mnt >> /mnt/etc/fstab

- Chroot to new mount system root
# arch-chroot /mnt /bin/bash

- Setup Locale and Time:
edit /etc/locale.gen and uncomment the needed localisations e.g. en_US.UTF-8 UTF-8. Save the file, and generate the new locales:
# nano /etc/locale.gen
# locale-gen

create file /etc/locale.conf with the uncommented lines e.g. en_US.UTF-8
# echo LANG=en_US.UTF-8 >> /etc/locale.conf

select a time zone and create the symbolic link /etc/localtime, where Zone/Subzone is the TZ value from tzselect:
# tzselect
# ln -s /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime

6. Installing a boot loader: there are few choices for boot loaders; the one that is going to be installed is GRUB:
# grub-install /dev/sda
- since this system is being installed in a virtual machine, the above command will result in a error; as a result, the option --force must be added as below:
# grub-install --force /dev/sda
- at last:
# grub-mkconfig -o /boot/grub/grub.cfg

7. Re-generate the initramfs image:
# mkinitcpio -p linux

8. Adjust network configuration for the next boot:
# cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/ethernet-dhcp
- edit the new profile /etc/netctl/ethernet-dhcp - line interface with the correct network adapter (may be obtained by command ip link);
- start the netctl:
# netctl start ethernet-dhcp
- make the netctl auto start at boot:
# netctl enable ethernet-dhcp

9. Set the root password:
# passwd

10. Set the hostname:
# echo any_hostname >> /etc/hostname

update 2016-09-11 - The hostname can be set after initial reboot by using the following command:
# hostnamectl set-hostname <any_hostname>

11. Add new users:
# useradd -m -g users -G wheel -s /bin/bash user_name
# passwd user_name

12. Allow new users to sudo:
# visudo
and uncomment the lines below:
## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

13. Exit from the chroot environment, umount the partitions and reboot the system:

# exit
# umount -R /mnt
# reboot

14. Syncronize and update the system:
# pacman -Syu


No comments:

Post a Comment