From aldum, 4 Days ago, written in Plain Text.
This paste will bite the big one in 3 Weeks.
Embed
  1. This page explains how to install Artix on a USB flash drive. The end result is
  2. a persistent installation identical to that on a normal hard drive along with
  3. several optimizations aimed at running Linux on removable flash media. It is
  4. compatible with both BIOS and UEFI booting modes.
  5.  
  6.  
  7. # Install Base System
  8.  
  9. Plug in the drive and determine the device name
  10.  
  11. ```shell
  12. dmesg | tail
  13. # usb-storage 2-2:1.0: USB Mass Storage device detected
  14. # scsi host2: usb-storage 2-2:1.0
  15. # sd 2:0:0:0: [sdb] 965246976 512-byte logical blocks: (494 GB/460 GiB)
  16. # sd 2:0:0:0: [sdb] Write Protect is off
  17. # sd 2:0:0:0: [sdb] Mode Sense: 43 00 00 00
  18. # sd 2:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
  19. #  sdb:
  20. # sd 2:0:0:0: [sdb] Attached SCSI removable disk
  21. export TARGET=/dev/sdb
  22. ```
  23.  
  24. ### wipe (optional)
  25.  
  26. Use dd to write the USB with all zeros, permanently erasing all data:
  27. ```shell
  28. dd if=/dev/zero of=/dev/sdX status=progress && sync
  29. ```
  30. Expect this to take a relatively long time (hour+) depending on the size.
  31.  
  32.  
  33. ## partition
  34.  
  35. Create a 10M BIOS partition, an EFI partition, and a Linux partition with the
  36. remaining space (`sgdisk` is in the gptfdisk package):
  37.  
  38. ```shell
  39. sgdisk -o -n 1:0:+10M -t 1:EF02 -n 2:0:+1024M -t 2:EF00 -n 3:0:0 -t 3:8304 $TARGET
  40. ```
  41.  
  42. ## format
  43.  
  44. Do not format the `/dev/sdX1` block. This is the BIOS/MBR parition.
  45.  
  46. ```shell
  47. # Format the EFI system partition with a FAT32 filesystem:
  48. mkfs.fat -F32 ${TARGET}2
  49. # Format the Linux partition with an ext4 filesystem:
  50. mkfs.ext4 ${TARGET}3
  51. ```
  52.  
  53. ## mount
  54.  
  55. ```shell
  56. # Mount the ext4 formatted partition as the root filesystem:
  57. export MNT=/mnt/usb
  58. mkdir -p $MNT
  59. mount ${TARGET}3 $MNT
  60. mount ${TARGET}2 ${MNT}/boot
  61. ```
  62.  
  63. ## base system
  64.  
  65. By default, dinit will installed (alphabetical), adjust if desired as seen in:
  66. https://wiki.artixlinux.org/Main/Installation#Install_base_system
  67.  
  68. ```shell
  69. basestrap $MNT base inetutils base-devel vim htop mc less
  70. basestrap $MNT linux linux-firmware
  71. # Generate a new /etc/fstab using UUIDs as source identifiers:
  72. fstabgen -U $MNT > ${MNT}/etc/fstab
  73. ```
  74.  
  75. ## configure
  76.  
  77. Unless otherwise noted, all configuration is done within a chroot. Chroot into
  78. the new system:
  79. ```shell
  80. artix-chroot $MNT
  81. export PS1="(chroot) $PS1"
  82. ```
  83.  
  84. ### locale
  85.  
  86. Use tab-completion to discover the appropriate entries for _region_ and _city_:
  87. ```shell
  88. ln -sf /usr/share/zoneinfo/region/city /etc/localtime
  89. # substitute en_US.UTF-8 for your desired locale
  90. sed -i '/en_US.UTF-8/s/^#*//' /etc/locale.gen
  91. locale-gen
  92. echo 'LANG=en_US.UTF-8' > /etc/locale.conf
  93. ```
  94.  
  95. ### hostname
  96.  
  97. ```shell
  98. export HOSTNAME="ghost"
  99. cat  << EOF > /etc/hosts
  100. 127.0.0.1        localhost
  101. ::1              localhost
  102. 127.0.1.1        ${HOSTNAME}.localdomain ${HOSTNAME}
  103. EOF
  104. echo ${HOSTNAME} > /etc/hostname
  105. ```
  106.  
  107. ### root password
  108.  
  109. ```shell
  110. passwd
  111. ```
  112.  
  113. ### bootloader
  114.  
  115. ```shell
  116. # Install grub and efibootmgr
  117. pacman -S grub efibootmgr
  118. # Install GRUB for both BIOS and UEFI booting modes
  119. grub-install --target=i386-pc --recheck $TARGET
  120. grub-install --target=x86_64-efi --efi-directory /boot --recheck --removable
  121. # Generate a GRUB configuration
  122. grub-mkconfig -o /boot/grub/grub.cfg
  123. ```
  124.  
  125. ### network
  126.  
  127. ```shell
  128. pacman -S networkmanager-dinit
  129. ln -s /etc/dinit.d/NetworkManager /etc/dinit.d/boot.d/
  130. ```
  131.  
  132. ### user
  133.  
  134. ```shell
  135. export USER=user
  136. useradd -m -G wheel -s /bin/bash $USER
  137. passwd $USER
  138. # sudo
  139. sed -i '/%wheel ALL=(ALL:ALL) ALL/s/^# //' /etc/sudoers
  140. visudo -c # check if it parses
  141. ```
  142.  
  143. ### noatime (optional)
  144.  
  145. ```shell
  146. sed -i -s 's/relatime/noatime/' /etc/fstab
  147. ```
  148.  
captcha