Various instructions for setting up Linux OS on Clevo N950TP6
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

893 lines
43 KiB

  1. # UEFI partition scheme for Clevo N950TP6
  2. Partitions:
  3. - UEFI (syslinux boot)
  4. - NVMe SSD (Arch Linux file system)
  5. - HDD/SSD (user files + cache files)
  6. ## Table of Contents
  7. - [General overview](#general-overview)
  8. - [Getting started: backups & Arch Linux installation](#getting-started-backups--arch-linux-installation)
  9. - [Partition tables](#partition-tables)
  10. - [Storage roles](#storage-roles)
  11. - [Partition scheme overview](#partition-scheme-overview)
  12. - [Boot loader](#boot-loader)
  13. - [Boot partition structure](#boot-partition-structure)
  14. - [Boot partition permissions](#boot-partition-permissions)
  15. - [Filesystem structure](#filesystem-structure)
  16. - [Mount points overview](#mount-points-overview)
  17. - [/mnt location overview](#mnt-location-overview)
  18. - [fstab configuration file](#fstab-configuration-file)
  19. - [syslinux configuration file](#syslinux-configuration-file)
  20. - [mkinitcpio preset file](#mkinitcpio-preset-file)
  21. - [mkinitcpio configuration file](#mkinitcpio-configuration-file)
  22. - [Additional hints](#additional-hints)
  23. - [Retrieving UUIDs](#retrieving-uuids)
  24. - [Kernel updates may break the setup. How to avoid?](#kernel-updates-may-break-the-setup-how-to-avoid)
  25. - [RewriteFS](#rewritefs)
  26. - [RewriteFS - installation](#rewritefs---installation)
  27. - [RewriteFS - fstab example](#rewritefs---fstab-example)
  28. ## General overview
  29. - 3 partitions used in this scheme
  30. - Various parts of the file system, such as `/var`, exists in HDD/SSD in order to reduce redundant write operations on NVMe.
  31. - RAM used as a mounting point for `/tmp`
  32. - Swap is stored in a seperate file for modularity. It is located at `/swap/swapfile` (Yes, this is against [FHS](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard))
  33. - UEFI partition size is 256 MiB in this installation, rest of the SSD (~250 GiB) is reserved for the Arch Linux OS
  34. - This installation method takes advantage of [bind mounting feature](https://wiki.archlinux.org/index.php/EFI_system_partition#Using_bind_mount)
  35. - Only Arch Linux installed
  36. - No Windows or any other OSes installed
  37. - Uses `syslinux` bootloader.
  38. - **NOTE:** When you create UEFI-based boot partition, you don't need to run `extlinux --install` command (unlike on BIOS-based boot partition). Just put necessary boot files, set boot flags for the boot partition and you're good to go.
  39. - **NOTE:** You don't need to run `efibootmgr`, as referred on some websites.
  40. **NOTE:** In general, you can have `EFI` partition on HDD mass storage, too. I mean: NVMe is not mandatory requirement here. However, slightly different `/etc/fstab` configuration is required than presented in [fstab configuration file](#fstab-configuration-file) section. I have tested this custom setup on my spare HDD.
  41. --------------------------
  42. ## Getting started: backups & Arch Linux installation
  43. **1)** Get an external mass storage & a Linux live USB & boot it
  44. **NOTE:** If you intend to use Linux desktop and can't access it, use additional kernel boot parameters `acpi_osi="!Windows 2015" acpi_osi=Linux`
  45. **2)** Mount your mass storage to `/mnt/backupstorage`
  46. ```
  47. mkdir -p /mnt/backupstorage
  48. mount /dev/<backupstorage> /mnt/backupstorage
  49. ```
  50. **2)** Backup your original NVMe partitions to another mass storage as a `.gz` archive (greatly reduces backup file size). Command:
  51. ```
  52. dd if=/dev/nvme0n1 conv=sync,noerror status=progress | gzip -c > /mnt/backupstorage/clevo-nvme.img.gz
  53. ```
  54. **NOTE:** You can restore the backed up partitions with command:
  55. ```
  56. gunzip -c /mnt/backupstorage/clevo-nvme.img.gz | dd of=/dev/nvme0n1 conv=sync,noerror status=progress
  57. ```
  58. **3)** Format NVMe drive (this follows partition scheme defined below):
  59. **WARNING:** Ensure you have proper partition backups before proceeding.
  60. ```
  61. fdisk /dev/nvme0n1
  62. d 1 delete partition 1
  63. d .. delete partition N (all partitions must be deleted)
  64. g create a new GPT partition table
  65. n create a new partition 1 (boot partition)
  66. p primary partition
  67. <default> default first sector
  68. +256M last sector: 256M
  69. n create a new partition 2 (filesystem partition)
  70. p primary partition
  71. <default> default first sector
  72. <default> default last sector (the whole disk. You can adjust this for your needs!)
  73. w
  74. mkfs.vfat /dev/nvme0n1p1 format NVMe boot partition to FAT32
  75. mkfs.ext4 /dev/nvme0n1p2 format NVMe file system partition to Ext4
  76. parted /dev/nvme0n1
  77. toggle 1 boot toggle boot flag on boot partition
  78. toggle 1 esp toggle esp flag (EFI) on boot partition (unless already exists!)
  79. ```
  80. **4)** Install Arch Linux:
  81. **4.1)** Mount `/dev/nvme0n1p2` to `/mnt/archsystem` (`mkdir -p /mnt/archsystem && mount /dev/nvme0n1p2 /mnt/archsystem`)
  82. **4.2)** Deploy Arch Linux system into `/mnt/archsystem`:
  83. A) If you use non-Arch Linux live USB distribution, use [arch-bootstrap](https://github.com/tokland/arch-bootstrap) shell script.
  84. B) On Arch Linux based live USB distribution, use `pacstrap` command which is supplied with [arch-install-scripts](https://www.archlinux.org/packages/extra/any/arch-install-scripts/) package.
  85. **5)** Mount `/dev/nvme0n1p1` to `/mnt/archsystem/boot_efi` (`mkdir -p /mnt/archsystem/boot_efi && mount /dev/nvme0n1p1 /mnt/archsystem/boot_efi`)
  86. **6)** Access the Arch Linux system with `arch-chroot` command.
  87. **7)** In chrooted environment, install [syslinux](https://www.archlinux.org/packages/core/x86_64/syslinux/) & [intel-ucode](https://www.archlinux.org/packages/extra/any/intel-ucode/). Follow file system scheme defined in the following sections:
  88. - [Boot partition structure](#boot-partition-structure)
  89. - [Filesystem structure](#filesystem-structure)
  90. - [fstab configuration file](#fstab-configuration-file)
  91. - [syslinux configuration file](#syslinux-configuration-file)
  92. - [mkinitcpio preset files](#mkinitcpio-preset-files)
  93. - [mkinitcpio configuration file](#mkinitcpio-configuration-file)
  94. **NOTE:** Use default `$HOME` locations for all users (root's home should point to `/root` and other users to `/home/<user>`). Nothing special here, just use defaults.
  95. **8)** Once the system is configured, check your configuration:
  96. - Check basic settings, such as `hostname`, `localectl`, timedatectl`, `locale-gen`, and your user-specific configurations
  97. - Check you have properly set up boot files & configuration (EFI partition, `init` symbolic link, etc.)
  98. - Test that initial RAM disk images (`initramfs.img`, `initramfs-fallback.img`) & Linux kernel image are generated into `/boot_efi` instead of default `/boot` location. You can test this with `mkinitcpio -p linux` command.
  99. - In some rare cases, you may need to reinstall `systemd`. I once dropped into `rootfs` shell, and ultimately fixed this by reinstalling `systemd`
  100. --------------------------
  101. ## Partition tables
  102. The following sheet represents the desired partition tables for various mass storage devides used in this setup.
  103. | Mass Storage | Partition table |
  104. |------------------|-----------------|
  105. | Internal NVMe | gpt * |
  106. | Internal HDD/SSD | gpt/dos |
  107. * GPT (`gpt`) partition table is required for `UEFI` support. GPT partition table should be applied to the mass storage you will install your `EFI` boot partition into.
  108. - DOS (`dos`) partition table is compatible with BIOS only. In UEFI setup, you can use DOS partition table on any mass storage you don't directly intended to use for booting process.
  109. - If you have DOS partition table on your mass storage which contains boot partition, the mass storage can only be used for BIOS-mode booting.
  110. - You can boot this laptop using either BIOS or UEFI mode. UEFI is recommended.
  111. - You can switch between BIOS & UEFI modes in [setup menu](images/bios/bios_4.jpg).
  112. ## Storage roles
  113. The following sheet represents a general overview of desired partition scheme.
  114. | Role | Location | Partition | Partition Size | Type | Flags |
  115. |-------------------|-------------------------|-----------|----------------|-------------|-------------|
  116. | Boot files | Internal NVMe | 1 | 256 MiB | FAT32, EFI | boot, esp * |
  117. | Operating System | Internal NVMe | 2 | Any | Ext4 | - |
  118. | User files & dirs | Internal HDD/SSD (2.5") | Any | Any | Ext4 ** | - |
  119. * `boot, esp` flags are available only for GPT partitioned mass storage. For DOS, only `boot` flag can be used.
  120. ** If you intended to store `$HOME` folders of system users, you should use a partition type which supports Unix-type permission scheme. Thus, NTFS and similar solutions are invalid options for this mass storage. Keep in mind that many Unix-like partition types may be incompatible on Microsoft Windows OSes.
  121. ## Partition scheme overview
  122. - Internal NVMe is referred as `/dev/nvme0n1`
  123. - Internal 1 TiB HDD is referred as `/dev/sda`
  124. ```
  125. > fdisk -l
  126. Disk /dev/nvme0n1: 232.9 GiB, 250059350016 bytes, 488397168 sectors
  127. Units: sectors of 1 * 512 = 512 bytes
  128. Sector size (logical/physical): 512 bytes / 512 bytes
  129. I/O size (minimum/optimal): 512 bytes / 512 bytes
  130. Disklabel type: gpt
  131. Disk identifier: B4ED4BFE-7300-4B6E-8DE4-74D91681A89C
  132. Device Start End Sectors Size Type
  133. /dev/nvme0n1p1 2048 526335 524288 256M EFI System
  134. /dev/nvme0n1p2 526336 488396799 487870464 232.7G Linux filesystem
  135. Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
  136. Disk model: WDC WD10JPVX-75J
  137. Units: sectors of 1 * 512 = 512 bytes
  138. Sector size (logical/physical): 512 bytes / 4096 bytes
  139. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  140. Disklabel type: gpt
  141. Disk identifier: C4C74840-056F-4C6F-9351-728CB43B2E17
  142. Device Start End Sectors Size Type
  143. /dev/sda1 2048 1953523711 1953521664 931.5G Linux filesystem
  144. ```
  145. ```
  146. > parted -l
  147. Model: ATA WDC WD10JPVX-75J (scsi)
  148. Disk /dev/sda: 1000GB
  149. Sector size (logical/physical): 512B/4096B
  150. Partition Table: gpt
  151. Disk Flags:
  152. Number Start End Size File system Name Flags
  153. 1 1049kB 1000GB 1000GB ext4
  154. Model: Unknown (unknown)
  155. Disk /dev/nvme0n1: 250GB
  156. Sector size (logical/physical): 512B/512B
  157. Partition Table: gpt
  158. Disk Flags:
  159. Number Start End Size File system Name Flags
  160. 1 1049kB 269MB 268MB fat32 boot, esp
  161. 2 269MB 233GB 232GB ext4
  162. ```
  163. --------------------------
  164. ## Boot loader
  165. - Pretty simple to set up
  166. - Existing `syslinux` installation used
  167. ### Boot partition structure
  168. ```
  169. . EFI partition mount point
  170. |
  171. └─────────────────────────────────────EFI─────────────────────────────────────
  172. | | |
  173. BOOT syslinux |
  174. ├── bootx64.efi * ├── syslinux.efi * ├── initramfs-linux-fallback.img (fallback initramfs image)
  175. ├── cat.c32 ├── cat.c32 ├── initramfs-linux.img (initramfs image)
  176. ├── chain.c32 ├── chain.c32 ├── vmlinuz-linux (kernel image)
  177. ├── cmd.c32 ├── cmd.c32 └── intel-ucode.img (from package `intel-ucode`)
  178. ├── cmenu.c32 ├── cmenu.c32
  179. ├── config.c32 ├── config.c32
  180. ├── cptime.c32 ├── cptime.c32
  181. ├── cpu.c32 ├── cpu.c32
  182. ├── cpuid.c32 ├── cpuid.c32
  183. ├── cpuidtest.c32 ├── cpuidtest.c32
  184. ├── debug.c32 ├── debug.c32
  185. ├── dhcp.c32 ├── dhcp.c32
  186. ├── dir.c32 ├── dir.c32
  187. ├── dmi.c32 ├── dmi.c32
  188. ├── dmitest.c32 ├── dmitest.c32
  189. ├── gfxboot.c32 ├── gfxboot.c32
  190. ├── hdt.c32 ├── hdt.c32
  191. ├── hexdump.c32 ├── hexdump.c32
  192. ├── host.c32 ├── host.c32
  193. ├── ifcpu64.c32 ├── ifcpu64.c32
  194. ├── ifcpu.c32 ├── ifcpu.c32
  195. ├── ldlinux.e64 ├── ldlinux.e64
  196. ├── lfs.c32 ├── lfs.c32
  197. ├── libcom32.c32 ├── libcom32.c32
  198. ├── libgpl.c32 ├── libgpl.c32
  199. ├── liblua.c32 ├── liblua.c32
  200. ├── libmenu.c32 ├── libmenu.c32
  201. ├── libutil.c32 ├── libutil.c32
  202. ├── linux.c32 ├── linux.c32
  203. ├── ls.c32 ├── ls.c32
  204. ├── lua.c32 ├── lua.c32
  205. ├── mboot.c32 ├── mboot.c32
  206. ├── meminfo.c32 ├── meminfo.c32
  207. ├── menu.c32 ├── menu.c32
  208. ├── pci.c32 ├── pci.c32
  209. ├── pwd.c32 ├── pwd.c32
  210. ├── reboot.c32 ├── reboot.c32
  211. ├── rosh.c32 ├── rosh.c32
  212. ├── sysdump.c32 ├── sysdump.c32
  213. ├── syslinux.c32 ├── syslinux.c32
  214. ├── syslinux.cfg * ├── syslinux.cfg *
  215. ├── vesa.c32 ├── vesa.c32
  216. ├── vesamenu.c32 ├── vesamenu.c32
  217. ├── vpdtest.c32 ├── vpdtest.c32
  218. ├── whichsys.c32 ├── whichsys.c32
  219. └── zzjson.c32 └── zzjson.c32
  220. ```
  221. * Duplicate files with equivalent contents. Although all files are duplicates, you should pay attention especially to these files.
  222. Basically, you need:
  223. - A) existing `syslinux` installation
  224. - B) Copy files from `/usr/lib/syslinux/efi64/` to the `EFI/BOOT/` and `EFI/syslinux/` subfolders presented above.
  225. Be aware: `.c32` files presented here may vary depending on version of your `syslinux` package. It should be fine, though.
  226. ### Boot partition permissions
  227. **NOTE:** You don't need to set these manually if you use proper `/etc/fstab` entry mask values as defined in [fstab configuration file](#fstab-configuration-file). These values are here so you can just check them.
  228. | Permissions | Owner (user:group) | Type | Item Name |
  229. |------------------|--------------------|-----------|------------------------------------|
  230. | rwxr-xr-x (0755) | root:root | Directory | ./EFI |
  231. | rwxr-xr-x (0755) | root:root | Directory | ./EFI/BOOT |
  232. | rwxr-xr-x (0755) | root:root | Directory | ./EFI/syslinux |
  233. | rw-r--r-- (0644) | root:root | File | ./EFI/initramfs-linux-fallback.img |
  234. | rw-r--r-- (0644) | root:root | File | ./EFI/initramfs-linux.img |
  235. | rw-r--r-- (0644) | root:root | File | ./EFI/vmlinuz-linux |
  236. | rw-r--r-- (0644) | root:root | File | ./EFI/intel-ucode.img |
  237. | ---------------- | --------- | --------- | ---------------------------------- |
  238. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/bootx64.efi |
  239. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/cat.c32 |
  240. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/chain.c32 |
  241. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/cmd.c32 |
  242. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/cmenu.c32 |
  243. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/config.c32 |
  244. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/cptime.c32 |
  245. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/cpu.c32 |
  246. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/cpuid.c32 |
  247. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/cpuidtest.c32 |
  248. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/debug.c32 |
  249. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/dhcp.c32 |
  250. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/dir.c32 |
  251. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/dmi.c32 |
  252. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/dmitest.c32 |
  253. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/gfxboot.c32 |
  254. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/hdt.c32 |
  255. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/hexdump.c32 |
  256. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/host.c32 |
  257. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/ifcpu64.c32 |
  258. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/ifcpu.c32 |
  259. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/ldlinux.e64 |
  260. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/lfs.c32 |
  261. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/libcom32.c32 |
  262. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/libgpl.c32 |
  263. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/liblua.c32 |
  264. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/libmenu.c32 |
  265. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/libutil.c32 |
  266. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/linux.c32 |
  267. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/ls.c32 |
  268. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/lua.c32 |
  269. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/mboot.c32 |
  270. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/meminfo.c32 |
  271. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/menu.c32 |
  272. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/pci.c32 |
  273. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/pwd.c32 |
  274. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/reboot.c32 |
  275. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/rosh.c32 |
  276. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/sysdump.c32 |
  277. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/syslinux.c32 |
  278. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/syslinux.cfg |
  279. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/vesa.c32 |
  280. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/vesamenu.c32 |
  281. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/vpdtest.c32 |
  282. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/whichsys.c32 |
  283. | rw-r--r-- (0644) | root:root | File | ./EFI/BOOT/zzjson.c32 |
  284. | ---------------- | --------- | --------- | ---------------------------------- |
  285. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/cat.c32 |
  286. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/chain.c32 |
  287. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/cmd.c32 |
  288. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/cmenu.c32 |
  289. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/config.c32 |
  290. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/cptime.c32 |
  291. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/cpu.c32 |
  292. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/cpuid.c32 |
  293. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/cpuidtest.c32 |
  294. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/debug.c32 |
  295. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/dhcp.c32 |
  296. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/dir.c32 |
  297. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/dmi.c32 |
  298. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/dmitest.c32 |
  299. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/gfxboot.c32 |
  300. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/hdt.c32 |
  301. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/hexdump.c32 |
  302. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/host.c32 |
  303. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/ifcpu64.c32 |
  304. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/ifcpu.c32 |
  305. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/ldlinux.e64 |
  306. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/lfs.c32 |
  307. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/libcom32.c32 |
  308. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/libgpl.c32 |
  309. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/liblua.c32 |
  310. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/libmenu.c32 |
  311. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/libutil.c32 |
  312. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/linux.c32 |
  313. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/ls.c32 |
  314. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/lua.c32 |
  315. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/mboot.c32 |
  316. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/meminfo.c32 |
  317. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/menu.c32 |
  318. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/pci.c32 |
  319. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/pwd.c32 |
  320. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/reboot.c32 |
  321. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/rosh.c32 |
  322. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/sysdump.c32 |
  323. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/syslinux.c32 |
  324. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/syslinux.cfg |
  325. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/syslinux.efi |
  326. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/vesa.c32 |
  327. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/vesamenu.c32 |
  328. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/vpdtest.c32 |
  329. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/whichsys.c32 |
  330. | rw-r--r-- (0644) | root:root | File | ./EFI/syslinux/zzjson.c32 |
  331. ## Filesystem structure
  332. ### Mount points overview
  333. | Item Name | Item Type | Partition | Partition format |
  334. |-------------|----------------------------------------------|-----------------------|------------------|
  335. | /bin | Symbolic link (to usr/bin) | NVMe, 2 (OS) | Ext4 |
  336. | /boot ***** | Directory | NVMe, 2 (OS) | Ext4 |
  337. | /boot_efi * | Directory | NVMe, 1 (Boot) | FAT32/EFI |
  338. | /dev | Directory | NVMe, 2 (OS) | Ext4 |
  339. | /etc | Directory | NVMe, 2 (OS) | Ext4 |
  340. | /home | Directory (bind) ** | HDD/SSD (User files) | Ext4 |
  341. | /init | Symbolic link (to `usr/lib/systemd/systemd`) | NVMe, 2 (OS) | Ext4 |
  342. | /lib | Symbolic link (to `usr/lib`) | NVMe, 2 (OS) | Ext4 |
  343. | /lib64 | Symbolic link (to `usr/lib`) | NVMe, 2 (OS) | Ext4 |
  344. | /lost+found | Directory | NVMe, 2 (OS) | Ext4 |
  345. | /mnt *** | Directory | NVMe, 2 (OS) | Ext4 |
  346. | /opt | Directory | NVMe, 2 (OS) | Ext4 |
  347. | /proc | Directory | NVMe, 2 (OS) | Ext4 |
  348. | /root | Directory (bind) ** | HDD/SSD (User files) | Ext4 |
  349. | /run | Directory | NVMe, 2 (OS) | Ext4 |
  350. | /sbin | Symbolic link (to `usr/bin`) | NVMe, 2 (OS) | Ext4 |
  351. | /swap **** | Directory (bind) ** | HDD/SSD (Cache files) | Ext4 |
  352. | /srv | Directory | NVMe, 2 (OS) | Ext4 |
  353. | /sys | Directory | NVMe, 2 (OS) | Ext4 |
  354. | /tmp | Directory | RAM | tmpfs |
  355. | /usr | Directory | NVMe, 2 (OS) | Ext4 |
  356. | /var | Directory (bind) ** | HDD/SSD (Cache files) | Ext4 |
  357. * Mount point `/boot_efi` for UEFI boot partition is defined in `/etc/fstab`. Please see [fstab configuration file](#fstab-configuration file) for additional information.
  358. ** `bind` option is defined in `/etc/fstab`. Please see the following diagram.
  359. *** Directory `/mnt` contains directories existing on HDD/SSD (User files). Please see the following diagram.
  360. **** Optional: non-standard location for a SWAP file. Please see [Arch Wiki - Swap file](https://wiki.archlinux.org/index.php/Swap#Swap_file) for additional information.
  361. ***** `/boot` folder contains only `intel-ucode.img` file, provided by Arch Linux package `intel-ucode`. Otherwise, `/boot` folder is empty and all necessary boot files are in `/boot_efi`
  362. ### `/mnt` location overview
  363. | Item Name | Item Type | Partition | Partition format |
  364. |----------------------|-------------------------------|-----------|------------------|
  365. | /mnt/hdd | Directory | HDD/SSD | Ext4 |
  366. | /mnt/hdd/home | Directory (binded to `/home`) | HDD/SSD | Ext4 |
  367. | /mnt/hdd/home/<user> | Directory | HDD/SSD | Ext4 |
  368. | /mnt/hdd/home/root | Directory (binded to `/root`) | HDD/SSD | Ext4 |
  369. | /mnt/hdd/var | Directory (binded to `/var`) | HDD/SSD | Ext4 |
  370. | /mnt/hdd/lost+found | Directory | HDD/SSD | Ext4 |
  371. | /mnt/hdd/swap | Directory (binded to `/swap`) | HDD/SSD | Ext4 |
  372. `<user>` refers to your Linux file system user account(s).
  373. ## fstab configuration file
  374. The following `/etc/fstab` configuration corresponds to the file system structure explained above.
  375. Please configure `UUID` values for your setup. You must use proper `UUID` values instead of the ones presented below (see [Retrieving UUIDs](#retrieving-uuids)). Additionally, use proper username string for `<user>`.
  376. ```
  377. > cat /etc/fstab
  378. #
  379. # /etc/fstab: static file system information
  380. #
  381. # <file system> <dir> <type> <options> <dump> <pass>
  382. #
  383. #########################################
  384. # NVMe: M.2 - FILE SYSTEM PARTITION
  385. # Root system
  386. UUID=9148225b-d661-4e4a-801c-f5bdc48f509e / ext4 defaults,noatime,discard 0 1
  387. #########################################
  388. # Boot files - FAT32 partition, needs mask values
  389. UUID=927D-38E4 /boot_efi vfat defaults,dmask=0022,fmask=0133 0 0
  390. #########################################
  391. # RAM & SWAP
  392. # temporary folders
  393. tmpfs /tmp tmpfs nodev,nosuid,size=20480M,nr_inodes=500k 0 0
  394. # Swap memory file (optional)
  395. /mnt/hdd/swap /swap none bind 0 0
  396. /swap/swapfile none swap defaults 0 0
  397. #########################################
  398. # HDD: SATA - USER FILES PARTITION
  399. UUID=fba31569-c25c-4e30-b117-9ea83c41a8bd /mnt/hdd ext4 defaults,discard 0 2
  400. #########################################
  401. # Bind folders
  402. # /var folder
  403. /mnt/hdd/var /var none bind 0 0
  404. # Home folders
  405. /mnt/hdd/home/root /root none bind 0 0
  406. /root /home/root none bind 0 0
  407. #########################################
  408. # Optional: mount your cache folders to RAM
  409. #tmpfs /home/<user>/.cache tmpfs size=15%,mode=0777,uid=1000,gid=1000 0 0
  410. ```
  411. ## syslinux configuration file
  412. This configuration applies to the files `EFI/BOOT/syslinux.cfg` & `EFI/syslinux/syslinux.cfg` on NVMe partition 1 (Boot). Please configure `APPEND` kernel parameters properly for your setup. At least, you must use proper `UUID` values instead of the ones presented below (see [Retrieving UUIDs](#retrieving-uuids)).
  413. ```
  414. # Config file for Syslinux -
  415. # /boot/syslinux/syslinux.cfg
  416. #
  417. # Comboot modules:
  418. # * menu.c32 - provides a text menu
  419. # * vesamenu.c32 - provides a graphical menu
  420. # * chain.c32 - chainload MBRs, partition boot sectors, Windows bootloaders
  421. # * hdt.c32 - hardware detection tool
  422. # * reboot.c32 - reboots the system
  423. #
  424. # To Use: Copy the respective files from /usr/lib/syslinux to /boot/syslinux.
  425. # If /usr and /boot are on the same file system, symlink the files instead
  426. # of copying them.
  427. #
  428. # If you do not use a menu, a 'boot:' prompt will be shown and the system
  429. # will boot automatically after 5 seconds.
  430. #
  431. # Please review the wiki: https://wiki.archlinux.org/index.php/Syslinux
  432. # The wiki provides further configuration examples
  433. DEFAULT arch
  434. PROMPT 0 # Set to 1 if you always want to display the boot: prompt
  435. TIMEOUT 5
  436. # You can create syslinux keymaps with the keytab-lilo tool
  437. #KBDMAP de.ktl
  438. # Menu Configuration
  439. # Either menu.c32 or vesamenu32.c32 must be copied to /boot/syslinux
  440. UI menu.c32
  441. #UI vesamenu.c32
  442. # Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menu
  443. MENU TITLE Boot Menu
  444. #MENU BACKGROUND splash.jpg
  445. MENU COLOR border 30;44 #40ffffff #a0000000 std
  446. MENU COLOR title 1;36;44 #9033ccff #a0000000 std
  447. MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
  448. MENU COLOR unsel 37;44 #50ffffff #a0000000 std
  449. MENU COLOR help 37;40 #c0ffffff #a0000000 std
  450. MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
  451. MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
  452. MENU COLOR msg07 37;40 #90ffffff #a0000000 std
  453. MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
  454. #MENU RESOLUTION 1920 1080
  455. #Clear the screen when exiting the menu
  456. MENU CLEAR
  457. # boot sections follow
  458. #
  459. # TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
  460. # 895 = 1920x1080x32 framebuffer
  461. #
  462. LABEL arch
  463. MENU LABEL Arch Linux
  464. LINUX ../vmlinuz-linux
  465. INITRD ../initramfs-linux.img
  466. APPEND root=UUID=9148225b-d661-4e4a-801c-f5bdc48f509e rw vga=895 acpi_osi="!Windows 2015" acpi_osi=Linux nowatchdog nogpumanager rd.udev.log-priority=3 vm.swappiness=10 net.ifnames=0 biosdevname=0 cgroup_no_v1=all
  467. LABEL archshell
  468. MENU LABEL Arch Linux (shell)
  469. LINUX ../vmlinuz-linux
  470. INITRD ../initramfs-linux.img
  471. APPEND root=UUID=9148225b-d661-4e4a-801c-f5bdc48f509e rw vga=895 systemd.unit=multi-user.target nowatchdog vm.swappiness=10 net.ifnames=0 biosdevname=0 cgroup_no_v1=all
  472. LABEL archfallback
  473. MENU LABEL Arch Linux Fallback
  474. LINUX ../vmlinuz-linux
  475. INITRD ../initramfs-linux-fallback.img
  476. APPEND root=UUID=9148225b-d661-4e4a-801c-f5bdc48f509e rw vga=895 acpi_osi="!Windows 2015" acpi_osi=Linux nowatchdog vm.swappiness=10 net.ifnames=0 biosdevname=0
  477. LABEL archfallback-rescue
  478. MENU LABEL Arch Linux Fallback (rescue mode)
  479. LINUX ../vmlinuz-linux
  480. INITRD ../initramfs-linux-fallback.img
  481. APPEND root=UUID=9148225b-d661-4e4a-801c-f5bdc48f509e vga=895 systemd.unit=multi-user.target nowatchdog vm.swappiness=10 net.ifnames=0 biosdevname=0
  482. #LABEL windows
  483. # MENU LABEL Windows
  484. # COM32 chain.c32
  485. # APPEND hd0 1
  486. ## These do not work with UEFI
  487. #LABEL hdt
  488. # MENU LABEL HDT (Hardware Detection Tool)
  489. # COM32 hdt.c32
  490. #LABEL reboot
  491. # MENU LABEL Reboot
  492. # COM32 reboot.c32
  493. #LABEL poweroff
  494. # MENU LABEL Poweroff
  495. # COM32 poweroff.c32
  496. ```
  497. ## mkinitcpio preset files
  498. Custom `/etc/mkinitcpio.d/linux.preset` file is recommended for this setup. Each time you run `mkinitcpio -p linux` or update Linux kernel or systemd configuration, proper initrd and kernel files are automatically generated in proper location (`/boot_efi/` in this setup) without additional hassle.
  499. ```
  500. > cat /etc/mkinitcpio.d/linux.preset
  501. # mkinitcpio preset file for the 'linux' package
  502. ESP_DIR="/boot_efi/EFI"
  503. # Get kernel version directly from the generated kernel image file
  504. # Avoid misleading detection from the running kernel
  505. #
  506. KERNELIMG="/boot/vmlinuz-linux"
  507. ALL_config="/etc/mkinitcpio.conf"
  508. ALL_kver="${ESP_DIR}/vmlinuz-linux"
  509. PRESETS=('default' 'fallback')
  510. #default_config="/etc/mkinitcpio.conf"
  511. default_image="${ESP_DIR}/initramfs-linux.img"
  512. default_options="-A esp-update-linux -k ${KERNELIMG}"
  513. #fallback_config="/etc/mkinitcpio.conf"
  514. fallback_image="${ESP_DIR}/initramfs-linux-fallback.img"
  515. fallback_options="-S autodetect -k ${KERNELIMG}"
  516. ```
  517. Additionally, add the following file which ensures that Linux kernel image & `intel-ucode` files are correctly installed when issuing `mkinitcpio -p linux` command.
  518. ```
  519. > cat /etc/initcpio/install/esp-update-linux
  520. ESP_DIR="/boot_efi/EFI"
  521. build() {
  522. cp -af /boot/intel-ucode.img "${ESP_DIR}"/
  523. cp -af /boot/vmlinuz-linux "${ESP_DIR}"/
  524. }
  525. ```
  526. ## mkinitcpio configuration file
  527. The following `/etc/mkinitcpio.conf` file works in this setup. The file is used to configure initial RAM disk files (`initramfs.img`, `initramfs-fallback.img`). Not all modules listed in `MODULES` array are required, but they have been left for [Optimus/Intel GPU passthrough setup](https://gist.github.com/agentsim/e89beb42ede85714a24529b2a6798bb8) I once had.
  528. ```
  529. # vim:set ft=sh
  530. # MODULES
  531. # The following modules are loaded before any boot hooks are
  532. # run. Advanced users may wish to specify all system modules
  533. # in this array. For instance:
  534. # MODULES=(piix ide_disk reiserfs)
  535. MODULES=(vfio vfio_iommu_type1 vfio_pci vfio_virqfd vhost-net pci-stub)
  536. # BINARIES
  537. # This setting includes any additional binaries a given user may
  538. # wish into the CPIO image. This is run last, so it may be used to
  539. # override the actual binaries included by a given hook
  540. # BINARIES are dependency parsed, so you may safely ignore libraries
  541. BINARIES=()
  542. # FILES
  543. # This setting is similar to BINARIES above, however, files are added
  544. # as-is and are not parsed in any way. This is useful for config files.
  545. FILES=()
  546. # HOOKS
  547. # This is the most important setting in this file. The HOOKS control the
  548. # modules and scripts added to the image, and what happens at boot time.
  549. # Order is important, and it is recommended that you do not change the
  550. # order in which HOOKS are added. Run 'mkinitcpio -H <hook name>' for
  551. # help on a given hook.
  552. # 'base' is _required_ unless you know precisely what you are doing.
  553. # 'udev' is _required_ in order to automatically load modules
  554. # 'filesystems' is _required_ unless you specify your fs modules in MODULES
  555. # Examples:
  556. ## This setup specifies all modules in the MODULES setting above.
  557. ## No raid, lvm2, or encrypted root is needed.
  558. # HOOKS=(base)
  559. #
  560. ## This setup will autodetect all modules for your system and should
  561. ## work as a sane default
  562. # HOOKS=(base udev autodetect block filesystems)
  563. #
  564. ## This setup will generate a 'full' image which supports most systems.
  565. ## No autodetection is done.
  566. # HOOKS=(base udev block filesystems)
  567. #
  568. ## This setup assembles a pata mdadm array with an encrypted root FS.
  569. ## Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
  570. # HOOKS=(base udev block mdadm encrypt filesystems)
  571. #
  572. ## This setup loads an lvm2 volume group on a usb device.
  573. # HOOKS=(base udev block lvm2 filesystems)
  574. #
  575. ## NOTE: If you have /usr on a separate partition, you MUST include the
  576. # usr, fsck and shutdown hooks.
  577. HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)
  578. # COMPRESSION
  579. # Use this to compress the initramfs image. By default, gzip compression
  580. # is used. Use 'cat' to create an uncompressed image.
  581. #COMPRESSION="gzip"
  582. #COMPRESSION="bzip2"
  583. #COMPRESSION="lzma"
  584. #COMPRESSION="xz"
  585. #COMPRESSION="lzop"
  586. #COMPRESSION="lz4"
  587. # COMPRESSION_OPTIONS
  588. # Additional options for the compressor
  589. #COMPRESSION_OPTIONS=()
  590. ```
  591. --------------------------
  592. ## Additional hints
  593. ### Retrieving UUIDs
  594. Run `blkid` command as root or with `sudo`.
  595. --------------------------
  596. ## RewriteFS
  597. RewriteFS is a solution to force writing of all hidden [dot files]() into `$HOME/.config` location. Of course, this is just a default setup and can be configured further.
  598. RewriteFS is available in AUR as [rewritefs-git](https://aur.archlinux.org/packages/rewritefs-git/) package.
  599. **WARNING:** Using `rewritefs` may increase your HDD usage in heavy file operations.
  600. ### RewriteFS - installation
  601. **1)** Install RewriteFS (AUR: [rewritefs-git](https://aur.archlinux.org/packages/rewritefs-git/))
  602. **2)** Move all your dotfiles and dotfolders from `$HOME` to `$HOME/.config/` folder (excluding `.config`, `.cache` & `.local` folders). Remove the dot prefix from the names of those moved dotfiles/folders. You should end up of having only three dotfolders in your `$HOME` directory: `.cache`, `.config` and `.local` (and no dotfiles at all). All your previous dotfiles/folders are now in `$HOME/.config`, without the dot prefix in their name. Right? Good. Go ahead.
  603. **3)** Add file `/etc/rewritefs.conf` with the following contents:
  604. ```
  605. m#^(?!\.)# .
  606. m#^\.(cache|config|local)# .
  607. m#^\.# .config/
  608. ```
  609. **4)** Uncomment `user_allow_other` in `/etc/fuse.conf`. According to the rewritefs author, you must do it:
  610. ```
  611. The files are owned by the user of the process that create them, which is rewritefs, not your applications. You have to run rewritefs as [user], not root.
  612. ```
  613. **5)** Configure your fstab. Use `/etc/fstab` example below as a configuration reference.
  614. **NOTE:** It is important to set `<user>` UID and `<user>` GID bits in `/etc/fstab`. Otherwise you may end up creating new files which belong to group root instead of your actual primary group in `$HOME`.
  615. **6)** Log out, switch to another TTY and login as another user or alternatively unmount the partition where your `$HOME` locates at.
  616. **7)** Reboot the system
  617. ### RewriteFS - fstab example
  618. ```
  619. > cat /etc/fstab
  620. #
  621. # /etc/fstab: static file system information
  622. #
  623. # <file system> <dir> <type> <options> <dump> <pass>
  624. #
  625. #########################################
  626. # NVMe: M.2 - FILE SYSTEM PARTITION
  627. # Root system
  628. UUID=9148225b-d661-4e4a-801c-f5bdc48f509e / ext4 defaults,noatime,discard 0 1
  629. #########################################
  630. # Boot files - FAT32 partition, needs mask values
  631. UUID=927D-38E4 /boot_efi vfat defaults,dmask=0022,fmask=0133 0 0
  632. #########################################
  633. # RAM & SWAP
  634. # temporary folders
  635. tmpfs /tmp tmpfs nodev,nosuid,size=20480M,nr_inodes=500k 0 0
  636. # Swap memory file (optional)
  637. /mnt/hdd/swap /swap none bind 0 0
  638. /swap/swapfile none swap defaults 0 0
  639. #########################################
  640. # HDD: SATA - USER FILES PARTITION
  641. UUID=fba31569-c25c-4e30-b117-9ea83c41a8bd /mnt/hdd ext4 defaults,discard 0 2
  642. #########################################
  643. # Bind folders
  644. # /var folder
  645. /mnt/hdd/var /var none bind 0 0
  646. # Home folders
  647. /mnt/hdd/home/root /root none bind 0 0
  648. /root /home/root none bind 0 0
  649. /mnt/hdd/home/<user> /home/<user> rewritefs config=/etc/rewritefs.conf,allow_other,uid=1000,gid=1000 0 0
  650. #########################################
  651. # Optional: mount your cache folders to RAM
  652. NOTE: When rewritefs is being used, mount order must be /tmp and then /home folders. This is because contents of user's .cache folder is written to /tmp/user_cache folder
  653. #tmpfs /home/<user>/.cache tmpfs size=15%,mode=0777,uid=1000,gid=1000 0 0
  654. ```
  655. ```
  656. > stat -c "%A %G:%U %n" /etc/rewritefs.conf
  657. -rw-r--r-- root:root /etc/rewritefs.conf
  658. ```
  659. Common syntax for RewriteFS fstab entry is as follows (not related to this setup):
  660. ```
  661. /mnt/home/<user> /home/<user> rewritefs config=/etc/rewritefs.conf,allow_other,uid=<user UID>,gid=<user GID> 0 0
  662. ```