ArchLinux:Installation: Difference between revisions
Line 147: | Line 147: | ||
Use the {{mono|refind-install}} script that comes pre-packaged with rEFInd to simplify the process of setting up rEFInd. We will be installing rEFInd onto the default/fallback boot path {{mono|/EFI/BOOT/BOOT*.EFI}}. This is extremely useful for certain systems, ones that require {{mono|/EFI/*/*.EFI}} to be signed in BIOS, and/or booting from USB flash drives. | Use the {{mono|refind-install}} script that comes pre-packaged with rEFInd to simplify the process of setting up rEFInd. We will be installing rEFInd onto the default/fallback boot path {{mono|/EFI/BOOT/BOOT*.EFI}}. This is extremely useful for certain systems, ones that require {{mono|/EFI/*/*.EFI}} to be signed in BIOS, and/or booting from USB flash drives. | ||
{{Console|1=refind-install --usedefault /dev/sdX2 --alldrivers}} | {{Console|1=refind-install --usedefault /dev/sdX2 --alldrivers}} | ||
Take the UUID for {{mono|sdX1}} and plug it into {{mono|refind.conf}} (look for the Arch Linux section). | Take the UUID for {{mono|sdX1}} and plug it into {{mono|refind.conf}} (look for the Arch Linux section). Be sure to update all the paths correctly, add in microcode if applicable and remove the {{mono|disabled}} setting. | ||
{{Console|1=blkid /dev/sdX1|2=vim /boot/EFI/BOOT/refind.conf}} | {{Console|1=blkid /dev/sdX1|2=vim /boot/EFI/BOOT/refind.conf}} | ||
When finished it should look something like this: | When finished it should look something like this: | ||
{{Console|prompt=false|root{{=}}PARTUUID{{=}}ec71be76-c4a6-467a-aa88-683d58e3a4fd}} | {{Console|prompt=false|1=menuentry <mark class="magenta2">"Arch Linux"</mark><br/> icon /EFI/BOOT/icons/os_arch.png<br/> volume <mark class="magenta2">"Arch Linux"</mark><br/> loader /vmlinuz-linux<br/> initrd /intel-ucode.img /initramfs-linux.img<br/> options <mark class="magenta2">"root{{=}}PARTUUID{{=}}ec71be76-c4a6-467a-aa88-683d58e3a4fd rw add_efi_memmap"</mark><br/> submenuentry <mark class="magenta2">"Boot using fallback initramfs"</mark> {<br/> initrd /intel-ucode.img /initramfs-linux-fallback.img<br/> }<br/> submenuentry <mark class="magenta2">"Boot to terminal"</mark><br/> add_options <mark class="magenta2">"systemd.unit=multi-user.target"</mark><br/> }<br/>} }} | ||
Exit out of the chroot environment. | Exit out of the chroot environment. | ||
{{Console|1=exit}} | {{Console|1=exit}} |
Revision as of 10:32, 11 July 2017
UNDER 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:
VirtualBox 5.1.22 r115126 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.
To start sync the systems time and date.
root ~ # timedatectl set-ntp true root ~ # timedatectl status |
Verify Boot Mode
Verify that the motherboard has UEFI enabled. If this outputs a list of variables, the computer has successfully booted into EFI mode.
root ~ # efivar -l |
Keyboard Keymap
If using a non-US keymap, specify which keymap to load.
root ~ # ls /usr/share/kbd/keymaps/ |
Organization is laid out in directories as Machine Type / Keyboard Type, take the filename without the extension and plug it into the command loadkeys.
root ~ # loadkeys de-latin1 |
Networking/Wireless
Make sure the network is connected and internet access is working (for wired network connections, dhcp was loaded on boot).
root ~ # ping archlinux.org |
Performing the installation over wireless requires manual setup. 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 bring it up first.
root ~ # ip link set wlan0 up |
With the interface activated, get a list of all available access points (AP) nearby.
root ~ # iw dev wlan0 scan | less |
Depending on what type of encryption the AP is using for the network, 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") |
Verify that the wireless network was brought up properly.
root ~ # iw dev wlan0 link |
Installation via SSH
Installing remotely from another computer using SSH can be a lot faster, but requires the use of another machine. Remember, copy and paste work over SSH.
To start ssh in the installation environment, start the openssh service with systemd and then set the root password.
root ~ # systemctl start sshd root ~ # passwd |
Use the ip addr command to find the IP address assigned to the machine. Logging in remotely as the root account with the password setup previously should now be possible.
Hard Drive Setup
If you are installing Arch in conjunction with Mac OS X and/or Windows, partitions will be Apple Core storage and HPFS/NTFS/exFAT respectively. |
Before we can begin the installation we 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 addressable storage space to 232 x 512 bytes or 2TB. The operating systems (OS) that cannot boot from GPT are Windows XP and all prior versions. 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 ~ # lsblk |
We can safely ignore the ones mounted from /run/archiso as these are the live disc image we booting from.
Having located the drive we are going to be using for Arch, make note of the device node the disks uses.
Partitioning
Filesystem | Mountpoint | Size | Description |
---|---|---|---|
Linux | / | * | root partition |
EFI System | /boot | 200M | boot partition |
For 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.
root ~ # dd if=/dev/zero of=/dev/sdX bs=1k count=2048 |
WARNING: 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.
root ~ # sgdisk -z /dev/sdX |
Write a new GPT partition table with protected MBR.
root ~ # 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.
root ~ # 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.
root ~ # 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.
root ~ # sgdisk -A 2:set:2 /dev/sdX |
If 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.
If sgdisk has been complaining that the linux kernel is caching partition information, you should reboot before continuing.
Formatting/Mounting
With the partitions setup, they now need to be formatted.
For the root filesystem, using metadata_csum will enable metadata checksums for added protection against disk corruption.
root ~ # mkfs.ext4 -O metadata_csum /dev/sdX1 |
Format the EFI System partition with FAT32.
root ~ # mkfs.fat -F32 /dev/sdX2 |
Mount the partitions, take care of the order.
root ~ # mount /dev/sdX1 /mnt root ~ # mkdir /mnt/boot root ~ # mount /dev/sdX2 /mnt/boot |
Installation
Now that the disk(s) are setup and mounted in the correct directories, begin the Arch Linux bootstrap process.
Base Packages
Install the base and base-devel package groups, the rEFInd Boot Manager and the sudo and vim packages. When not using WiFi, the dialog and wpa_supplicant packages can safely be removed from the list. If the system has an Intel-based CPU the intel-ucode package is required.
root ~ # pacstrap /mnt base base-devel dialog efibootmgr intel-ucode refind-efi sudo vim wpa_supplicant |
Fstab
Generate an fstab file so that Arch knows what to mount on boot. Using the -U option will use UUIDs for the source partitions, this has the advantage of not changing if the hard drive is plugged into another computer.
root ~ # genfstab -U -p /mnt >> /mnt/etc/fstab |
Be sure to confirm it was generated correctly (UUIDs line up).
root ~ # blkid /dev/sdX1 && blkid /dev/sdX2 && cat /mnt/etc/fstab |
In order to ext4 journal data structures also gain checksums add ,journal_checksum to the mounting options on boot.
root ~ # sed -i 's/data=ordered/data=ordered,journal_checksum/' /mnt/etc/fstab |
Again confirming this change is not a bad idea.
If you are using an SSD you might want to consider adding ,discard to the mounting options as well. |
Chroot into Install
Change root into the new system.
root ~ # arch-chroot /mnt |
Begin configuration by setting a root password.
# passwd |
Modify the mkinitcpio.conf in order to load the required kernel module for ext4 checksums on boot and then create the initramfs (initial RAM disk filesystem) image.
# sed -i 's/^MODULES=""/MODULES="crc32c-intel"/' /etc/mkinitcpio.conf # mkinitcpio -p linux |
Finally add a new user account and give the wheel group sudo access.
# useradd -m -g users -g wheel -s /bin/bash kyau # passwd kyau # sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers |
Due to the ability to lock yourself out of your own system you should always use visudo in order to edit sudoers. Given the system is not live yet and only in a chroot environment, this one time can be forgiven. |
Boot Loader
Use the refind-install script that comes pre-packaged with rEFInd to simplify the process of setting up rEFInd. We will be installing rEFInd onto the default/fallback boot path /EFI/BOOT/BOOT*.EFI. This is extremely useful for certain systems, ones that require /EFI/*/*.EFI to be signed in BIOS, and/or booting from USB flash drives.
# refind-install --usedefault /dev/sdX2 --alldrivers |
Take the UUID for sdX1 and plug it into refind.conf (look for the Arch Linux section). Be sure to update all the paths correctly, add in microcode if applicable and remove the disabled setting.
# blkid /dev/sdX1 # vim /boot/EFI/BOOT/refind.conf |
When finished it should look something like this:
menuentry "Arch Linux" icon /EFI/BOOT/icons/os_arch.png volume "Arch Linux" loader /vmlinuz-linux initrd /intel-ucode.img /initramfs-linux.img options "root=PARTUUID=ec71be76-c4a6-467a-aa88-683d58e3a4fd rw add_efi_memmap" submenuentry "Boot using fallback initramfs" { initrd /intel-ucode.img /initramfs-linux-fallback.img } submenuentry "Boot to terminal" add_options "systemd.unit=multi-user.target" } } |
Exit out of the chroot environment.
# exit |
Unmount all partitions and reboot the system.
root ~ # umount -R /mnt && reboot |
References
- ^ "ArchWiki". Partitioning: Choosing between GPT and MBR. https://wiki.archlinux.org/index.php/Partitioning#Choosing_between_GPT_and_MBR.