fat32-partitionless-voidlinux-liveusb.html (11707B)
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4<!-- 2021-03-21 --> 5<meta charset="utf-8"> 6<meta name="viewport" content="width=device-width, initial-scale=1"> 7<title>FAT32 Partitionless Void Linux Live USB</title> 8<meta name="generator" content="Org mode"> 9<meta name="author" content="Dash Eclipse"> 10<meta name="description" content="Install Void Linux LiveOS on A FAT32 Partitionless USB Stick, Works for Both UEFI and Legacy BIOS" 11> 12<meta name="keywords" content="voidlinux, liveusb, liveos, refind, syslinux, uefi, legacy bios"> 13<link rel='icon' type='image/x-icon' href='/favicon.svg'/> 14<meta name='viewport' content='width=device-width, initial-scale=1'> 15<link rel='stylesheet' href='/styles/topnav.css' type='text/css'/> 16<link rel='stylesheet' href='/styles/site.css' type='text/css'/> 17<link rel='stylesheet' href='/styles/syntax-coloring.css' type='text/css'/> 18<link rel='alternate' type='application/rss+xml' title='RSS' href='/blog/rss.xml'> 19</head> 20<body> 21<header id="top" class="status"> 22<div> 23<ul class='topnav'> 24<li class='home'><a href='/#dash'>ezup.dev</a></li> 25<li><a class='active' href='./'>Blog</a></li> 26<li><a href='/#pgp'>PGP</a></li> 27<li><a href='/git/' target='_blank'><u>Git</u></a></li> 28<li class='right'><a href='/#about'>About</a></li> 29</ul> 30</div> 31</header> 32<main id="content"> 33<header> 34<h1 class="title">FAT32 Partitionless Void Linux Live USB</h1> 35<p class="subtitle">Published on 2020-07-14 by Dash Eclipse</p> 36</header><nav id="table-of-contents"> 37<h2>Table of Contents</h2> 38<div id="text-table-of-contents"> 39<ul> 40<li><a href="#org994254c">1. What is this about and why do I create Live USB this way</a> 41<ul> 42<li><a href="#orgaf16b49">1.1. Advantages</a></li> 43<li><a href="#org0dbcdad">1.2. How does it work?</a></li> 44</ul> 45</li> 46<li><a href="#orgffdd0f9">2. FAT32 filesystem creation and file directory structure</a></li> 47<li><a href="#org9cada5f">3. UEFI</a></li> 48<li><a href="#org055eedc">4. Legacy BIOS</a> 49<ul> 50<li><a href="#orga3ee035">4.1. Minimal config</a></li> 51<li><a href="#orga31ec01">4.2. Graphical boot menu</a></li> 52</ul> 53</li> 54</ul> 55</div> 56</nav> 57 58<section id="outline-container-org994254c" class="outline-2"> 59<h2 id="org994254c"><span class="section-number-2">1</span> What is this about and why do I create Live USB this way</h2> 60<div class="outline-text-2" id="text-1"> 61<p> 62I use void-live as my Live USB because it supports booting into RAM, so I can eject USB stick after boot into LiveOS. And it's esay to use void-mklive to generate customized iso, it's simple and just works. 63</p> 64 65<p> 66But I don't want to use <code>dd</code> to write iso to my USB stick each time I need to use Live USB, or use a dedicated USB stick for the LiveOS. I can't use the USB stick to store other files once I create Live USB this way. 67</p> 68 69<p> 70The solution is pretty simple, just create one FAT32 filesystem on the USB stick without any partition table, install bootloaders and copy LiveOS to it, and then configure the bootloader to boot the LiveOS. 71</p> 72</div> 73 74<div id="outline-container-orgaf16b49" class="outline-3"> 75<h3 id="orgaf16b49"><span class="section-number-3">1.1</span> Advantages</h3> 76<div class="outline-text-3" id="text-1-1"> 77<ul class="org-ul"> 78<li>Works for both UEFI and Legacy BIOS</li> 79<li>Maximally use the storage, everything in one filesystem</li> 80<li>Could still use the USB stick for storing files as noraml</li> 81<li>Easy to delete the LiveOS from the USB stick, just remove these files</li> 82<li>Simple and just works, no dirty hacks, no need to load iso files</li> 83<li>No need to install boot code<sup><a id="fnr.1" class="footref" href="#fn.1">1</a></sup></li> 84</ul> 85</div> 86</div> 87 88<div id="outline-container-org0dbcdad" class="outline-3"> 89<h3 id="org0dbcdad"><span class="section-number-3">1.2</span> How does it work?</h3> 90<div class="outline-text-3" id="text-1-2"> 91<p> 92It's pretty simple, just install the bootloader, configure it to load <code>vmlinuz</code> the linux kernel and <code>initrd</code> the initramfs and it will load <code>LiveOS/squashfs.img</code> from the FAT32 filesystem which labeled as <code>VOID_LIVE</code>. 93</p> 94 95<p> 96Just install bootloaders for UEFI and Legacy BIOS, I choose rEFInd for UEFI and syslinux for Legacy BIOS. 97</p> 98 99<p> 100For UEFI, a FAT32 filesystem is necessary for loading a boot manager or bootloader, the FAT32 filesystem does not necessarily need to be inside a GPT or MBR partition table, it could on the whole device without any partition table (a.k.a. partitionless). 101</p> 102 103<p> 104For Legacy BIOS, when you have a partition table on the hard drive, you need to install the boot code to the device to be able to boot from it, and the partition which contains the bootloader should be marked as <b>active</b>. But you don't need to install boot code for a partitionless setup<sup><a id="fnr.1.100" class="footref" href="#fn.1">1</a></sup>, it just boots from the filesystem. 105</p> 106</div> 107</div> 108</section> 109 110<section id="outline-container-orgffdd0f9" class="outline-2"> 111<h2 id="orgffdd0f9"><span class="section-number-2">2</span> FAT32 filesystem creation and file directory structure</h2> 112<div class="outline-text-2" id="text-2"> 113<p> 114Assume the USB stick where we are going to create Live USB on is <code>/dev/sdc</code> and the FAT32 volume name is <code>VOID_LIVE</code>, you can create it with this command. Note the volume name can be other value but must be identical as boot options specified in bootloader configuration files. 115</p> 116<div class="org-src-container"> 117<pre class="src src-sh">sudo mkfs.vfat -I -F32 -n VOID_LIVE /dev/sdc 118</pre> 119</div> 120 121<ul class="org-ul"> 122<li><code>LiveOS/</code> linux kernel, initramfs and LiveOS from void-live <sup><a id="fnr.2" class="footref" href="#fn.2">2</a></sup></li> 123<li><code>EFI/</code> rEFInd stuff for UEFI boot</li> 124<li><code>syslinux/</code> syslinux stuff for legacy BIOS boot</li> 125</ul> 126<p> 127Boot options can be found in <code>boot/isolinux/isolinux.cfg</code> or <code>boot/grub/grub_void.cfg</code> from void-live iso. 128</p> 129<pre style="line-height:1;"> 130VOID_LIVE 131├── EFI 132│ ├── BOOT 133│ │ ├── BOOTX64.EFI 134│ │ └── refind.conf 135│ └── refind 136│ ├── refind.conf 137│ └── refind_x64.efi 138├── LiveOS 139│ ├── initrd 140│ ├── squashfs.img 141│ └── vmlinuz 142└── syslinux 143 ├── ldlinux.c32 144 ├── ldlinux.sys 145 └── syslinux.cfg 146 1475 directories, 10 files 148</pre> 149</div> 150</section> 151 152<section id="outline-container-org9cada5f" class="outline-2"> 153<h2 id="org9cada5f"><span class="section-number-2">3</span> UEFI</h2> 154<div class="outline-text-2" id="text-3"> 155<p> 156I use rEFInd Boot Manager for UEFI boot, you can just download it from <a href="https://www.rodsbooks.com/refind/getting.html">the official website</a> and copy it to the FAT32 filesystem, or install <code>refind</code> the voidlinux package and then copy it from <code>/usr/share/refind</code>. It looks better with themes such like <a href="https://github.com/munlik/refind-theme-regular">refind-theme-regular</a>. You are free to customize it. 157</p> 158 159<p> 160<code>EFI/{BOOT,refind}/refind.conf</code> 161</p> 162<pre class="example" id="org3bca618"> 163timeout 20 164 165menuentry "Void Linux (x86_64-musl)" { 166 loader LiveOS/vmlinuz 167 initrd /LiveOS/initrd 168 options "root=live:CDLABEL=VOID_LIVE ro init=/sbin/init rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap vconsole.unicode=1 vconsole.keymap=dvorak-programmer locale.LANG=en_US.UTF-8 rd.live.overlay.overlayfs=1" 169} 170 171menuentry "Void Linux (x86_64-musl) (RAM)" { 172 loader LiveOS/vmlinuz 173 initrd /LiveOS/initrd 174 options "root=live:CDLABEL=VOID_LIVE ro init=/sbin/init rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap vconsole.unicode=1 vconsole.keymap=dvorak-programmer locale.LANG=en_US.UTF-8 rd.live.overlay.overlayfs=1 rd.live.ram" 175} 176</pre> 177</div> 178</section> 179 180<section id="outline-container-org055eedc" class="outline-2"> 181<h2 id="org055eedc"><span class="section-number-2">4</span> Legacy BIOS</h2> 182<div class="outline-text-2" id="text-4"> 183<p> 184I use syslinux because it's more lightweight than grub, <code>syslinux</code> the package is required to install syslinux to USB stick. You can use the minimal config or graphical boot menu config, I recommend to use the minimal one. 185</p> 186</div> 187 188<div id="outline-container-orga3ee035" class="outline-3"> 189<h3 id="orga3ee035"><span class="section-number-3">4.1</span> Minimal config</h3> 190<div class="outline-text-3" id="text-4-1"> 191<p> 192To avoid syslinux <code>Boot Error</code> I just use this minimal configuration without any non-core syslinux modules, and only run the extlinux/syslinux command once. I recommend you to create the Live USB in this order. 193</p> 194 195<ol class="org-ol"> 196<li>Create FAT32 filesystem</li> 197<li>mount it to VOID_LIVE, create VOID_LIVE/syslinux/ folder</li> 198<li>Install syslinux with <code>extlinux --install VOID_LIVE/syslinux</code></li> 199<li>Add syslinux/syslinux.cfg and LiveOS/{vmlinuz,initrd,squashfs.img}</li> 200</ol> 201 202<p> 203<code>syslinux/syslinux.cfg</code> 204</p> 205<pre class="example" id="org3ba0504"> 206PROMPT 1 207TIMEOUT 50 208DEFAULT voidram 209 210LABEL void 211 LINUX /LiveOS/vmlinuz 212 APPEND initrd=/LiveOS/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=dvorak-programmer locale.LANG=en_US.UTF-8 rd.live.overlay.overlayfs=1 213 214LABEL voidram 215 LINUX /LiveOS/vmlinuz 216 APPEND initrd=/LiveOS/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=dvorak-programmer locale.LANG=en_US.UTF-8 rd.live.overlay.overlayfs=1 rd.live.ram 217</pre> 218</div> 219</div> 220 221<div id="outline-container-orga31ec01" class="outline-3"> 222<h3 id="orga31ec01"><span class="section-number-3">4.2</span> Graphical boot menu</h3> 223<div class="outline-text-3" id="text-4-2"> 224<p> 225You can check <code>boot/isolinux/{*.c32,isolinux.cfg}</code> from void-live iso for dependencies and config to use graphical boot menu, but from my experience you need to create the Live USB in this order to avoid syslinux <code>Boot Error</code> (not able to boot), especially when the squashfs.img is large. 226</p> 227 228<ol class="org-ol"> 229<li>Create FAT32 filesystem</li> 230<li>mount it to VOID_LIVE</li> 231<li>Add <code>syslinux/{chain,libcom32,libutil,vesamenu}.c32</code> (from <code>/usr/lib/syslinux</code>), <code>/syslinux.cfg</code> (optionally <code>splash.png</code>), and <code>LiveOS/{vmlinuz,initrd}</code></li> 232<li>Install syslinux with <code>extlinux --install VOID_LIVE/syslinux</code></li> 233<li>Add VOID_LIVE/LiveOS/squashfs.img</li> 234<li>umount VOID_LIVE</li> 235</ol> 236 237<p> 238Note it may won't able to boot if you change any of files syslinux may load, including kernel and initramfs. Reinstall syslinux to the USB stick won't help and the only solution I know is recreate the FAT32 filesystem and start over again. 239</p> 240</div> 241</div> 242</section> 243<div id="footnotes"> 244<h2 class="footnotes">Footnotes: </h2> 245<div id="text-footnotes"> 246 247<div class="footdef"><sup><a id="fn.1" class="footnum" href="#fnr.1">1</a></sup> <div class="footpara"><p class="footpara"> 248<a href="https://unix.stackexchange.com/a/103568">For Legacy BIOS, Using a filesystem without a partition table thus not only saves space, but also a step in the boot process.</a> 249</p></div></div> 250 251<div class="footdef"><sup><a id="fn.2" class="footnum" href="#fnr.2">2</a></sup> <div class="footpara"><p class="footpara"> 252Use the official <a href="https://voidlinux.org/download/">void-live</a> or create your own iso by using <a href="https://github.com/void-linux/void-mklive">void-mklive</a> 253</p></div></div> 254 255 256</div> 257</div></main> 258</body> 259</html>