- This page explains how to install Artix on a USB flash drive. The end result is
- a persistent installation identical to that on a normal hard drive along with
- several optimizations aimed at running Linux on removable flash media. It is
- compatible with both BIOS and UEFI booting modes.
- # Install Base System
- Plug in the drive and determine the device name
- ```shell
- dmesg | tail
- # usb-storage 2-2:1.0: USB Mass Storage device detected
- # scsi host2: usb-storage 2-2:1.0
- # sd 2:0:0:0: [sdb] 965246976 512-byte logical blocks: (494 GB/460 GiB)
- # sd 2:0:0:0: [sdb] Write Protect is off
- # sd 2:0:0:0: [sdb] Mode Sense: 43 00 00 00
- # sd 2:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
- # sdb:
- # sd 2:0:0:0: [sdb] Attached SCSI removable disk
- export TARGET=/dev/sdb
- ```
- ### wipe (optional)
- Use dd to write the USB with all zeros, permanently erasing all data:
- ```shell
- dd if=/dev/zero of=/dev/sdX status=progress && sync
- ```
- Expect this to take a relatively long time (hour+) depending on the size.
- ## partition
- Create a 10M BIOS partition, an EFI partition, and a Linux partition with the
- remaining space (`sgdisk` is in the gptfdisk package):
- ```shell
- sgdisk -o -n 1:0:+10M -t 1:EF02 -n 2:0:+1024M -t 2:EF00 -n 3:0:0 -t 3:8304 $TARGET
- ```
- ## format
- Do not format the `/dev/sdX1` block. This is the BIOS/MBR parition.
- ```shell
- # Format the EFI system partition with a FAT32 filesystem:
- mkfs.fat -F32 ${TARGET}2
- # Format the Linux partition with an ext4 filesystem:
- mkfs.ext4 ${TARGET}3
- ```
- ## mount
- ```shell
- # Mount the ext4 formatted partition as the root filesystem:
- export MNT=/mnt/usb
- mkdir -p $MNT
- mount ${TARGET}3 $MNT
- mount ${TARGET}2 ${MNT}/boot
- ```
- ## base system
- By default, dinit will installed (alphabetical), adjust if desired as seen in:
- https://wiki.artixlinux.org/Main/Installation#Install_base_system
- ```shell
- basestrap $MNT base inetutils base-devel vim htop mc less
- basestrap $MNT linux linux-firmware
- # Generate a new /etc/fstab using UUIDs as source identifiers:
- fstabgen -U $MNT > ${MNT}/etc/fstab
- ```
- ## configure
- Unless otherwise noted, all configuration is done within a chroot. Chroot into
- the new system:
- ```shell
- artix-chroot $MNT
- export PS1="(chroot) $PS1"
- ```
- ### locale
- Use tab-completion to discover the appropriate entries for _region_ and _city_:
- ```shell
- ln -sf /usr/share/zoneinfo/region/city /etc/localtime
- # substitute en_US.UTF-8 for your desired locale
- sed -i '/en_US.UTF-8/s/^#*//' /etc/locale.gen
- locale-gen
- echo 'LANG=en_US.UTF-8' > /etc/locale.conf
- ```
- ### hostname
- ```shell
- export HOSTNAME="ghost"
- cat << EOF > /etc/hosts
- 127.0.0.1 localhost
- ::1 localhost
- 127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}
- EOF
- echo ${HOSTNAME} > /etc/hostname
- ```
- ### root password
- ```shell
- passwd
- ```
- ### bootloader
- ```shell
- # Install grub and efibootmgr
- pacman -S grub efibootmgr
- # Install GRUB for both BIOS and UEFI booting modes
- grub-install --target=i386-pc --recheck $TARGET
- grub-install --target=x86_64-efi --efi-directory /boot --recheck --removable
- # Generate a GRUB configuration
- grub-mkconfig -o /boot/grub/grub.cfg
- ```
- ### network
- ```shell
- pacman -S networkmanager-dinit
- ln -s /etc/dinit.d/NetworkManager /etc/dinit.d/boot.d/
- ```
- ### user
- ```shell
- export USER=user
- useradd -m -G wheel -s /bin/bash $USER
- passwd $USER
- # sudo
- sed -i '/%wheel ALL=(ALL:ALL) ALL/s/^# //' /etc/sudoers
- visudo -c # check if it parses
- ```
- ### noatime (optional)
- ```shell
- sed -i -s 's/relatime/noatime/' /etc/fstab
- ```