ArchLinux:Installation: Difference between revisions

From Wiki³
Line 86: Line 86:
| class="acenter"| /boot
| class="acenter"| /boot
| class="acenter"| 200M
| class="acenter"| 200M
| class="acenter"| optional, use if RAM < 16 GB
| class="acenter"| boot partition
|}
|}
{{Note|1=For the rest of this guide I will be referring to the hard drive you are installing to as {{mono|sdX}}, yours will likely be {{mono|sda}}, {{mono|sdb}}, or some other such variant.}}
{{Note|1=For the rest of this guide I will be referring to the hard drive you are installing to as {{mono|sdX}}, yours will likely be {{mono|sda}}, {{mono|sdb}}, or some other such variant.}}
Line 96: Line 96:
Write a new GPT partition table with protected MBR.
Write a new GPT partition table with protected MBR.
{{Console|1=sgdisk -o /dev/sdX}}
{{Console|1=sgdisk -o /dev/sdX}}
Create our Arch Linux partition, use everything but the last 200MB, and our EFI System partition. We can also set the proper partition types in the same command.
Create our Arch Linux partition (use everything but the last 200MB) and then our EFI System partition with the final 200MB; might as well setup the partition types in the same command.
{{Console|1=sgdisk -n 1:0:-200M /dev/sdX -n 2:-200M:-0 -t 1:8300 -t 2:ef00 /dev/sdX}}
{{Console|1=sgdisk -n 1:0:-200M /dev/sdX -n 2:-200M:-0 -t 1:8300 -t 2:ef00 /dev/sdX}}
For posterity we can set some names to help identify the partitions.
For posterity we can set some names to help identify the partitions.
{{Console|1=sgdisk -c 1:"Arch Linux" -c 2:"EFI Boot" /dev/sdX}}
{{Console|1=sgdisk -c 1:"Arch Linux" -c 2:"EFI Boot" /dev/sdX}}
Just in case we want to boot in Legacy mode we will also set the legacy boot attribute.
{{Console|1=sgdisk -A 2:set 2 /dev/sdX}}
{{Note|If you are a keen observer you will notice we have not made use of a {{mono|swap}} partition, that is because we will be using a swap file instead.}}


== Formatting/Mounting ==
== Formatting/Mounting ==

Revision as of 18:55, 10 July 2017

IconUNDER CONSTRUCTION: The document is currently being modified!

The following tutorial is a collection of notes on how to install the Arch Linux distribution. This guide is mainly suited for use with servers and embedded machines. This tutorial originally started as a YouTube video I had made in early 2012 called How to Install Arch Linux. I then remade this video in late 2012, due to major changes in the installation process, renamed as Arch Linux: System Installation. This tutorial is the spiritual successor to those videos and has been created via the recording notes from said videos.

Following the Arch Linux philosophy, these tutorials are geared at being simple and efficient.

Booting the Installation Media

Place the copy of the Arch Linux image you burned to a disc in your machine and reboot. Enter BIOS if necessary to modify the boot device order in order to boot from the media.

You should be looking at the EFI boot menu, which will auto boot the Arch Linux ISO in a few moments. When your system has finished the boot up process you will be at the console. You may also notice you have been automatically logged into the root account.

For the creation of this tutorial I used the following environment:

Icon VirtualBox 5.1.22 r115126
Icon archlinux-2017.07.01-x86_64.iso

Pre-Installation

There are a few things that you may choose to go through before you begin your installation. None of these are required, but may be extremely useful.

The only thing I would recommend for all is to sync your time and date first.

root ~ # timedatectl status

Verify Boot Mode

You can verify that your motherboard has UEFI enabled with this command, if it outputs a list of variables you have successfully booted into EFI mode.

root ~ # efivar -l

Keyboard Keymap

If you are using a non-US keymap, you will need to specify which keymap to load. Pull up a list of all the keymaps.

root ~ # ls /usr/share/kbd/keymaps/

Organization is laid out in directories as Machine Type / Keyboard Type, if you take the name of the map.gz file without the path of extension you can then plug that into the command loadkeys.

Example for the United Kingdom:

root ~ # loadkeys uk

Networking/Wireless

Check to make sure you have internet access (if you have a wired network connection, dhcp was loaded on boot).

root ~ # ping archlinux.org

If you need to perform the installation over wireless you will need to set this up manually. To do so, get the name of the interface, usually wlan0, and then check to see if your wireless interface is activated.

root ~ # iw dev
root ~ # ip link show wlan0

If the interface is in state DOWN you will need to bring it up first.

root ~ # ip link set wlan0 up

With the interface activated, get a list of all available access points near you.

root ~ # iw dev wlan0 scan | less

Depending on what type of encryption you are using for your network you can connect with one of the following methods:

  • No Encryption
root ~ # iw dev wlan0 connect "YOUR_SSID"
  • WEP
root ~ # iw dev wlan0 connect "YOUR_SSID" key :YOUR_KEY
  • WPA/WPA2
root ~ # wpa_supplicant -i wlan0 -c <(wpa_passphrse "YOUR_SSID" "YOUR_KEY")

You can then verify that you brought the wireless network up properly.

root ~ # iw dev wlan0 link

Installation via SSH

If you wish to install remotely from another computer you will simply need to execute two commands in order to get sshd up and running. First start the openssh service with systemd and then set the root password.

root ~ # systemctl start sshd
root ~ # passwd

