lunasqu.ee-nuxt/content/blog/How-to-install-Arch-Linux.md

220 lines
6.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: How to install Arch Linux
tags:
- linux
- tutorial
date: 2018-03-15 17:21:22
---
Today Im going to instruct you through the steps of installing your own Arch Linux system.
<!-- more -->
## Download the ISO
You can find the [downloads for Arch Linux by clicking here](https://www.archlinux.org/download/).
## 1. Partition the drive
Determine your drive name by running `lsblk`. Run the following command to start the partitioning (with `/dev/sda` replaced by your drive):
```
# fdisk /dev/sda
```
1. Enter `n` to create a new partition.
2. Press Enter on the following prompts to accept the defaults.
3. Enter `w` to write your changes to the disk.
## 2. Create the File System and mount it
Next, you need to create a filesystem on the partition that youve made. After youve created the filesystem, you can mount it.
```
# mkfs.ext4 /dev/sda1
# mount -t ext4 /dev/sda1 /mnt
```
## 3. Install Arch Linux system
This is maybe the most important step in the progress. This is the step where you are actually installing the system. For that, you need to run `pacstrap` followed by the packages you want to install. In this case, well install `base` and `grub` for the bootloader.
```
# pacstrap -i /mnt base grub
```
## 4. Generate File System Tab
The file `fstab` contains descriptive information about the filesystems the system can mount.
```
# genfstab -U -p /mnt >> /mnt/etc/fstab
```
## 5. Enter the system via `chroot`
Now, were ready to set up the system by going inside it. For this, well be running `arch-chroot`. **Do NOT reboot at this stage!**
```
# arch-chroot /mnt /bin/bash
```
## 6. Setting up locales
Locales are basically the language files your system will be using.
```
# nano /etc/locale.gen
Uncomment line en_US.UTF-8 UTF-8
Uncomment line en_US ISO-8859-1
(uncomment by removing the `#` in front)
```
After that, you have to generate the locale files.
```
# locale-gen
```
And then put them into effect on the system.
```
# echo LANG=en_US.UTF-8 > /etc/locale.conf
# export LANG=en_US.UTF-8
```
## 7. Setting the timezone
All timezone files can be found in `/usr/share/zoneinfo/`. You need to create a link to `/etc/localtime` with the timezone you want.
```
# ln -s /usr/share/zoneinfo/LOCATION/CITY /etc/localtime
```
## 8. Set the hardware clock
This command sets the hardware clock from system time. `--utc` implies that your hardware clock is in the UTC timezone. More information [here](https://wiki.archlinux.org/index.php/Time#Hardware_clock)
```
# hwclock --systohc --utc
```
## 9. Set your systems hostname
This can be anything you want.
```
# echo "my-computer" > /etc/hostname
```
## 10. Set up simple networking
Before you do the following, please run `ip a` to determine your interface. Its generally called `eth0`, but it may be different on some machines.
1. Copy the example
```
# cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/my_network
```
2. Modify the interface name
```
# nano /etc/netctl/my_network
Replace the "Interface=eth0" line with the one shown by the "ip a" command.
```
3. Enable the network
```
# netctl enable my_network
```
##
Setting a password on your root user is highly recommended. You can do that now by running `passwd`
##
You can find information on how to install GRUB on various systems on the [Arch Linux Wiki](https://wiki.archlinux.org/index.php/GRUB). The following is a simple installation on a system with a **BIOS** (not **UEFI**). You can find more boot loaders [here](https://wiki.archlinux.org/index.php/Category:Boot_loaders).
```
# grub-install --recheck /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg
```
## 13. Reboot the machine
You are now ready to boot into your new system.
```
# exit
# umount /mnt
# shutdown
```
After shutting down, remove the disk image and boot the system again. **You can now use your newly installed system!**
# More things to do
## Creating an user account
The first user you create should also be added to the `wheel` group. This will be kind of like an administrator.
```
# useradd -m -G wheel -s /bin/bash usernamehere
# passwd usernamehere
```
For creating other users, you should omit the `-G wheel` part unless you want them to be able to use `sudo`.
### Enabling `sudo`
1. Install sudo - `# pacman -S sudo`
2. Create a file in `/etc/sudoers.d/99-wheel` with the following lines:
```
%wheel ALL=(ALL) ALL
```
If you want the `wheel` group to be able to use sudo without password, you can replace the last `ALL` with `NOPASSWD: ALL`.
## Installing a Desktop Environment
Firstly, you should install `xorg` packages.
```
# pacman -S xorg-server xorg-xinit xorg-server-utils mesa xterm
```
For graphics drivers, you can look at the wiki: [Intel](https://wiki.archlinux.org/index.php/Intel_graphics), [ATI](https://wiki.archlinux.org/index.php/ATI), [AMD](https://wiki.archlinux.org/index.php/AMDGPU) and [NVIDIA](https://wiki.archlinux.org/index.php/NVIDIA).
**You can find packages for various desktop environments [here](https://wiki.archlinux.org/index.php/Desktop_environment).**
### Install `lightdm`
Some desktop environments dont have a system to log you in to a session. This is where `lightdm` comes to play.
```
# pacman -S lightdm lightdm-gtk-greeter
# systemctl enable lightdm.service
```
You can find lightdm configuration at `/etc/lightdm/lightdm.conf`.
After youve installed what you want, you can reboot the system and it should either load up the desktop environment or the `lightdm-gtk-greeter`, which will allow you to select a desktop environment to log in to.
## Keeping your system up-to-date
You should keep your system up-to-date to get the latest packages and security patches. Arch Linux is a **rolling release** distribution, meaning that you dont have to reinstall the entire system and package updates are rolled separately instead of in bundles.
```
# pacman -Syu
```
This command synchronizes your system with the latest repositories and installs all available updates.
# Thats it!
This should be your basic Arch Linux system ready to go! Always remember that the [Arch Linux Wiki](https://wiki.archlinux.org/) is a great place to find help for all things Linux, not just Arch!