Here is a common trap that many new Arch Linux users fall into: Immediately after booting into their brand-new Arch Linux installation, they find that they have no Internet access and are stuck on what to do next. Part of the ethos of Arch Linux is that you'll want to understand what's going on under the hood. So I'll explain what's going on under the hood before "giving the solution" at the end.
The most common way to install Arch Linux is to download the ISO image, burn it onto a CD or USB key, and boot from that ISO image. The environment you end up in is itself an Arch Linux environment called Archiso. Within Archiso, you would then typically reformat/repartition your hard drive, install a base system onto the hard drive, boot from your hard drive (and NOT from Archiso), and then proceed to use your computer from there.
The key insight here is that the Arch Linux environment on your hard drive and the Arch Linux environment provided by Archiso are distinct. In particular, Archiso may have some networking software installed that enabled it to access the Internet. If you do not also install that software into the environment on your hard drive, then you may not be able to access the Internet from your primary Arch Linux environment.
Specifically, the Archiso environment has the packages dhcpcd
and iwd
installed. The dhcpcd
package provides a DHCP client, allowing your computer to acquire an IP address. The iwd
package provides functionality for wireless internet (i.e. WiFi).
There are alternative packages, and if you "know what you're doing", you can choose to use those alternatives instead. But if you don't have enough context to decide between the alternatives, and if the Archiso environment works fine for you, you can replicate its networking configuration by ensuring you install those two packages. If you’re only using a wired connection, you can install just the dhcpcd
package and skip the iwd
package.
The most straightforward way to do this is to restart the installation process from scratch. Then, when you get to the step of installing packages onto your hard drive, make sure you also install the relevant networking packages. This would be after you've chroot
'ed into your Arch Linux environment.
However, you can also just perform the step of installing those two packages without repeating the whole installation process. I'll explain how to do this next.
First, you'll need to boot into your Archiso environment (from the CD or USB key) again. Then confirm that you have a working Internet connection there (for example, by running ping google.com
). If the Internet doesn't work even in the Archiso environment, you'll have to debug that first (and remember what you did to fix it, so that you can do the same thing to the Arch Linux environment on the hard drive).
You've presumably already partitioned and formatted your hard drives and pacstrap
'ed the base system onto your hard drive, so you can skip all those steps from the installation. Instead, you'll want to remount your partitions onto the Archiso file system in the same way as you did during the installation and then chroot into it (via the arch-chroot
command).
Now what's pretty deceptive here is that you'll find that your Internet still seems to work, even after having chroot
'ed into your Arch Linux system environment. This is because the Internet connection from the Archiso environment actually carries over here. Unfortunately, that means it's difficult to test whether you've fixed the issue in a chroot
'ed session.
Anyway, once you're chroot
'ed into your Arch Linux environment, simply install the packages as usual (i.e., pacman -S dhcpcd
). Then exit out of the chroot environment, optionally unmount the hard drives, and then reboot the system via the reboot command. Finally, remove the USB key or CD so that on the next boot-up, you end up in the Arch Linux environment on your hard drive.
When you next boot into your Arch Linux environment, if you immediately try the ping command, you’ll notice your internet still isn’t working. This is because we need to configure systemd to automatically start the dhcpcd service on boot-up. Run systemctl start dhcpcd.service
to have it run right now, and then type in systemctl enable dhcpcd.service
to have it start on every subsequent boot-up. Similarly, you may need to run start and enable the iwd.service
if you need WiFi access. At this point, the ping command should finally work, and you should have a working Internet connection.
You might want to amend this to suggest installing the packages from the beginning. The pacstrap command doesn''t have to be limited. The user can simply append dhcpcd (and anything else) to it and it will be installed. I use a long list of additions that I use whenever I install Arch on a system. I find it much easier.
My own approach to wifi is to add dhcpcd and wpa_supplicant to the pacstrap command. Enable dhcpcd from arch-chroot. Link dhcpcd's 10-wpa_supplicant file to /usr/lib/dhcpcd/dhcpcd-hooks/. Create a wpa_suppplicant.conf for /etc/wpa_supplicant folder. Once that's done, the installed Arch will always automatically connect to the wifi SSID, including on its first boot.
I understand that that approach may be too difficult for a newbie, but I think that using pacstrap to install dhcpcd (and anything else) is easier than going through the steps you've outlined.