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.

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