{"id":129,"date":"2024-10-31T17:50:36","date_gmt":"2024-10-31T16:50:36","guid":{"rendered":"https:\/\/trashdump.net\/?p=129"},"modified":"2024-11-01T12:24:00","modified_gmt":"2024-11-01T11:24:00","slug":"universal-usb-boot-stick-based-on-ventoy","status":"publish","type":"post","link":"https:\/\/trashdump.net\/?p=129","title":{"rendered":"Universal USB Boot Stick based on Ventoy"},"content":{"rendered":"<h2 id='running-non-iso-linux-from-flash-drive'  id=\"boomdevs_1\" >Running non ISO Linux from flash drive<\/h2>\n<p>While testing Ventoy and its option for customization I was wondering whether storing and starting the different images on the USB Stick is realy the most effective way.<br \/>\nHavinf different Images in place for fast installations is great. And the oportunity ofjust copying them to the flash drive without any further hazel is nearly perfect for daily <a class=\"wp-editor-md-post-content-link\" href=\"#changing-the-reference-to-the-filesystem-within-initrdgz\">purposes<\/a>.<\/p>\n<p>But on the other hand I there are three other use cases for Live Systems<\/p>\n<ul>\n<li>Preinstalled Toolset for Work<\/li>\n<li>Hacking<\/li>\n<li>Images for System Rescue<\/li>\n<\/ul>\n<p>For those use cases a more efficient way for booting and storing Data on the same flash drive makes more sense.<\/p>\n<h3 id='mounting-iso-and-extract-necessary-files'  id=\"boomdevs_2\" >Mounting ISO and extract necessary files<\/h3>\n<p>Mounting an ISO is quiet easy. Either open it wiith graphical UI of the OS of your choice or (on &#42;nix) mount ist as a loop device.<\/p>\n<pre><code class=\"language-bash line-numbers\">mkdir \/tmp\/loop\nsudo mount -o loop \/path\/to\/some.iso \/tmp\/loop\n<\/code><\/pre>\n<p>Now extract the vmlinuz, initrd.gz and the root filesystem. Based on Damm Small Linux 2024 this looks like this.<\/p>\n<pre><code class=\"language-bash line-numbers\">tree \/Volumes\/dsl-2024.rc7\/\n\/Volumes\/dsl-2024.rc7\/\n\u251c\u2500\u2500 antiX\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 initrd.gz\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 initrd.gz.md5\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 linuxfs\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 linuxfs.info\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 linuxfs.md5\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 random-seed\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 vmlinuz\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 vmlinuz.md5\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 vmlinuz1.md5\n\u251c\u2500\u2500 boot\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 isolinux\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 README\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 boot.cat\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 chain.c32\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 console.def.gfx\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 console.def.orig\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 console.men.orig\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 gfx-cpio\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 gfxboot.c32\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 gfxsave.cfg\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 isolinux.bin\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 isolinux.cat\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 isolinux.cfg\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 ldlinux.c32\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 libcom32.c32\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 libmenu.c32\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 libutil.c32\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 menu.c32\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 readme.msg\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 version\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 memtest\n\u251c\u2500\u2500 cdrom.ico\n\u2514\u2500\u2500 version\n\n4 directories, 31 files\n<\/code><\/pre>\n<p>Checking the <code>\/boot\/isolinux\/isolinux.cfg<\/code> gives us a brief overview abot the needs.<\/p>\n<pre><code class=\"language-properties line-numbers\">...\n#    MENU LABEL antiX-23-runit_386-base (26 August 2023)\nLABEL live\n    MENU LABEL DSL 2024, hacked from antiX 23\n    KERNEL \/antiX\/vmlinuz\n    APPEND quiet splasht disable=lxF\n    INITRD \/antiX\/initrd.gz\n...\n<\/code><\/pre>\n<p>To avoid missing something we copy the complete directory <code>antiX<\/code>. Problem is, that the filesystem is withn the Image <code>linuxfs<\/code>, which is mounted in an overlay configuration stored in <code>initrd.gz<\/code>.<\/p>\n<p>On the the flash drive we create a directory to store our non ISO based systems (in my case <code>\/linux<\/code>). Within this directory we create as subdirectories for Damm Small Linux (<code>dsl<\/code>) in which we copy all the files from the <code>antiX<\/code> directory.<\/p>\n<h3 id='changing-the-reference-to-the-filesystem-within-initrd-gz'  id=\"boomdevs_3\" >Changing the reference to the filesystem within initrd.gz<\/h3>\n<p>To update the reference we have to extract the data from the initrd.<\/p>\n<pre><code class=\"language-bash line-numbers\">mkdir \/tmp\/temp-initrd\ncd \/tmp\/temp-initrd\ngzip -dc \/[path to flash drive]\/linux\/dsl\/initrd.gz | cpio --extract --make-directories\n<\/code><\/pre>\n<p>Now we can edit the path to the <code>init<\/code> file in the root of our temporary directory and update the default path to <code>linuxfs<\/code>.<\/p>\n<pre><code class=\"language-bash line-numbers\">vi init\n\n...\n    DEFAULT_SQFILE=\/antiX\/linuxfs    (change to:\/linux\/dsl\/linuxfs)\n...\n\n\/linuxfs\n\n<\/code><\/pre>\n<p>After saving those change it is time to recreate the <code>initrd.gz<\/code>. The following pipe of commands finds every content in the current directory pipes it to cpio for creating a new initrd which pipes the output to gzip for compressing and storing it back to our target directory on the flash drive.<\/p>\n<pre><code class=\"language-bash line-numbers\">find . | cpio --create --format=newc | gzip &gt; \/[path to flash drive]\/linux\/dsl\/initrd.gz\n<\/code><\/pre>\n<h3 id='creating-a-custom-grub2-menu'  id=\"boomdevs_4\" >Creating a custom grub2 menu<\/h3>\n<p>Since we not have an image here the necessary item in grub2 will not automatically be created. Therefor we use the custom menu plugin from ventoy and define custom class for our entries.<\/p>\n<p>If not existing we create a <code>ventoy<\/code> directory in the root of the flash drive. That&#8217;s the common directory for config and themes in Ventoy.<\/p>\n<pre><code class=\"language-bash line-numbers\">mkdir -p \/[path to flash drive]\/ventoy\n<\/code><\/pre>\n<p>Next we create a file named <code>ventoy_grub.cfg<\/code> to store our custom menu configuration.<\/p>\n<pre><code class=\"language-bash line-numbers\">vi \/[path to flash drive]\/ventoy\/ventoy_grub.cfg\n<\/code><\/pre>\n<p>with the following content<\/p>\n<pre><code class=\"language-properties line-numbers\">menuentry \"Damm Small Linux\" --class=custom {\n    echo \"Loading Kernel ...\"\n    linux (hd0,msdos1)\/linux\/dsl\/vmlinuz root=(hd0,msdos1)\/linux\/dsl\/linuxfs\n    echo \"Loading Initrd ...\"\n    initrd (hd0,msdos1)\/linux\/dsl\/initrd.gz\n}\nmenuentry '&lt;-- Return to previous menu [Esc]' --class=vtoyret VTOY_RET {\n    echo 'Return ...'\n}\n<\/code><\/pre>\n<p>After saving this we are ready for booting our customized Ventoy flash drive. After booting into the Ventoy grub2 menu we have to call our custom menu with [F6] and kann boot directly without beeing limited by the ISOs in boot time or errors caused by failed file sources.<\/p>\n<p>To be done:<\/p>\n<ul>\n<li><input style=\"margin-right:5px\" type=\"checkbox\" class=\"task-list-item-checkbox\" disabled \/>Creating a directory or a partition on flash drive to store data and system state<\/li>\n<\/ul>\n<p>[TOC]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Running non ISO Linux from flash drive While testing Ventoy and its option for customization I was wondering whether storing and starting the different images on the USB Stick is realy the most effective way. Havinf different Images in place for fast installations is great. And the oportunity ofjust copying them to the flash drive [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/posts\/129"}],"collection":[{"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trashdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=129"}],"version-history":[{"count":11,"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/trashdump.net\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/trashdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trashdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trashdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}