You should now be able to login remotely as the root account with the password you have setup. If you need to figure out the IP address assigned to the machine use the ip addr command.

Hard Drive Setup

Before you can begin the installation you must partition and format the hard drives that will be used in the installation. For this we use the GPT partition scheme. GPT (or GUID Partition Table) came about due to the inherit 32-bit limitation in MBR limiting the maximum addresasble storage space to 232 x 512 bytes or 2TB. The only Operating Systems (OS) that cannot boot GPT are Windows pre 2003 (ie. Windows XP and before). Given that GPT forms part of the UEFI standard it will be the defacto choice if you have UEFI enabled.[1]

Pull up a list of all of the disks in your system.

root ~ # fdisk -l

You can safely ignore the one on the bottom that begins with /dev/loop as this is mounted off of the live disc image you are using to install from.

Once you have located the drives you are using for Arch, mark down the device nodes the disks use.

IconIf you are installing Arch in conjunction with Mac OS X and/or Windows, these partitions will be Apple Core storage and HPFS/NTFS/exFAT respectively.

Partitioning

Filesystem Mountpoint Size Description
Linux / * root partition
EFI System /boot 200M boot partition
IconFor the rest of this guide I will be referring to the hard drive you are installing to as sdX, yours will likely be sda, sdb, or some other such variant.

Before we begin it is always good practice to zero the disk out.

# dd if=/dev/zero of=/dev/sdX bs=1k count=2048
IconWARNING: This will wipe the entire disk!
Skip this step if you are only using part of the disk for Arch Linux.

With that taken care of we can begin partitioning with sgdisk. Delete the current partition table, although dd should have taken care of this.

# sgdisk -z /dev/sdX

Write a new GPT partition table with protected MBR.

# sgdisk -o /dev/sdX

Create our Arch Linux partition (use everything but the last 200MB) and then our EFI System partition with the final 200MB; might as well setup the partition types in the same command.

# sgdisk -n 1:0:-200M /dev/sdX -n 2:-200M:-0 -t 1:8300 -t 2:ef00 /dev/sdX

For posterity we can set some names to help identify the partitions.

# sgdisk -c 1:"Arch Linux" -c 2:"EFI Boot" /dev/sdX

Just in case we want to boot in Legacy mode we will also set the legacy boot attribute.

# sgdisk -A 2:set 2 /dev/sdX
IconIf you are a keen observer you will notice we have not made use of a swap partition, that is because we will be using a swap file instead.

Formatting/Mounting

Now that the partition table(s) are setup, let us move on to formatting all of the partitions and get them mounted temporarily for installation of Arch. First create/enable the swap partition if you designated one.

root@archiso ~ # mkswap /dev/sda2
root@archiso ~ # swapon /dev/sda2

Next format all of the partitions that will be used for Arch with the mkfs.ext4 commmand. Then finally mount all of these partition to a temporary directory on the live filesystem.

IconIf you are using the multi-disk setup some of these device nodes will be different.


root@archiso ~ # mkfs.ext4 /dev/sda1
root@archiso ~ # mkfs.ext4 /dev/sda3
root@archiso ~ # mount /dev/sda3 /mnt
root@archiso ~ # mkdir /mnt/{boot,home,var}
root@archiso ~ # mount /dev/sda1 /mnt/boot

In addition if you are using the multi-disk setup, also format and mount the home and var partitions.

root@archiso ~ # mkfs.ext4 /dev/sdb2
root@archiso ~ # mkfs.ext4 /dev/sdb3
root@archiso ~ # mount /dev/sdb2 /mnt/var
root@archiso ~ # mount /dev/sdb3 /mnt/home

Installation

Now that we have the disk(s) setup and mounted in the correct temporary directory we can begin installing Arch Linux and then configure it for its first boot.

Before you install Arch there is one last decision to be made and that is to choose the boot loader you want to use. If this is the only operating system on the computer feel free to choose the Syslinux option as it tends to be simple. If you are attempting to dual boot with another operating system you might want to look into using GRUB instead. In order to keep this article simple I will only be detailing the use of Syslinux, refer to Arch Linux Wiki for details on using GRUB instead.

Begin by installing the base package set and syslinux onto your new system.

root@archiso ~ # pacstrap -i /mnt base syslinux

This will install the base system for Arch, other packages will be installed later on after initial boot.

In order to get a working bootable Arch system you will next have to generate an fstab file. I will be using UUIDs given that they have certain advantages. Switch the -U for -L to use labels instead. Be sure to open the file in an editor afterwards to confirm it was generated correctly. If you are using an SSD as one of the disks then add in ,discard to the options of each of the SSD mount points.

root@archiso ~ # genfstab -U -p /mnt >> /mnt/etc/fstab
root@archiso ~ # nano /mnt/etc/fstab

To proceed, change root into the new system and create the mkinitcpio or the initial RAM disk filesystem.

root@archiso ~ # arch-chroot /mnt /bin/bash
root@archiso ~ # mkinitcpio -p linux

With that finished install the Syslinux bootloader.

root@archiso ~ # syslinux-install_update -iam

Set the root password and then exit out of the chroot environment.

root@archiso ~ # passwd
root@archiso ~ # exit

Finally you can umount all of the mounted partitions and reboot into your new Arch Linux installation.

root@archiso ~ # umount /mnt/{boot,home,var} /mnt
root@archiso ~ # systemctl reboot

Configuration

References