Skip to content

Instantly share code, notes, and snippets.

@tkiapril
Last active August 29, 2015 14:05
Show Gist options
  • Save tkiapril/9dffcbd30fd42646c9bb to your computer and use it in GitHub Desktop.
Save tkiapril/9dffcbd30fd42646c9bb to your computer and use it in GitHub Desktop.
How to install Arch Linux quick - in a tkistic style

How to install Arch Linux quick - in a tkistic style

Install base system

  1. First, get a latest, fresh ISO image.

  2. Boot.

  3. Load keymap. Typically it will be:

    loadkeys us

    but it should be already loaded for you on boot.

  4. Partition.

    cfdisk /dev/sdX

    Making a swap partition is not recommended unless you are installing it on a notebook.

  5. Format.

    mkfs.FORMAT /dev/sdXn

    Recommended FORMAT is ext4.

  6. Mount the partition under /mnt.

    mount /dev/sdXn /mnt
  7. Edit the /etc/pacman.d/mirrorlist: put your preferred mirror at top. JAIST was the best in my circumstances. In order to edit easily, you might want to install vim. You would also use rankmirrors. Refer to this page.

  8. Install the base packages into your partition.

    pacstrap /mnt base base-devel curl git grub openssh screen tmux vim wget zsh zsh-completions
  9. When it's done, generate fstab.

    genfstab -p /mnt >> /mnt/etc/fstab
  10. chroot into the partition.

    arch-chroot /mnt
  11. Write your hostname.

    echo HOSTNAME >> /etc/hostname
  12. Symlink local time zone.

    ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime
  13. Uncomment locale of your liking from /etc/locale.gen. Typically it would be en_US.UTF-8.

  14. Generate your locales.

    locale-gen
  15. Set locale preferences.

    locale > /etc/locale.conf
  16. Set console keymap and font preferences. In /etc/vconsole.conf:

    # /etc/vconsole.conf
    KEYMAP=us
    FONT=lat2-16
  17. Configure /etc/mkinitcpio.conf. My liking is to change COMPRESSION to cat:

    COMPRESSION="cat"
  18. Create an initial RAM disk with:

    mkinitcpio -p linux
  19. Set a root password with passwd.

Enable services

Enable and start services you would run. All of these commands should be run as root.

```shell
sudo systemctl enable sshd
sudo systemctl start sshd
```

From now on, follow if you are not installing your distribution from a machine different from where it will be distributed (i.e. not on linode). Other than that, reboot and apply after deploy as needed.

Network Configuration

Configure your network. I personally prefer systemd-networkd. All of these commands should be run as root.

  1. Configure /etc/systemd/network/PROFILE_NAME.network (you should have one every NIC).
  • for static IP:
[Match]
Name=INTERFACE_NAME

[Network]
Address=YOUR.IP.ADDRESS.HERE/CIDR
Address=ANOTHER.IP.ADDRESS.HERE/CIDR
Gateway=GATEWAY.IP.ADDRESS.HERE
  • for DHCP:
[Match]
Name=INTERFACE_NAME

[Network]
DHCP=yes

;uncomment this section if you want to *not* use received from the DHCP server as the transient hostname.
;[DHCPv4]
;UseHostname=false
  1. Start systemd-resolvd and link resolv.conf for DNS resolution from DHCP, or if DNS is defined in network files.

    sudo systemctl enable systemd-resolved
    sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
    sudo systemctl start systemd-resolved
  2. Enable and start systemd-networkd.

    sudo systemctl enable systemd-networkd
    sudo systemctl start systemd-networkd
  3. Check network status.

    ip addr
    ping -c3 google.com

Install Bootloader

Install your bootloader. I prefer GRUB.

  • for MBR partitioned disk:

    grub-install --target=i386-pc --recheck --debug /dev/sdX
    grub-mkconfig -o /boot/grub/grub.cfg

Reboot

Reboot to newly installed system.

```shell
exit
umount -R /mnt
reboot
```

Create new user and add to sudoers

  1. Create a new user for typical use. Using root for everyday chores are EVIL.

    useradd -m -G wheel -s /bin/bash USERNAME
  2. Edit sudoers. Before editing, I recommend you to edit your vimrc for easy editing, or install sensible.vim.

    EDITOR=vim sudo visudo
    # visudo
    USERNAME ALL=(ALL) NOPASSWD: ALL

If you enabled sshd and configured network, you can use ssh to work from now on.

Create Swap File

I recommend you use a swap file instead of a swap partition because it is easier to modify. All of these commands should be run as root.

  1. Create file for use as swap file.

    sudo fallocate -l 1024M /swapfile # allocate file for swapfile
    sudo chmod 600 /swapfile # set proper permissions
    sudo mkswap /swapfile # format swapfile as swap
    sudo swapon /swapfile # enable swap
  2. Edit /etc/fstab and add an entry for the swapfile:

    # /etc/fstab
    /swapfile none swap default 0 0

In case you want to remove swapfile:

sudo swapoff /swapfile
sudo rm -f /swapfile

and remove the entry from /etc/fstab.

If you want to resize swapfile, just remove it and regenerate it without removing the fstab entry.

When removing or resizing swapfile, note that swap is managed by systemd and will be re-enabled by it after some time.

Install zsh

Because we installed zsh on system install, we do not have to install the package. However, I will install oh-my-zsh for ease of configuration and themes.

  1. Install oh-my-zsh.

    curl -L http://install.ohmyz.sh | sh
  2. Automatic chsh is likely to fail, so you have to do it for yourself.

    chsh # authorize and type zsh on prompt
  3. Edit ~/.zshrc and change oh-my-zsh theme. I prefer agnoster, which is flavored with powerline-patched fonts and solarized colors. I recommend you to install powerline-patched fonts such as Source Code Powerline if you are going to use agnoster.

    # ~/.zshrc
    ZSH_THEME="agnoster" # it should be residing on top, you should modify it.
  4. Editing ~/.zshrc, change your $EDITOR environmental variable and alias:

    # ~/.zshrc
    export EDITOR="vim"
    alias vi="vim"
  5. Editing ~/.zshrc, enable keypad by appending:

    # ~/.zshrc
    # Keypad
    # 0 . Enter
    bindkey -s "^[Op" "0"
    bindkey -s "^[Ol" "."
    bindkey -s "^[OM" "^M"
    # 1 2 3
    bindkey -s "^[Oq" "1"
    bindkey -s "^[Or" "2"
    bindkey -s "^[Os" "3"
    # 4 5 6
    bindkey -s "^[Ot" "4"
    bindkey -s "^[Ou" "5"
    bindkey -s "^[Ov" "6"
    # 7 8 9
    bindkey -s "^[Ow" "7"
    bindkey -s "^[Ox" "8"
    bindkey -s "^[Oy" "9"
    # + -  * /
    bindkey -s "^[Ok" "+"
    bindkey -s "^[Om" "-"
    bindkey -s "^[Oj" "*"
    bindkey -s "^[Oo" "/"
  6. Change into zsh by:

    exec zsh

Relax on the couch and drink a glass of your favorite drink

You now have installed Arch Linux, tkistic style. Now go on and install other stuff you would use, such as:

  • Edit vimrc.
  • Edit .tmux.conf.
  • Install rvm.
  • Install pyenv.
  • Install mkvirtualenv.
  • Install powerline.
  • and many other geeky things!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment