Installing Arch Linux on a Thinkpad L380

The installation of Arch Linux is often seen as a daunting proposition for those who are unfamiliar with the command line hackery many admins perform day-to-day. Although the initial learning curve is quiet steep, you will find yourself all the better for it after you can complete the installation with minimal hassle. To this end, I have thrown what I had on hand at the wall and written about the particular pieces that have stuck. This may not be the most thorough and technical walk through, but I hope that it can provide some assistance to those who find themselves baffled as to what to do next. This particular walk through is intended to work on the Lenovo Thinkpad L380. While some steps may work for other computers and installations, I will not make any promises as the the efficacy of this walk through for any other device.

Preparing the device

For this portion, you will need to obtain the Arch Linux iso. Specifically, you will need the iso file that is intended for the x86-64 chipsets. You will also need to download a program, such as Rufus, to create a bootable drive that will allow you to load the operating system for installation.

First, ensure that you have all you important files backed up to prevent the loss of important data. This installation process will make your files irrecoverable because we will later be formatting the drive to install the operating system.

Second go the the system’s bios menu and disable secure boot. This is done by pressing f1 at boot. The option will be under the “Security” tab and it will be called “Secure boot.” Save and restart the device.

Finally, with the USB device inserted, press f12 to enter the boot menu. In this menu, you will select the device containing Arch Linux to boot from. Choose the “Arch Linux” and enter the Arch Linux environment.

Step One: Wifi-menu

Although there are other methods to get your device online, I did not have the appropriate adapter for physically connecting my laptop to my network. I met some difficulties using wpa_supplicant but I found that wifi-menu was able to easily get me online. Simply run the following command:

root@archiso~# wifi-menu -o

You will be presented with an interface that will show you the surrounding available networks. Choose your own and enter your password to connect to the internet. Run the “ping” command to ensure that you have connectivity.

Step Two: Clock sync

Next we will set the system clock to ensure that logs are accurate and enter a second command to check that the initial command worked:

root@archiso~# timedatectl set-ntp true
root@archiso~# timedatectl status

Step 3: Partitioning

For this step, I have elected to create 3 partitions. The first partition will store the boot information, the second partition will house my root directory, and the third partition will be for user home directories. I decided to not create a swap partition because I came to the conclusion that a swap file would afford more flexibility.

Begin by finding the names of the storage devices connected to your computer

root@archiso~# lsblk
         NAME…     SIZE… TYPE MOUNTPOINT
         loop0
         sda                    //this is my bootable flashdrive
         mmcblk0        //this was an sd card I forgot to remove
         nvme0n1        //this the laptop ssd

Your device will be referred to as /dev/[device name] in all the following commands

Run gdisk to begin the partitioning process. I will put the entirety of this in one section with comments that will briefly describe or provide some context.

root@archiso~# gdisk
    GPT fdisk (gdisk) version 1.0.4
    
    Type device filename, or press <enter> to exit: /dev/nvme0n1 
    Partition table scan:   //this may be different for you 
        MBR: protective
        BSD: not present
        APM: not present
        GPT: present
    Found valid GPT with protective MBR: using GPT

    Command (? for help): d     //delete the exiting partitions
    Partition (1 - 3): 1        //repeat these deletions for all partitions 
    
    Command ( ? for help): i    //this will show information about the partitions
    No partitions
    Command ( ? for help): n    //add a new partition
    Partition number(1-128, default 1): 1   //select the first position
    First sector (2048-XXXX, default = 2048) or {+-}size{KMGTP}:   //default is fine
    Last sector (2048-XXXX, default = XXXX) or {+-}size{KMGTP}: +550M
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): ef02
    Changed type of partition to 'Linux x86-64 root (/)'
    
    Command ( ? for help): n    //add a new partition
    Partition number(2-128, default 1): 2   //select the first position
    First sector (YYYY-XXXX, default = YYYY) or {+-}size{KMGTP}:   //default is fine
    Last sector (YYYY-XXXX, default = XXXX) or {+-}size{KMGTP}: +28G
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): 8304
    Changed type of partition to 'Linux x86-64 root (/)'
    
    Command ( ? for help): n    //add a new partition
    Partition number(3-128, default 1): 3   //select the first position
    First sector (YYYY-XXXX, default = YYYY) or {+-}size{KMGTP}:    //default is fine
    Last sector (YYYY-XXXX, default = XXXX) or {+-}size{KMGTP}:     //default is fine if you are using the rest of the disk, otherwise specify
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): 8302
    Changed type of partition to 'Linux /home'
    
    Command ( ? for help): i    //look at your partitions to ensure that they are correct
    
    Command ( ? for help): w    //write the changes to the disk
    
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
    
    Do you want to proceed? (Y/N): y
    OK; writing new GUID partition table (GPT) to /dev/nvme0n1.
    The operation has completed successfully. 
    
    root@archiso~#

If it seems unclear or you prefer a different partitioning program, google how to apply the following:

  1. bios boot partition(code: EF02), size: 550.0 MiB
  2. linux x86-64 root (/)(code: 8304), size: 28 GiB (splitting the difference here, feel free to use more or less space(within the recommendations))
  3. linux /home (code: 8302), size: remainder of the disk

Now that the partitions have been created, we need to format them for use by Arch. I have elected to use ext4 because it is well supported and has the proper utilities to keep the ssd healthy. Run “lsblk” to find the name of your partitions. These will be referred to as “/dev/[device partition name]” in all the following commands.

 root@archiso~# lsblk
        Name            SIZE    TYPE    MOUNTPOINT
        ...
        ...
        ...
        nvme0n1                 disk
            nvme0n1p1   550M    part
            nvme0n1p2   28G     part
            nvme0n1p3   210G    part

Next we will format the partitions. The boot partition will need to be in fat32 and the two remaining OS partitions will be in ext4.

root@archiso~# mkfs.fat /dev/nvme0n1p1         //boot directory
root@archiso~# mkfs.ext4 /dev/nvme0n1p2     //root directory
root@archiso~# mkfs.ext4 /dev/nvme0n1p3     //home directory

Now that the partitions are ready, we need to mount them. We will need to create two additional directories within /mnt to mount all our partitions

root@archiso~# mkdir /mnt/boot 
root@archiso~# mkdir /mnt/home 
root@archiso~# mount /dev/nvme0n1p2 /mnt
root@archiso~# mount /dev/nvme0n1p1 /boot 
root@archiso~# mount /dev/nvme0n1p3 /home

Step Four: Rank your mirrors

We’re going to begin by ranking mirrors so that we use the fastest mirrors. Begin by backing up your mirror list

root@archiso~# cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup

Now download the mirror list for your area. I will be using Los Angeles.

root@archiso~# curl -s "https://www.archlinux.org/mirrorlist/?country=US&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' >> mirrorlist.new

Open the downloaded file to ensure that you downloaded the correct file.

root@archiso~# cat /etc/pacman.d/mirrorlist.new

Now we can rank the mirror list and refresh it.

root@archiso~# rankmirrors -n 6 /etc/pacman.d/mirrorlist.new
root@archiso~# cp /etc/pacman.d/mirrorlist.new /etc/pacman.d/mirrorlist
root@archiso~# pacman -Syyu

Step 5: Initial installation and configuration

At this point, you should have your partitions formatted with the proper filesystems and mounted to the proper mount points. If not, go back and follow the steps to complete these two tasks.

First, were going to install the ‘base’ package to /mnt where out root directory is located. It will complete with a couple warnings that we can safely ignore.

root@archiso~# pacstrap /mnt base

After that completes, generate the fstab file. It is important that all your partitions are mounted at this point. If you don’t, you may face issues trying to boot later and you will need to manually edit the fstab file to fix the issue.

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

At this point, you should now log into the root account of the installed system. Be aware that while you have access to the tools on the USB drive at this point, removing and rebooting will leave you with many of these tools missing due to the minimalist nature of the installed OS.

 root@archiso~# arch-chroot /mnt

