<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Arch on Bastien Traverse</title>
    <link>https://bastientraverse.com/en/tags/arch/</link>
    <description>Recent content in Arch on Bastien Traverse</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sat, 12 Mar 2022 00:00:00 +0100</lastBuildDate><atom:link href="https://bastientraverse.com/en/tags/arch/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Offline Arch install with local pacman cache</title>
      <link>https://bastientraverse.com/en/posts/2022-03/arch-offline-cache/</link>
      <pubDate>Sat, 12 Mar 2022 00:00:00 +0100</pubDate>
      
      <guid>https://bastientraverse.com/en/posts/2022-03/arch-offline-cache/</guid>
      <description>&lt;p&gt;While developing my &lt;a href=&#34;https://github.com/neitsab/archvm&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Arch VM script&lt;/a&gt;, I had to go through the installation over and over to test every change.&lt;/p&gt;
&lt;p&gt;I am tethered to my phone for Internet connectivity, and the quality and speeds are&amp;hellip; How should I put it? &lt;em&gt;Underwhelming&lt;/em&gt; to say the least (I live in a mountainous rural area).&lt;/p&gt;
&lt;p&gt;So while doing so, I grew increasingly wary of the long wait for packages to download and the &lt;em&gt;287 MB&lt;/em&gt; worth (&lt;em&gt;gah!&lt;/em&gt;) of data it would chip off my 40 GB plan each and every time. What I needed was a way to provide a local package cache to pacman.&lt;/p&gt;
&lt;p&gt;Amazingly, but certainly not surprisingly, &lt;a href=&#34;https://wiki.archlinux.org/title/Offline_installation&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;there is a great article on the Arch wiki&lt;/a&gt; for that.&lt;/p&gt;
&lt;p&gt;However, due to my target file system being exFAT (&lt;em&gt;cough&lt;/em&gt; &lt;a href=&#34;https://bastientraverse.com/en/posts/2022-02/system-imaging/#an-unexpected-obstacle-to-boot-ventoy-shenanigans&#34;&gt;ventoy shenanigans&lt;/a&gt;, &lt;em&gt;cough&lt;/em&gt;) and some file names containing the &lt;a href=&#34;https://averstak.tripod.com/fatdox/names.htm&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;forbidden &lt;code&gt;:&lt;/code&gt; character&lt;/a&gt;, this solution didn&amp;rsquo;t work for me.&lt;/p&gt;
&lt;p&gt;Also because I am using GNOME Boxes, &lt;a href=&#34;https://people.gnome.org/~shaunm/help.gnome.org/gnome-boxes/shared-folders.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;sharing a folder&lt;/a&gt; with the host was out of the equation as that entails installing some &lt;a href=&#34;https://www.spice-space.org/index.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;SPICE&lt;/a&gt;-related packages which pull in an entire graphical stack as dependencies, hence defeating the purpose.&lt;/p&gt;
&lt;p&gt;Setting up SSH access  to the guest requires &lt;a href=&#34;https://unix.stackexchange.com/a/649326&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;quite some fiddling&lt;/a&gt;, and anyway it wasn&amp;rsquo;t immediately clear to me how I would instruct pacstrap to tap into the network cache, or it would have likely required some modifications to the live &lt;code&gt;pacman.conf&lt;/code&gt; and I wanted to avoid all that complexity&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;Remastering the ISO was another option that I left out because I wanted the script to work with a vanilla install. No, what I was really looking for was something of the &lt;em&gt;utmost&lt;/em&gt; simplicity&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;What I finally came up with, and not to toot my own horn but I think it is pretty darn &lt;em&gt;brillant&lt;/em&gt; (considering I haven&amp;rsquo;t seen it mentioned anywhere online when I researched the topic&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;), is a &lt;em&gt;bind mounted squashfs&lt;/em&gt;&lt;sup id=&#34;fnref:4&#34;&gt;&lt;a href=&#34;#fn:4&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;4&lt;/a&gt;&lt;/sup&gt; package cache placed on an external medium like a USB flash drive. This in turn can easily be shared in GNOME Boxes even without the SPICE packages installed in the guest!&lt;/p&gt;
&lt;p&gt;Here is a rundown of the process:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;create a SquashFS archive of &lt;code&gt;/var/cache/pacman/pkg&lt;/code&gt; on a system containing the desired package set (I reused a just-installed VM to match its exact minimal set but you can go wild and copy everything from your main rig, that&amp;rsquo;ll give you a larger cache):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;mksquashfs /var/cache/pacman/pkg/ pkg.sqsh &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    -comp zstd &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    -no-exports &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    -progress &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    -mem 1G &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;    -not-reproducible
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;copy the SquashFS file on the external medium you will mount during the install&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;boot into the Arch Live environment and create two directories, one for your external medium and one for the archive:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mkdir /tmp/{usb,squash}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;admonition note&#34;&gt;&lt;p class=&#34;admonition-title&#34;&gt;Note&lt;/p&gt;
  Do not use &lt;code&gt;/mnt&lt;/code&gt; if you plan to use it as the installation mount point.
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;mount the external medium containing the squash file and then the squash file itself:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mount /dev/XXXY /tmp/usb
mount /tmp/usb/pkg.sqsh /tmp/squash
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;finally, and that&amp;rsquo;s what&amp;rsquo;s doing the trick for pacstrap, &lt;strong&gt;bind&lt;/strong&gt;-mount &lt;code&gt;/tmp/squash&lt;/code&gt; on archiso&amp;rsquo;s &lt;code&gt;/var/cache/pacman/pkg&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mount --bind /tmp/squash /var/cache/pacman/pkg
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;rsquo;s it, now you just have to add &lt;code&gt;-c&lt;/code&gt; to your &lt;a href=&#34;https://man.archlinux.org/man/extra/arch-install-scripts/pacstrap.8.en&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;pacstrap&lt;/a&gt; invocation:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pacstrap -c /mnt base linux [...]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Downloads will be skipped (as long as package versions in the squashfs archive are not older than the synced databases&amp;rsquo; ones), and now you can carry on with your installation, contented by the blissful release of not having to suffer through the hell of this perpetual cycle of reincar&amp;hellip; Err I mean wasteful downloading of already acquired packages 😊️&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://stallman.org/articles/happy-hacking.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Happy hacking&lt;/a&gt;!&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Just as I was bringing the finishing touches to this article, I realized my blunder: what I needed was an access &lt;em&gt;from&lt;/em&gt; the guest to the host, not the contrary. This would allow me to do something like an &lt;a href=&#34;https://wiki.archlinux.org/title/Pacman/Tips_and_tricks#Read-write_cache&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;SSHFS&lt;/a&gt; mount or even &lt;a href=&#34;https://wiki.archlinux.org/title/Pacman/Tips_and_tricks#Read-only_cache&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;serving the cache via a simple web server&lt;/a&gt;. Follow-up article to come on how &lt;em&gt;easy&lt;/em&gt; it actually is to connect from a guest to the host in GNOME Boxes 😁️&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;Yeah, no seriously, in my use case that was the web server/SSHFS mount. But let&amp;rsquo;s just say this article was &lt;em&gt;actually&lt;/em&gt; meant to be for a fully offline install&amp;hellip; 😂️&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:3&#34;&gt;
&lt;p&gt;I&amp;rsquo;ll admit this may only be due to my constraints being ridiculously specific, but maybe for once I can dream of having come up with a truly original solution, wouldn&amp;rsquo;t you agree ? 😀️&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:4&#34;&gt;
&lt;p&gt;The idea of using &lt;a href=&#34;https://tldp.org/HOWTO/SquashFS-HOWTO/whatis.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;SquashFS&lt;/a&gt; instead of a more common loop-mounted filesystem-in-a-file is what I felt was the real feat of ingeniosity here. And yes, I need to pat myself on the back from time to time, is it something wrong? 😉️&amp;#160;&lt;a href=&#34;#fnref:4&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>
