Skip to content

Arch on external disk

On this installation I will install Arch Linux with LXDE on a flash drive from a working Arch setup

The first step is to install the Arch install related stuff.

sudo pacman -S arch-install-scripts  

Disks

Verify the drive you want to partition

lsblk  

Then part it

fdisk /dev/sdx  

In here I will create a new empty DOS partitoin table and make two partitions
A 128Mb partition for boot and the rest for root

The boot partition needs to have the bootable flag

Format boot

mkfs.ext4 /dev/sdx1  

Then root

mkfs.ext4 /dev/sdx2  

Now for the swapfile

mkswap -U clear --size 4G --file /swapfile  

Now mounting the things

Mount root

mount /dev/sdx2 /mnt  

Create directoy for boot

mkdir /mnt/boot  

mount boot

mount /dev/sdx1 /boot  

Activate the swap

swapon /swapfile  

Generate the fstab

genfstab -U /mnt >> /mnt/etc/fstab  

New root

Install the bare minimum

pacstrap /mnt base base-devel linux linux-firmware vim linux-headers  

And move to the system

arch-chroot /mnt  

Local stuff

For the timezone

ln -sf /usr/share/zoneinfo/Portugal /etc/localtime  

Syncing the hardware clock

hwclock --systohc  

Find the language/locale that you want and uncomment that

vim /etc/locale.gen  

Now you need to regenerate the locales

locale-gen  

Add the language you want

vim /etc/locale.conf  

And write something like this.

LANG=en_US.UTF-8  

To define the keyboard layout

vim /etc/vconsole.conf  
KEYMAP=pt-latin9  

Users and network

Set the name for your machine

vim /etc/hostname  

Edit the hosts

vim /etc/hosts  

Write

127.0.0.1     localhost  
::1           localhost  
127.0.1.1     host_name.localdomain host_name  

Replace host_name with the name you wrote on /etc/hostname

Define root password

passwd  

Add a regular user

useradd -m -nome_utilizador  
passwd -nome_utilizador  

Make it a root user

usermod -aG wheel -nome_utilizador  
EDITOR=vim visudo  

In the file uncomment the wheel option

bootloader

pacman -S grub efibootmgr  
grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=GRUB  
grub-mkconfig -o /boot/grub/grub.cfg  

Must say Found linux image and Found initrd image. If it doesn't then the kernel isn't installed.

Graphical interface

pacman -S lxde  

Cleaning up

exit  
umount /dev/sdx1  
umount /dev/sdx2  

On the actual machine

Now you need to put the disk on the main machine boot from a USB drive
You can get the ISO image here and burn it to the drive like so:

umount /dev/sdx1  
sudo dd if=~/Downloads/archlinux-20xx.xx.xx-x86_64.iso of=/dev/sdx conv=fdatasync status=progress  

Now you need to remount everything and chroot

mount /dev/sdx2 /mnt  
mount /dev/sdx1 /boot  
swapon /swapfile  
arch-chroot /mnt  

And now you need to reinstall grub

grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=GRUB  
grub-mkconfig -o /boot/grub/grub.cfg  

Must say Found linux image and Found initrd image. If it doesn't then the kernel isn't installed.

And now it should be done.

exit  
umount /dev/sdx1  
umount /dev/sdx2  
poweroff  

Remove the flash drive and turn on the computer. Everything should work.