The shell will now look something like this

[root@archiso /]# 

From here, we will be following the Arch Installation guide pretty closely. I will be putting the options that I have chosen for the Los Angeles, US area beginning with the Time Zone.

[root@archiso /]# ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Next we generate the /etc/adjtime file

[root@archiso /]# hwclock --systohc

Now, localization changes and generate the configuration file. Remove the “#” from the “en_US.UTF-8 UTF-8” line and generate.

[root@archiso /]# nano /etc/locale.gen //ctrl + X to save and exit from nano editor
[root@archiso /]# locale-gen

Now, create the locale.conf file and set LANG variable to your language. I will be adding the line, LANG=en_US.UTF-8

[root@archiso /]# nano /etc/locale.conf     //ctrl + X to save and exit

Finally, set the keyboard layout by adding the line “KEYMAP=us” for US key mapping

[root@archiso /]# nano /etc/vconsole.conf   //ctrl + X to save and exit

Step 6: Network Configuration

Unfortunately, the base package does not install the necessary utilities to connect wirelessly. While you can skip this step if you can physically connect to a network, I was not able to do so. This required me to install some extra packages for wireless connectivity.

[root@archiso /]# pacman -S wpa_supplicant
[root@archiso /]# pacman -S dialog

Now we can create a hostname file for the machine and matching entries in the hosts file

[root@archiso /]# nano /etc/hostname    //add line that contains your pc hostname without surrounding ""
        "hostname"
    [root@archiso /]# nano /etc/hosts       //should look like the following
        127.0.0.1	localhost
        ::1		    localhost
        127.0.1.1	"hostname".localdomain "hostname"

Step 6: GRUB configuration

This will be different from a typical installation due to having a separate boot partition. Although it it is not necessary, having the boot files on a separate partition affords more flexibility for utilities that I can use with the main partitions.

Begin by installing the “grub” and “efibootmgr” packages that will be used to install GRUB.

[root@archiso /]# pacman -S grub
[root@archiso /]# pacman -S efibootmgr

Direct the grub application to install to the /boot partition. Earlier, we mounted this to /boot. If you mounted this somewhere else, specifiy the location in the “–efi-directory=XXXX” portion. “–bootloader-id=GRUB” identifies the grub boot entry.

[root@archiso /]# grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB

Now we need to enable microcode updates for the cpu. This particular laptop has an intel chip; so, we will use the intel microcode updates.

[root@archiso /]# pacman -S intel-ucode

We are now ready to generate the grub configuration file

[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg

Now you can exit the root environment, shutdown, remove the installation media, and reboot.

[root@archiso /]# exit
root@archiso~# shutdown -P now

After booting into the system, login and create a root password

[root@archiso /]# passwd

Use wifi-menu to connect to the internet, the -o option will let you use netctl later to automatically connect to the internet.

[root@archiso /]# wifi-menu -o 

We also want to install sudo to enable us to use an account besides the root account to make system changes. This is good for having multiple users on a single system because you can dictate what privileges they have.

[root@archiso /]# pacman -S sudo

You can now create a new user and give him or her sudo access

[root@archiso /]# useradd -m USER_NAME
[root@archiso /]# passwd USER_NAME

We will now add the user to a file that grants sudo access. There are other methods to do this, one of which is using the wheel group and adding the user to the wheel group. For the sake of simplicity, I will only show the first method.

[root@archiso /]# visudo
 //Add "USER_NAME ALL=(ALL) ALL" to the visudo opened file to give "USER_NAME" sudo privileges 

Congratulations!

At this point, you should now have a working bare bones Arch Linux installation. From here, I recommend installing a desktop that you find pleasant. I opted to use KDE plasma which I installed using the linked tutorial. If you find any errors in my walk through or know of a better way to go through the installation, let me know and I’ll do my best to include the information in the guide. If you find that you don’t understand something or want a more thorough explanation about why something is happening, I wholly endorse reading through the Arch Linux installation guide. Thank you for reading this far, and I hope I was able to be of some help.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s