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:
- Insert both of the USB flash drive.
- Boot from the USB with the arch installation media.
Follow along in the next unit for installing arch on the USB flash drive.
Installation:
- 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.
- Check you internet connectivity using the following.
root@archiso~# ping
- Update the system clock.
root@archiso~# timedatectl set-ntp true
- 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.
- 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.
- 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
- 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
- Installing the required packages.
-> I am using the vim editor in this tutorial.
root@archiso~# pacstrap /mnt base linux linux-firmware vim
- Generating the format style table.
root@archiso~# genfstab -U /mnt >> /mnt/etc/fstab
-> -U option for using the UUIDs.
-
Change root to the mount directory using the 'arch-chroot /mnt' command.
-
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
- 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.
-
Generate the locale using the 'locale-gen' command.
-
Add locale to the locale.conf file.
[root@archiso /]# echo "LANG=en_US.UTF-8" > /etc/locale.conf
- Set the host name.
[root@archiso /]# echo "ArchUSB" > /etc/hostname
-> Replace ArchUSB with your hostname.
- 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.
- 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)
-
Generate Initramfs using the 'mkinitcpio -P linux' command.
-
Add a user and create a password.
[root@archiso /]# useradd -mG wheel
-> Replace with your username.
[root@archiso /]# passwd
- Set a password for root.
[root@archiso /]# passwd root
- 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
- Install grub.
[root@archiso /]# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --removable --recheck
- Generate grub configuration file.
[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg
- 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.
-
Exit to the archiso using the 'exit' command.
-
Unmount all the partitions using the 'unmount -a' command.
-
Reboot the system using the 'reboot' command.
-
After rebooting, boot from the USB where arch was installed.
-
Login into the used which was added in the installation.
-
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.
- So, Arch is now successfully installed on your system.
Reached a new milestone: "BTW, I use Arch!"