joplin-notes/joplin notion extension/linux/Arch Installation in usb flash drive.md
2026-11-04 00:33:23 +05:30

6.4 KiB

Arch Installation in usb flash drive

Arch Installation for a removable USB flash drive:

-> Installing on a 64-bit UEFI non-CSM system. -> using GPT partition style.

Requirements:

-> A USB flash drive with bootable arch linux installation media. -> Another USB where linux is going to be installed, recommended size: 32 GB. -> A desktop computer or laptop for installing arch which supports UEFI.

Pre-Installation:

  1. Insert both of the USB flash drive.
  2. Boot from the USB with the arch installation media.

Follow along in the next unit for installing arch on the USB flash drive.

Installation:

  1. Connect to the internet either by ethernet or wifi.

-> For wifi, use the iwctl utility. -> Open it using the 'iwctl' command.

root@archiso~# iwctl

-> inside it, get the list of all the network devices using the following command.

[iwd]# device list

-> Use the wireless adapter to get scan and get a list of all the available networks.

[iwd]# station scan [iwd]# station get-networks

-> Connecting to the wireless network.

[iwd]# station connect <netowrk_name>

-> Enter the passphrase and check for connectivity using the following.

[iwd]# station show

-> if connected, use the 'exit' command to exit the utility.

  1. Check you internet connectivity using the following.

root@archiso~# ping

  1. Update the system clock.

root@archiso~# timedatectl set-ntp true

  1. List all the disks.

root@archiso~# lsblk

-> disks are in the format of /dev/sd. -> Here, recognise the USB drive disk where arch has to be installed.

  1. Partition the disks.

-> Use the gdisk/ fdisk/ cfdisk command for partitioning the disk. eg. gdisk /dev/sd

-> In this tutorial, I am using 3 partitions for the Linux EFI system, swap and the root. -> Here, denotes the disk letter.

-> Recommended sizes for partitions:

(i) /dev/sd1 -> EFI Partition: 550M (ii) /dev/sd2 -> Swap Partition: 2G (iii) /dev/sd3 -> Root partition: Any of the left space.

  1. Format the disks.

-> Format the disks using the following commands. -> Taking into conideration that the number of paritions is 3 and same as of the above.

-> Formating the EFI partition. root@archiso~# mkfs.fat -F32 /dev/sd1

-> Formating the swap partition. root@archiso~# mkswap /dev/sd2

-> Formatting the root partition. -> Turning off Journaling. root@archiso~# mkfs.ext4 -o "^has_journal" /dev/sd3

  1. Mounting the partitions.

-> Mounting swap partition. root@archiso~# swapon /dev/sda2

-> Mounting the root partition. root@archiso~# mount /dev/sd3 /mnt

-> Mounting the EFI partition. root@archiso~# mkdir -p /mnt/boot/efi root@archiso~# mount /dev/sd1 /mnt/boot/efi

  1. Installing the required packages.

-> I am using the vim editor in this tutorial.

root@archiso~# pacstrap /mnt base linux linux-firmware vim

  1. Generating the format style table.

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

-> -U option for using the UUIDs.

  1. Change root to the mount directory using the 'arch-chroot /mnt' command.

  2. Set your timezone and sync the harware clock.

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

-> Replace and with your region and city. eg: ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

-> Syncing the harware clock. [root@acrhiso /]# hwclock --systohc

  1. Set your locale.

[root@archiso /]# vim /etc/locale.gen

-> The above command will open the locale.gen in vim. Here locate your locale, un-comment it and save the file. -> I will be using the 'en_US.UTF8' locale throught the tutorial.

  1. Generate the locale using the 'locale-gen' command.

  2. Add locale to the locale.conf file.

[root@archiso /]# echo "LANG=en_US.UTF-8" > /etc/locale.conf

  1. Set the host name.

[root@archiso /]# echo "ArchUSB" > /etc/hostname

-> Replace ArchUSB with your hostname.

  1. Edit the hosts file.

[root@archiso /]# vim /etc/hosts

-> The above command will open the hosts file in vim. Here, add the following text (replace the hostname) below the comments in the file.

""" 127.0.0.1 localhost ::1 localhost 127.0.1.1 ArchUSB.localdomain ArchUSB """

-> Save the file and quit.

  1. Edit the mkinitcpio.conf file.

-> As this is a USB flash drive and is going to plugged in more than a single PC, some of the hooks in the mkinitcpio.conf file have to be moved ahead in the order for excepting a normal boot on multiple systems.

[root@archiso /]# vim /etc/mkinitcpio.conf

-> In the file that opens, find the HOOKS variable and move block and keyboard ahead of autodetect as shown below.

-> before HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block filesystems fsck)

-> after HOOKS=(base udev block keyboardautodetect modconf kms keymap consolefont filesystems fsck)

  1. Generate Initramfs using the 'mkinitcpio -P linux' command.

  2. Add a user and create a password.

[root@archiso /]# useradd -mG wheel

-> Replace with your username.

[root@archiso /]# passwd

  1. Set a password for root.

[root@archiso /]# passwd root

  1. Install the required packages.

[root@archiso /]# pacman -S grub base-devel efibootmgr linux-headers mtools dosfstools reflector networkmanager linux-headers git os-prober nm-connection-editor

  1. Install grub.

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

  1. Generate grub configuration file.

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

  1. Update sudo privileges.

[root@archiso /]# editor=vim visudo

-> The above command will open the visudo file. Here, un-comment the line matching the one below.

"%wheel ALL=(ALL) ALL"

-> Save it and exit the file.

  1. Exit to the archiso using the 'exit' command.

  2. Unmount all the partitions using the 'unmount -a' command.

  3. Reboot the system using the 'reboot' command.

  4. After rebooting, boot from the USB where arch was installed.

  5. Login into the used which was added in the installation.

  6. Edit the system journal file.

-> This is necessary to make the system know that the journal has to be stored in the RAM instead. -> Follow the below command to create and update the journal file.

mkdir /etc/systemd/journal.conf.d

vim /etc/systemd/journal.conf.d/usbstick.conf

-> In the file that opens, save the text below.

""" [Journal] Storage=volatile MaxRuntimeUse=30M """

-> MaxRuntimeUse set to 30M as recommended by the ArchWiki.

  1. So, Arch is now successfully installed on your system.

Reached a new milestone: "BTW, I use Arch!"