<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Raspberry Pi – Linux und Ich</title>
	<atom:link href="https://linuxundich.de/en/tag/raspberry-pi/feed/" rel="self" type="application/rss+xml" />
	<link>https://linuxundich.de/en</link>
	<description>A German Linux blog, in English</description>
	<lastBuildDate>Tue, 06 Oct 2026 15:30:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>Raspberry Pi Imager 2.0 on Linux: Installing, Root Privileges, CLI and Tips</title>
		<link>https://linuxundich.de/en/raspberry-pi-imager-linux-root-cli-tips/</link>
					<comments>https://linuxundich.de/en/raspberry-pi-imager-linux-root-cli-tips/#respond</comments>
		
		<dc:creator><![CDATA[Christoph Langner]]></dc:creator>
		<pubDate>Tue, 06 Oct 2026 15:30:44 +0000</pubDate>
				<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://linuxundich.de/en/?p=170</guid>

					<description><![CDATA[Raspberry Pi Imager 2.0 comes with a completely new interface. I'll show you how to install the current version on Arch Linux and Ubuntu, why Ubuntu foists outdated versions on you, how the Imager obtains root privileges and what it can do in the terminal.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Lately I&#8217;ve been putting my Raspberry Pis to work a lot more often again. And anyone starting new projects on the little computer inevitably ends up back at the Raspberry Pi Imager. The last time I used the program regularly, it was still a plain window with three buttons and a hidden settings dialog.</p>



<p class="wp-block-paragraph">So I wanted to take another look at what has happened with the Imager since then. The short answer: quite a lot. The long answer – with a special focus on us Linux users and the little pitfalls that most guides gloss over – is what this article is about.</p>



<h2 class="wp-block-heading">What is the Raspberry Pi Imager?</h2>



<p class="wp-block-paragraph">The Raspberry Pi Imager is the official tool from the makers of the Raspberry Pi for writing operating system images to a microSD card, a USB stick or an SSD. Unlike a plain old <code>dd</code>, the Imager downloads the images directly, decompresses them on the fly, writes them and then verifies the result.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae05898682e8&quot;}" data-wp-interactive="core/image" data-wp-key="6ae05898682e8" class="wp-block-image size-large wp-lightbox-container"><img fetchpriority="high" decoding="async" height="917" sizes="(max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-modell-auswahl-640x458.webp 640w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-modell-auswahl-768x550.webp 768w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-modell-auswahl-1280x917.webp 1280w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-modell-auswahl.webp 1297w" width="1280" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-modell-auswahl-1280x917.webp" alt="Raspberry Pi Imager 2.0.11.1 on Arch Linux with step bar and model list from Raspberry Pi 5 to Pi Zero."/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">Imager 2.0 starts by asking for your Pi model and then only shows operating systems that fit your board.</figcaption></figure>



<p class="wp-block-paragraph">Besides Raspberry Pi OS, the selection also includes Ubuntu, media centre distributions, retro gaming systems, images for 3D printers and home automation as well as utility images, for example for updating the bootloader. The program is licensed under Apache 2.0, and the source code lives <a href="https://github.com/raspberrypi/rpi-imager">on GitHub</a>. So you can check at any time what it is doing on your machine.</p>



<p class="wp-block-paragraph">The real highlight, though, is the <a href="https://www.raspberrypi.com/documentation/computers/getting-started.html#imager-install">pre-configuration</a>: hostname, user account, Wi-Fi, time zone, keyboard layout and SSH access can all be set before the first boot. The Pi then joins the network fully set up – ideal for headless operation, where you want to get by without a monitor and keyboard.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae058986888d&quot;}" data-wp-interactive="core/image" data-wp-key="6ae058986888d" class="wp-block-image size-large wp-lightbox-container"><img decoding="async" height="917" sizes="(max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-betriebssystem-auswahl-640x458.webp 640w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-betriebssystem-auswahl-768x550.webp 768w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-betriebssystem-auswahl-1280x917.webp 1280w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-betriebssystem-auswahl.webp 1297w" width="1280" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-betriebssystem-auswahl-1280x917.webp" alt="Operating system selection in Raspberry Pi Imager with Raspberry Pi OS in 64-bit, 32-bit and Legacy plus further categories."/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">Raspberry Pi OS based on Debian Trixie sits right at the top, with further distributions and special-purpose systems in the categories below.</figcaption></figure>



<h2 class="wp-block-heading">What&#8217;s new in Raspberry Pi Imager 2.0?</h2>



<p class="wp-block-paragraph">At the end of November 2025, the Foundation released <a href="https://www.raspberrypi.com/news/a-new-raspberry-pi-imager/">Raspberry Pi Imager 2.0</a>; by now version 2.0.11 is current (or 2.0.11.1 as a hotfix). A lot has changed under the hood since then, but above all the program looks completely different. The most important changes at a glance:</p>



<ul class="wp-block-list">

<li><strong>Wizard instead of a single window:</strong> You now click your way step by step through device, operating system, storage device, customisation and writing.</li>


<li><strong>Customisation in plain sight:</strong> The formerly hidden dialog for the &#8220;advanced options&#8221; (<code>Ctrl</code>+<code>Shift</code>+<code>X</code>, anyone?) is now a regular step in the wizard.</li>


<li><strong>Location by capital city:</strong> Instead of country codes you pick a capital city, and the Imager derives the time zone, keyboard layout and Wi-Fi regulatory country from it.</li>


<li><strong>Interfaces at the click of a mouse:</strong> <a href="https://en.wikipedia.org/wiki/I%C2%B2C">I2C</a>, <a href="https://en.wikipedia.org/wiki/Serial_Peripheral_Interface">SPI</a>, <a href="https://en.wikipedia.org/wiki/1-Wire">1-Wire</a>, the <a href="https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter">serial interface</a> and <a href="https://www.raspberrypi.com/news/usb-gadget-mode-in-raspberry-pi-os-ssh-over-usb/">USB gadget mode</a> (the Pi presents itself as a network device on the USB port, so SSH works straight over the cable) can be enabled directly in the Imager, with no detour via <a href="https://www.raspberrypi.com/documentation/computers/configuration.html">raspi-config</a>.</li>


<li><strong>Raspberry Pi Connect:</strong> You can sign in with your <a href="https://www.raspberrypi.com/documentation/services/connect.html">Connect account</a> while writing, and the Pi then shows up in remote access right after the first boot. Since version 2.0.10 this also works with Connect for Organisations.</li>


<li><strong>Accessibility:</strong> The interface can be operated entirely by keyboard and is labelled for screen readers.</li>


<li><strong>Stricter verification:</strong> The Imager forces the operating system to actually confirm written blocks. This can make writing take a little longer, but the result is more reliable.</li>

</ul>



<p class="wp-block-paragraph">Something has been removed as well, though: custom image files can still be written, but can no longer be pre-configured with hostname, Wi-Fi and so on. The developers justify this by saying the feature was never officially supported. Only images that are flagged accordingly can still be customised.</p>



<p class="wp-block-paragraph">So if you have been pre-configuring a self-built image with the Imager, you&#8217;ll need to find another way – or turn to the CLI mode, which I introduce further down. There is good news on SSH keys, however: support for multiple keys, which was dropped when 2.0 launched, has since returned.</p>



<h2 class="wp-block-heading">Installing Raspberry Pi Imager on Linux</h2>



<p class="wp-block-paragraph">This is where things get interesting for us Linux users, because the distributions differ considerably. The official <a href="https://www.raspberrypi.com/software/">download page</a> offers an AppImage for Linux. On <a href="https://github.com/raspberrypi/rpi-imager/releases">GitHub</a> there are additionally <code>.deb</code> packages for amd64, arm64 and armhf as well as a pure command-line version. What your distribution ships, however, is a different story.</p>



<h3 class="wp-block-heading">Arch Linux: up to date straight from extra</h3>



<p class="wp-block-paragraph">As so often, Arch users have it easiest: the Imager is in the <a href="https://archlinux.org/packages/extra/x86_64/rpi-imager/">official extra repository</a> and is up to date there (version 2.0.11.1 at the time of writing). No AUR helper is needed; a simple pacman call is enough, and the Imager is ready in your application menu:</p>



<pre class="wp-block-code"><code>$ sudo pacman -S rpi-imager</code></pre>



<p class="wp-block-paragraph">The Arch package ships a <a href="https://wiki.archlinux.org/title/Polkit">Polkit</a> rule. If you launch the Imager normally from the application menu, it requests the necessary privileges itself via pkexec – so you just enter your password in the Polkit dialog. If you use an AUR helper such as Paru or Yay, you&#8217;ll also find <code>rpi-imager-git</code> in the AUR – normally you won&#8217;t need it.</p>



<h3 class="wp-block-heading">Ubuntu: hands off Universe and Snap</h3>



<p class="wp-block-paragraph">On Ubuntu, by contrast, there is a trap that none of the usual guides say a word about. A <code>sudo apt install rpi-imager</code> does work, but even on Ubuntu 26.04 it still installs the ancient version 1.8.5 from <a href="https://launchpad.net/ubuntu/+source/rpi-imager">universe</a>. The <a href="https://snapcraft.io/rpi-imager">snap in the Snap Store</a> is stuck at version 1.9.6 as well.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae0589869576&quot;}" data-wp-interactive="core/image" data-wp-key="6ae0589869576" class="wp-block-image size-large wp-lightbox-container"><img decoding="async" height="835" sizes="(max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2026/10/ubuntu-app-zentrum-rpi-imager-640x434.webp 640w, https://linuxundich.de/wp-content/uploads/2026/10/ubuntu-app-zentrum-rpi-imager-768x521.webp 768w, https://linuxundich.de/wp-content/uploads/2026/10/ubuntu-app-zentrum-rpi-imager.webp 1232w" width="1232" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2026/10/ubuntu-app-zentrum-rpi-imager.webp" alt="Ubuntu App Center with the Imager in version 1.8.5+noembed-0ubuntu6, unrestricted permissions and Install button."/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">Ubuntu&#8217;s App Center conveniently offers the Imager for installation, but only delivers the outdated version 1.8.5.</figcaption></figure>



<p class="wp-block-paragraph">So neither package gets the new wizard, Raspberry Pi Connect or the bug fixes of recent months. Ubuntu users are therefore better off with the AppImage, the Flatpak (both covered below) or the official <code>.deb</code> package from <a href="https://github.com/raspberrypi/rpi-imager/releases">GitHub</a>. Replace <code>&lt;version&gt;</code> in the command with the version number of the file you downloaded:</p>



<pre class="wp-block-code"><code>$ sudo apt install ./rpi-imager_&lt;version&gt;_amd64.deb</code></pre>



<p class="wp-block-paragraph">If you already have an old version installed via apt or Snap, remove it first so that you don&#8217;t end up with two Imagers side by side in your application menu. Otherwise you may accidentally launch the old version and wonder where the features have gone.</p>



<pre class="wp-block-code"><code>$ sudo apt remove rpi-imager
$ sudo snap remove rpi-imager</code></pre>



<h3 class="wp-block-heading">AppImage: the official route for all distributions</h3>



<p class="wp-block-paragraph">The AppImage works regardless of distribution – so on Fedora, openSUSE and the like too. Download it from the official download page, make it executable and run it; no installation is required. Here, too, replace the <code>&lt;version&gt;</code> placeholder with the version number from the file name:</p>



<pre class="wp-block-code"><code>$ chmod +x Raspberry_Pi_Imager-v&lt;version&gt;-desktop-x86_64.AppImage
$ ./Raspberry_Pi_Imager-v&lt;version&gt;-desktop-x86_64.AppImage</code></pre>



<p class="wp-block-paragraph">On first launch without root privileges, the Imager complains and offers you the Install Authorization button. If you click it, it places (after you enter your password) a Polkit rule under <code>/etc/polkit-1/actions/</code> that applies to exactly this path of the AppImage. After that, it obtains the privileges by itself on every launch.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae0589869e51&quot;}" data-wp-interactive="core/image" data-wp-key="6ae0589869e51" class="wp-block-image size-large wp-lightbox-container"><img loading="lazy" decoding="async" height="770" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-ubuntu-berechtigungen-640x473.webp 640w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-ubuntu-berechtigungen-768x568.webp 768w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-ubuntu-berechtigungen.webp 1041w" width="1041" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-ubuntu-berechtigungen.webp" alt="Insufficient permissions dialog in Raspberry Pi Imager 2.0.11 on Ubuntu with Install Authorization and Quit."/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">Without root privileges, the AppImage offers to set up a Polkit rule itself. The suggested sudo command, however, doesn&#8217;t work at all without a path.</figcaption></figure>



<p class="wp-block-paragraph">If you later move the AppImage to a different folder, you have to set up the authorisation again. If you&#8217;d rather work without a permanent rule, launch the AppImage with <code>sudo</code>. There is a stumbling block here that Michael Kofler points out in <a href="https://kofler.info/raspberry-pi-imager/">his article</a>: sudo does not search the current directory, so you have to specify a path.</p>



<pre class="wp-block-code"><code>$ sudo ./Raspberry_Pi_Imager-v&lt;version&gt;-desktop-x86_64.AppImage</code></pre>



<p class="wp-block-paragraph">Without the <code>./</code> all you get is &#8220;command not found&#8221;. Curiously, the Imager itself suggests exactly this command without a path in its missing-privileges dialog. On Ubuntu 24.04 a second trap awaits: there the AppImage crashes right at startup because Qt is missing a library for X11. In the terminal it looks like this:</p>



<pre class="wp-block-code"><code>$ ./Raspberry_Pi_Imager-v2.0.11-desktop-x86_64.AppImage 
Platform: Linux 7.0.0-38-generic (x86_64)
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin &quot;xcb&quot; in &quot;/tmp/.mount_RaspbedIOBeG/usr/plugins/platforms&quot; even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-brcm, wayland-egl, wayland, xcb.

Aborted (core dumped)</code></pre>



<p class="wp-block-paragraph">The fix is the <code>libxcb-cursor0</code> package, which you install as usual through the package manager. After that, the Imager starts without complaint on Ubuntu 24.04 too. On Ubuntu 26.04 the problem no longer occurs. The <code>libfuse2t64</code> package that used to be recommended so often, on the other hand, was no longer necessary in my test.</p>



<pre class="wp-block-code"><code>$ sudo apt install libxcb-cursor0</code></pre>



<p class="wp-block-paragraph">By the way: the 2.0.11.1 hotfix has so far only been released for Windows, macOS and as a <code>.deb</code> package; as an AppImage, 2.0.11 is the latest version. That&#8217;s no big deal, though, because the hotfix merely fixes a bug when signing in to Raspberry Pi Connect. If you don&#8217;t use Connect, you&#8217;re not missing anything.</p>



<h3 class="wp-block-heading">Flatpak: convenient, but not verified by the vendor</h3>



<p class="wp-block-paragraph">On <a href="https://flathub.org/apps/org.raspberrypi.rpi-imager">Flathub</a> the Imager is available as <code>org.raspberrypi.rpi-imager</code> in the current version. The Flatpak gets full access to all devices and talks to UDisks2 to write to storage devices. A nice touch for the privacy-conscious: it is built without telemetry. Installation works as usual:</p>



<pre class="wp-block-code"><code>$ flatpak install flathub org.raspberrypi.rpi-imager</code></pre>



<p class="wp-block-paragraph">Note, however, that the app is not marked as <a href="https://docs.flathub.org/docs/for-users/verification">verified</a> on Flathub. Flathub does name Raspberry Pi Ltd as the developer, but that doesn&#8217;t tell you whether Raspberry Pi maintains the package itself. As a rule this isn&#8217;t a problem, but you should be aware of it.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae058986a8f8&quot;}" data-wp-interactive="core/image" data-wp-key="6ae058986a8f8" class="wp-block-image size-large wp-lightbox-container"><img loading="lazy" decoding="async" height="917" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-flatpak-gnome-software-640x458.webp 640w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-flatpak-gnome-software-768x550.webp 768w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-flatpak-gnome-software-1280x917.webp 1280w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-flatpak-gnome-software.webp 1297w" width="1280" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-flatpak-gnome-software-1280x917.webp" alt="Raspberry Pi Imager from Flathub in GNOME Software with Install button and screenshot of the old interface."/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">Flathub delivers the current Imager, but the screenshots in GNOME Software still show the old interface of version 1.2.</figcaption></figure>



<h3 class="wp-block-heading">Raspberry Pi OS</h3>



<p class="wp-block-paragraph">If you want to use the Imager directly on a Raspberry Pi, for example to prepare a second card or an SSD for another Pi, you install it on Raspberry Pi OS the classic way from the package sources. Here the package comes straight from the Foundation&#8217;s repositories, unlike on Ubuntu:</p>



<pre class="wp-block-code"><code>$ sudo apt update &amp;&amp; sudo apt install rpi-imager</code></pre>



<p class="wp-block-paragraph">On the Raspberry Pi 4 and 5 you can get by without a second computer entirely: their bootloader can use <a href="https://www.raspberrypi.com/documentation/computers/getting-started.html#network-install">network install</a> to load a stripped-down version of the Imager from the internet, which you then use to write an SD card or SSD directly in the Pi. With version 2.0.11, this network installer was noticeably reworked and slimmed down.</p>



<h2 class="wp-block-heading">Why does the Imager need root privileges at all?</h2>



<p class="wp-block-paragraph">On Windows and macOS you hardly notice it, but on Linux you do: the Imager writes directly to the block device, for example <code>/dev/sdb</code> or <code>/dev/mmcblk0</code>, and a normal user isn&#8217;t allowed to do that. Version 2 therefore takes care of obtaining the necessary privileges via pkexec itself.</p>



<p class="wp-block-paragraph">The prerequisite is a matching Polkit rule. With the Arch package and the official <code>.deb</code> it is installed along with the program; with the AppImage you create it via Install Authorization. If you launch the Imager via sudo or pkexec, settings and the download cache still end up in your home directory and not in <code>/root</code>, because the Imager detects the calling user.</p>



<p class="wp-block-paragraph">A little tip for the tidy-minded: the rules created by the AppImage are named <code>com.raspberrypi.rpi-imager.appimage-&lt;hash&gt;.policy</code> and live under <code>/etc/polkit-1/actions/</code>. If you delete the AppImage, you can remove the corresponding rule there by hand. This also works on distributions with a read-only <code>/usr</code> such as <a href="https://fedoraproject.org/atomic-desktops/silverblue/">Fedora Silverblue</a>, since the Imager deliberately writes to <code>/etc</code>.</p>



<div class="wp-block-group lui-no-link-marker lui-no-autolink has-border-color has-base-2-background-color has-background has-global-padding is-layout-constrained wp-container-core-group-is-layout-389236d9 wp-block-group-is-layout-constrained" style="border-color:var(--wp--preset--color--line);border-width:1px;border-radius:8px;margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50);padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)">
<p class="has-muted-color has-text-color has-small-font-size wp-block-paragraph" style="font-weight:700;letter-spacing:0.08em;text-transform:uppercase">What you need</p>



<p class="wp-block-paragraph">To get started, a Pi 5 with a power supply and a fast microSD card is all you need. My picks as of October 2026:</p>



<p class="wp-block-paragraph" style="margin-top:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--20);font-weight:700">The computer</p>



<div class="wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-957a3321 wp-block-columns-is-layout-flex" style="border-top-color:var(--wp--preset--color--line);border-top-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:70%">
<p class="has-small-font-size wp-block-paragraph"><strong>Raspberry Pi 5 (8 GB)</strong><br>Plenty of headroom for Pi-hole, Home Assistant, a desktop, containers and experiments.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%">
<div class="wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-c5ec1813 wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-outline is-style-outline--1"><a class="wp-block-button__link has-small-font-size has-custom-font-size wp-element-button" href="https://www.amazon.com/dp/B0CK2FCG1K/?tag=linuxundich-20" target="_blank" rel="sponsored nofollow noopener">On Amazon</a></div>
</div>
</div>
</div>



<p class="wp-block-paragraph" style="margin-top:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--20);font-weight:700">To run it</p>



<div class="wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-957a3321 wp-block-columns-is-layout-flex" style="border-top-color:var(--wp--preset--color--line);border-top-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:70%">
<p class="has-small-font-size wp-block-paragraph"><strong>27 W USB-C power supply for the Pi 5 (US plug)</strong><br>The Pi 5 wants 5 V at 5 A; a weaker supply throttles it and its USB ports.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%">
<div class="wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-c5ec1813 wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-outline is-style-outline--2"><a class="wp-block-button__link has-small-font-size has-custom-font-size wp-element-button" href="https://www.amazon.com/dp/B0CQV29QSX/?tag=linuxundich-20" target="_blank" rel="sponsored nofollow noopener">On Amazon</a></div>
</div>
</div>
</div>



<div class="wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-957a3321 wp-block-columns-is-layout-flex" style="border-top-color:var(--wp--preset--color--line);border-top-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:70%">
<p class="has-small-font-size wp-block-paragraph"><strong>Official case</strong><br>Simple, a perfect fit and with room for the fan.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%">
<div class="wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-c5ec1813 wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-outline is-style-outline--3"><a class="wp-block-button__link has-small-font-size has-custom-font-size wp-element-button" href="https://www.amazon.com/dp/B0CLY2974P/?tag=linuxundich-20" target="_blank" rel="sponsored nofollow noopener">On Amazon</a></div>
</div>
</div>
</div>



<div class="wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-957a3321 wp-block-columns-is-layout-flex" style="border-top-color:var(--wp--preset--color--line);border-top-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:70%">
<p class="has-small-font-size wp-block-paragraph"><strong>Official Active Cooler</strong><br>Clip-on fan with heatsink that adjusts its speed to the temperature.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%">
<div class="wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-c5ec1813 wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-outline is-style-outline--4"><a class="wp-block-button__link has-small-font-size has-custom-font-size wp-element-button" href="https://www.amazon.com/dp/B0CLXZBR5P/?tag=linuxundich-20" target="_blank" rel="sponsored nofollow noopener">On Amazon</a></div>
</div>
</div>
</div>



<p class="wp-block-paragraph" style="margin-top:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--20);font-weight:700">For writing with the Imager</p>



<div class="wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-957a3321 wp-block-columns-is-layout-flex" style="border-top-color:var(--wp--preset--color--line);border-top-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:70%">
<p class="has-small-font-size wp-block-paragraph"><strong>SanDisk Extreme microSDXC, 128 GB</strong><br>Fast card (A2): writing and verifying in the Imager are noticeably quicker.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%">
<div class="wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-c5ec1813 wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-outline is-style-outline--5"><a class="wp-block-button__link has-small-font-size has-custom-font-size wp-element-button" href="https://www.amazon.com/dp/B09X7BK27V/?tag=linuxundich-20" target="_blank" rel="sponsored nofollow noopener">On Amazon</a></div>
</div>
</div>
</div>



<div class="wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-957a3321 wp-block-columns-is-layout-flex" style="border-top-color:var(--wp--preset--color--line);border-top-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:70%">
<p class="has-small-font-size wp-block-paragraph"><strong>UGREEN card reader (USB-A and USB-C)</strong><br>USB 3.0 with up to 5 Gbit/s. An old USB 2 reader slows down any card.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%">
<div class="wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-c5ec1813 wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-outline is-style-outline--6"><a class="wp-block-button__link has-small-font-size has-custom-font-size wp-element-button" href="https://www.amazon.com/dp/B07D1J88CF/?tag=linuxundich-20" target="_blank" rel="sponsored nofollow noopener">On Amazon</a></div>
</div>
</div>
</div>



<p class="wp-block-paragraph" style="margin-top:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--20);font-weight:700">Alternatives</p>



<div class="wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-957a3321 wp-block-columns-is-layout-flex" style="border-top-color:var(--wp--preset--color--line);border-top-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:70%">
<p class="has-small-font-size wp-block-paragraph"><strong>Samsung EVO Plus microSD, 128 GB</strong><br>Also proven, in case the SanDisk is out of stock.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%">
<div class="wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-c5ec1813 wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-outline is-style-outline--7"><a class="wp-block-button__link has-small-font-size has-custom-font-size wp-element-button" href="https://www.amazon.com/dp/B0CWPPDS3D/?tag=linuxundich-20" target="_blank" rel="sponsored nofollow noopener">On Amazon</a></div>
</div>
</div>
</div>



<div class="wp-block-columns are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-957a3321 wp-block-columns-is-layout-flex" style="border-top-color:var(--wp--preset--color--line);border-top-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:70%">
<p class="has-small-font-size wp-block-paragraph"><strong>Raspberry Pi 500 desktop kit (US layout)</strong><br>A Pi 5 with 8 GB built into the keyboard, with mouse, power supply and a microSD card with Raspberry Pi OS.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:30%">
<div class="wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-c5ec1813 wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-outline is-style-outline--8"><a class="wp-block-button__link has-small-font-size has-custom-font-size wp-element-button" href="https://www.amazon.com/dp/B0FJF2PDW1/?tag=linuxundich-20" target="_blank" rel="sponsored nofollow noopener">On Amazon</a></div>
</div>
</div>
</div>



<p class="has-muted-color has-text-color has-small-font-size wp-block-paragraph" style="margin-top:var(--wp--preset--spacing--40)"><strong>Ad:</strong> All links in this box are Amazon affiliate links. As an Amazon Associate I earn from qualifying purchases; the price stays the same for you. I deliberately don&#8217;t list prices because they change too often. You&#8217;ll see the current price directly on Amazon.</p>
</div>



<h2 class="wp-block-heading">How to write an image with Raspberry Pi Imager</h2>



<p class="wp-block-paragraph">Actually using the program is quickly explained thanks to the new wizard. You work your way from top to bottom through five steps and can go back a step at any time if you&#8217;ve misclicked. Writing only happens at the very end after an explicit confirmation prompt, so nothing happens to your SD card before that:</p>



<ol class="wp-block-list">

<li><strong>Choose device:</strong> First you tell the Imager which model the image is intended for, such as Raspberry Pi 5 or Raspberry Pi Zero 2 W. The list of operating systems is then filtered accordingly.</li>


<li><strong>Choose operating system:</strong> Here you pick Raspberry Pi OS (with or without desktop, 32-bit or 64-bit) or one of the many other distributions. Via <em>Use custom</em> you select a locally stored image.</li>


<li><strong>Choose storage device:</strong> Now it&#8217;s the turn of the SD card or USB stick. More on that in the next section.</li>


<li><strong>Customise:</strong> Hostname, location, user and password, Wi-Fi, SSH (by password or public key), Raspberry Pi Connect and interfaces such as I2C and SPI. Depending on the operating system, the Imager writes these settings to the boot partition as <code>firstrun.sh</code>, as a <a href="https://www.raspberrypi.com/news/cloud-init-on-raspberry-pi-os/">cloud-init configuration</a> or in another format.</li>


<li><strong>Write:</strong> After a confirmation prompt, the Imager downloads the image, writes it and verifies it. Images that have been downloaded once end up in the cache, so writing the same image again is considerably faster.</li>

</ol>



<p class="wp-block-paragraph">If you want to set up several Pis in one go, you&#8217;ll appreciate the option to write another card at the end of the wizard. It lets you write the same image including customisations once more without having to click through all the steps again. Just remember to change the hostname.</p>



<p class="wp-block-paragraph">My tip for headless operation: store your <a href="https://wiki.archlinux.org/title/SSH_keys">public SSH key</a> right away instead of a password. Then you can connect to the Pi via <code>ssh</code> immediately after the first boot without ever having to type a password. If you access it from several machines, simply enter several keys.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae0589874bf5&quot;}" data-wp-interactive="core/image" data-wp-key="6ae0589874bf5" class="wp-block-image size-large wp-lightbox-container"><img loading="lazy" decoding="async" height="917" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-ssh-schluessel-640x458.webp 640w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-ssh-schluessel-768x550.webp 768w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-ssh-schluessel-1280x917.webp 1280w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-ssh-schluessel.webp 1297w" width="1280" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-ssh-schluessel-1280x917.webp" alt="SSH step in Raspberry Pi Imager with SSH enabled, key authentication and two pixelated keys."/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">In the remote access step you enable SSH and add as many public keys as you like, making password login unnecessary.</figcaption></figure>



<p class="wp-block-paragraph">If you set up a Pi afresh with the same hostname, SSH will complain about a <a href="https://linuxundich.de/en/ssh-tips-changed-host-keys-killing-and-parking-connections/">changed host key</a> at the next login. In this case there is no attack behind it; the freshly installed system has simply generated new keys. A single command fixes the problem quickly.</p>



<h2 class="wp-block-heading">Careful: pick the right drive</h2>



<p class="wp-block-paragraph">Probably the most important point of all: the Imager overwrites the selected storage device completely and does not check whether it still contains data. Michael Kofler rightly criticises that the icons for SD cards and USB devices in the selection can be confusing and that the summary doesn&#8217;t show the concrete device name such as <code>/dev/sde</code>.</p>



<p class="wp-block-paragraph">Sure, the Imager hides system drives by default, but an external backup disk on the USB port is just another removable drive as far as it is concerned. On Linux, however, you have a simple way of playing it safe: use <a href="https://man.archlinux.org/man/lsblk.8"><code>lsblk</code></a> before and after plugging in the SD card to see which device has been added.</p>



<pre class="wp-block-code"><code>$ lsblk -o NAME,SIZE,MODEL,TRAN,MOUNTPOINTS
NAME          SIZE MODEL                TRAN   MOUNTPOINTS
sda           4.5T WDC WD50NDZW-11BCSS1 usb    
└─sda1        4.5T                             /mnt/backup
sdb         117.2G Speed Line           usb    
├─sdb1        198K                             
├─sdb2        2.8M                             
└─sdb3        4.6G                             
zram0         3.8G                             [SWAP]
nvme0n1       3.6T CT4000P3PSSD8        nvme   
├─nvme0n1p1   512M                      nvme   /boot
└─nvme0n1p2   3.6T                      nvme   /var/log
                                               /var/cache/pacman/pkg
                                               /home
                                               /.snapshots
                                               /</code></pre>



<p class="wp-block-paragraph">In my example the situation is clear: <code>sdb</code> is the &#8220;Speed Line&#8221; USB stick with a good 117 GB and the remains of an old ISO image. <code>sda</code>, by contrast, is the external backup disk mounted at <code>/mnt/backup</code>. According to the TRAN column, both are attached via USB.</p>



<p class="wp-block-paragraph">This is exactly where the danger lies, because to the Imager both drives are equally removable media. Size and model name tell you which device is the right one. To be on the safe side, it&#8217;s best to unplug all external hard disks before starting the Imager. A few seconds of caution certainly beat a flattened backup disk.</p>



<p class="wp-block-paragraph">Incidentally, since version 2.0.11 the Imager locks the drive exclusively on Linux while it is writing to it. No other program can then access the card at the same time and wreck your freshly written image. Of course, that doesn&#8217;t protect you from picking the wrong drive – only a careful look helps there.</p>



<h2 class="wp-block-heading">Raspberry Pi Imager in the terminal: CLI mode</h2>



<p class="wp-block-paragraph">What most guides don&#8217;t mention: the Imager can also be used entirely without a graphical interface. That&#8217;s handy for scripts, for working over SSH or when you want to prepare several cards. You activate CLI mode with <code>--cli</code>, followed by the image and the target device:</p>



<pre class="wp-block-code"><code>$ sudo rpi-imager --cli raspios.img.xz /dev/sdb</code></pre>



<p class="wp-block-paragraph">The image may be compressed (since 2.0.11 also as a multi-part <code>.img.zst</code>), and instead of a local file the Imager also accepts an HTTP or HTTPS address. <code>rpi-imager --cli --help</code> gives an overview of all options, and the Arch package also ships a man page. The most useful options in my view:</p>



<ul class="wp-block-list">

<li><code>--sha256 &lt;hash&gt;</code> checks before writing whether the image matches the expected checksum.</li>


<li><code>--disable-verify</code> skips verification after writing (saves time, costs safety).</li>


<li><code>--first-run-script &lt;file&gt;</code> puts your own <code>firstrun.sh</code> onto the image.</li>


<li><code>--cloudinit-userdata &lt;file&gt;</code> and <code>--cloudinit-networkconfig &lt;file&gt;</code> write your own cloud-init configurations to the card as well.</li>


<li><code>--disable-eject</code> prevents the drive from being ejected after writing – handy if you still want to copy files to the boot partition afterwards.</li>


<li><code>--quiet</code> only prints errors, ideal for scripts.</li>

</ul>



<p class="wp-block-paragraph">The <a href="https://cloudinit.readthedocs.io/en/latest/">cloud-init</a> options in particular are interesting: they give you more possibilities in the terminal than in the graphical interface, and that includes images which the Imager no longer customises in the wizard. For servers without a Qt interface, GitHub also offers a separate <code>rpi-imager-cli</code> package and a CLI AppImage, for which the <code>--cli</code> switch is not needed.</p>



<h2 class="wp-block-heading">Custom image lists with &#8211;repo</h2>



<p class="wp-block-paragraph">One more treat for tinkerers, clubs and schools: with <code>--repo</code> you teach the Imager your own list of images. Instead of querying Raspberry Pi&#8217;s servers, it then reads a JSON file that is located either online or locally on your disk. The format is described in the repository under <a href="https://github.com/raspberrypi/rpi-imager/tree/main/doc/json-schema"><code>doc/json-schema</code></a>.</p>



<pre class="wp-block-code"><code>$ rpi-imager --repo https://example.org/os_list.json</code></pre>



<p class="wp-block-paragraph">That way you can, for example, hand a club or a school class an Imager that only shows your own prepared images. Simply create a custom launcher in the application menu that calls the Imager with the appropriate parameter. The Imager takes care of the rest as usual.</p>



<h2 class="wp-block-heading">Disabling telemetry</h2>



<p class="wp-block-paragraph">By default, on every write the Imager anonymously reports to Raspberry Pi which image you selected, along with the Imager version, your host operating system, the architecture and the language setting. According to the README, only counters are stored, and the aggregated data is publicly available at <a href="https://rpi-imager-stats.raspberrypi.com">rpi-imager-stats.raspberrypi.com</a>.</p>



<p class="wp-block-paragraph">If you&#8217;d still rather not have that, switch off the statistics in the app options or launch the Imager once with the <code>--disable-telemetry</code> parameter, which saves the setting permanently. As mentioned above, telemetry isn&#8217;t compiled into the Flatpak in the first place. So there&#8217;s nothing you need to do there.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae0589875fd0&quot;}" data-wp-interactive="core/image" data-wp-key="6ae0589875fd0" class="wp-block-image size-large wp-lightbox-container"><img loading="lazy" decoding="async" height="917" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-einstellungen-telemetrie-640x458.webp 640w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-einstellungen-telemetrie-768x550.webp 768w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-einstellungen-telemetrie-1280x917.webp 1280w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-einstellungen-telemetrie.webp 1297w" width="1280" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-einstellungen-telemetrie-1280x917.webp" alt="Raspberry Pi Imager settings with switches for ejecting and telemetry and a button for the image repository."/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">In the settings you switch off telemetry and, if you like, enter your own image list under Image Repository.</figcaption></figure>



<h2 class="wp-block-heading">Common problems on Linux</h2>



<p class="wp-block-paragraph"><strong>The Imager reports that it isn&#8217;t running as root.</strong> With the AppImage, click Install Authorization or launch it with <code>sudo ./…</code>. With distribution packages, check whether the file <code>com.raspberrypi.rpi-imager.policy</code> exists under <code>/usr/share/polkit-1/actions/</code>. If it is missing, reinstall the package or launch the Imager with sudo as a test.</p>



<p class="wp-block-paragraph"><strong>The AppImage won&#8217;t start.</strong> First check whether the executable bit is set (<code>chmod +x</code>). On Ubuntu 24.04, <code>libxcb-cursor0</code> is also missing, without which the AppImage crashes right at startup. Launch the AppImage in a terminal as a test; then you&#8217;ll see the error message and know which piece of the puzzle is still missing.</p>



<p class="wp-block-paragraph"><strong>Ubuntu shows the old interface.</strong> Then you&#8217;ve caught the version from apt or the Snap Store, both of which are still stuck at 1.x. Uninstall it and use the <code>.deb</code> from GitHub, the AppImage or the Flatpak instead. After that, the new wizard will greet you on Ubuntu too.</p>



<p class="wp-block-paragraph"><strong>The SD card doesn&#8217;t show up.</strong> Use <code>lsblk</code> to check whether the card reader recognises the card at all. Some card readers only show a device after the card is reinserted, others simply don&#8217;t like certain cards. If the card doesn&#8217;t appear in <code>lsblk</code> either, the problem isn&#8217;t the Imager.</p>



<p class="wp-block-paragraph"><strong>Writing takes forever.</strong> Verification reads the complete image back from the card once more after writing. With slow cards or USB 2 card readers this can take a while. A faster card helps more here than switching off the check. If verification fails, you should <a href="https://linuxundich.de/en/checking-usb-sticks-and-sd-cards-for-errors/">check your card for errors</a>.</p>



<p class="wp-block-paragraph"><strong>Faulty USB sticks or microSD cards.</strong> If the Imager shows the notice &#8220;Limited by storage device speed&#8221; while writing, the storage device is slowing the process down considerably. At just a few MB/s, a worn-out stick or a faulty card is often behind it. In that case, check the device for errors before you find yourself puzzling over an aborted verification.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae0589876927&quot;}" data-wp-interactive="core/image" data-wp-key="6ae0589876927" class="wp-block-image size-large wp-lightbox-container"><img loading="lazy" decoding="async" height="917" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-schreibvorgang-langsam-640x458.webp 640w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-schreibvorgang-langsam-768x550.webp 768w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-schreibvorgang-langsam-1280x917.webp 1280w, https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-schreibvorgang-langsam.webp 1297w" width="1280" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2026/10/raspberry-pi-imager-2-schreibvorgang-langsam-1280x917.webp" alt="Raspberry Pi Imager writing an image, progress three percent, notice about speed limited to 1 MB/s."/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">At a mere 1 MB/s, this card is slowing the Imager down – a clear sign of a slow or faulty storage device.</figcaption></figure>



<h2 class="wp-block-heading">Alternatives to Raspberry Pi Imager</h2>



<p class="wp-block-paragraph">Of course it doesn&#8217;t always have to be the Imager. If you&#8217;ve already downloaded an image, you can get there on Linux with built-in tools too – for instance with <code>dd</code>, with the Restore Disk Image function in <a href="https://apps.gnome.org/DiskUtility/">GNOME Disks</a> or the GTK4 tool <a href="https://linuxundich.de/en/impression-gtk4-tool-for-flashing-iso-images/">Impression</a>. You&#8217;ll then be missing the convenient pre-configuration, though, and will have to set up hostname, SSH and Wi-Fi by hand.</p>



<p class="wp-block-paragraph">If, conversely, you want to back up an existing system and keep the image as small as possible, take a look at <a href="https://linuxundich.de/en/pishrink-shrinks-raspberry-pi-images/">PiShrink</a>. It shrinks an image you&#8217;ve read out down to the space actually used, and you can later write it back to a card with the Imager.</p>



<h3 class="wp-block-heading">Better than dd, but not mandatory either</h3>



<p class="wp-block-paragraph">All in all, the upgrade to Raspberry Pi Imager 2.0 was a clear step forward in my view. The wizard guides even beginners safely through the setup, and for Linux users a good deal of fiddling has been eliminated, particularly when it comes to root privileges. Arch users simply install the program from extra and are done.</p>



<p class="wp-block-paragraph">Ubuntu users, on the other hand, should definitely steer clear of the package sources and the Snap Store and go for the official package. And if you like working in the terminal, you should take a closer look at CLI mode with its cloud-init options. How do you prepare your SD cards? Do you use the Imager, or do you still swear by <code>dd</code>?</p>


<hr><p>☕ <strong>Support Linux und Ich</strong><br>Thanks for reading <a href="https://linuxundich.de/en/">Linux und Ich</a>. If you enjoy the blog and would like to support my work, you will find more information on the <a href="https://linuxundich.de/en/support/">donation page</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://linuxundich.de/en/raspberry-pi-imager-linux-root-cli-tips/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PiShrink Shrinks Raspberry Pi Images</title>
		<link>https://linuxundich.de/en/pishrink-shrinks-raspberry-pi-images/</link>
					<comments>https://linuxundich.de/en/pishrink-shrinks-raspberry-pi-images/#respond</comments>
		
		<dc:creator><![CDATA[Christoph Langner]]></dc:creator>
		<pubDate>Mon, 27 Feb 2017 19:31:28 +0000</pubDate>
				<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[How-to]]></category>
		<guid isPermaLink="false">https://linuxundich.de/en/pishrink-shrinks-raspberry-pi-images/</guid>

					<description><![CDATA[PiShrink shrinks the image of a Raspberry Pi SD card to the space actually used and automatically expands the system again on first boot.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In an earlier article, I described how to back up and restore a Raspberry Pi installation from its memory card – no shit, Sherlock. One question came up again and again, though: the image file ends up exactly as large as the memory card, even if there&#8217;s still plenty of free space on it. The &#8220;empty&#8221; area is more or less packed into the image as well. As a result, the new memory card has to be at least as large as the old one. In addition, an image intended for archiving takes up a lot of storage space. So how do you let the air out of a Raspberry Pi image?</p>



<span id="more-156"></span>



<p class="wp-block-paragraph">On GitHub, I recently stumbled across <a href="https://github.com/Drewsif/PiShrink/">the PiShrink script</a>, which does exactly that. The little program takes a Pi image, reduces the partition size to the necessary minimum and also adds a script to the archived system that automatically expands the partition to the maximum available space on the next boot on real hardware. This way, you can quickly shrink the image of a Raspbian system from several gigabytes to a few hundred megabytes – without much effort. You also save time when restoring, since the file system automatically expands to its full size again the first time the Raspberry Pi boots.</p>



<pre class="wp-block-code"><code>$ <strong>mkdir ~/bin</strong>
$ <strong>wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh -P ~/bin</strong>
$ <strong>chmod +x ~/bin/pishrink.sh</strong></code></pre>



<p class="wp-block-paragraph">Since PiShrink is a simple Bash script, installing it isn&#8217;t particularly complicated: you just download the script and set the execute permission. Personally, I put scripts like this in the <code>~/bin</code> directory in my home folder. The system should automatically add this folder to your user&#8217;s <code>$PATH</code>, so you can run the command from anywhere without specifying a path. If that&#8217;s not the case for you, there are plenty of guides online on <a href="https://askubuntu.com/questions/60218/how-to-add-a-directory-to-the-path">extending the environment variable</a> (the linked article refers to Ubuntu, but the procedure is very similar on other distributions).</p>



<h2 class="wp-block-heading">PiShrink compresses Raspberry Pi images</h2>



<p class="wp-block-paragraph">You should now be able to call the PiShrink script directly in the terminal with a bold <code>pishrink.sh</code>. Without an image, the script merely shows its syntax. In the end, calling it comes down to specifying an image file and, optionally, a second file name if PiShrink should leave the original Raspberry Pi image untouched. If you only specify one file name, PiShrink edits that image directly.</p>



<p class="wp-block-paragraph">The only switch, <code>-s</code>, matters if you want to shrink the image of a Pi system that isn&#8217;t based on Raspbian – for example the Kodi distributions LibreELEC or OpenELEC. More precisely, the switch tells PiShrink not to expand the system automatically on the next boot. To do this, PiShrink normally adds a command to the <code>/etc/rc.local</code> file, which Raspbian runs automatically at boot. However, this file doesn&#8217;t exist on LibreELEC (and some other distributions).</p>



<pre class="wp-block-code"><code>### Show PiShrink's help:
$ <strong>pishrink.sh</strong>
Usage: /home/toff/bin/pishrink.sh &#91;-s] imagefile.img &#91;newimagefile.img]
### Shrink an existing Pi image:
$ <strong>sudo pishrink.sh raspberry-pi.img</strong>
### Shrink the image and keep the original:
$ <strong>sudo pishrink.sh raspberry-pi.img raspberry-pi_pishrink.img</strong>
### Disable automatic expansion of the partition:
$ <strong>sudo pishrink.sh -s raspberry-pi.img raspberry-pi_small.img</strong></code></pre>



<p class="wp-block-paragraph">So how does it all come together? As an example, I&#8217;m using a current installation of Raspbian Lite on a 16 GB SD card. You insert it into the card reader, determine the device ID with <code>lsblk</code> and then back up the image to the hard disk with <code>dd</code>. The image file then sits on the hard disk as <code>raspberry-pi.img</code>, around 16 GB in size – even though the image is actually mostly empty. Apart from the Raspbian system and a few configuration files, there&#8217;s no other data on the system.</p>



<pre class="wp-block-code"><code>$ <strong>lsblk</strong>
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
&#91;...]
sdd      8:48   1  14.9G  0 disk
├─sdd1   8:49   1    63M  0 part /run/media/&#91;...]/boot
└─sdd2   8:50   1  14.8G  0 part /run/media/&#91;...]/0aed834e-8c8f-412d-a276-a26
$ <strong>sudo dd if=/dev/sdd of=~/raspberry-pi.img</strong>
15894831104 bytes (16 GB, 15 GiB) copied, 210 s, 75.7 MB/s
31116288+0 records in
31116288+0 records out
15931539456 bytes (16 GB, 15 GiB) copied, 210.459 s, 75.7 MB/s
$ <strong>ls -alh ~/raspberry-pi.img</strong>
-rw-r--r-- 1 root root 15G Feb 24 21:48 raspberry-pi.img</code></pre>



<p class="wp-block-paragraph">Then you call PiShrink accordingly – since this is a Raspbian system, I leave out the <code>-s</code> option. PiShrink first copies the image (so make sure there&#8217;s enough free space), mounts the copy in a temporary directory under <code>/tmp</code> and then reduces the size of the image: from just under 16 GB originally to only about 1.6 GB. The effect you achieve naturally depends on how much real data was stored on the Raspberry Pi&#8217;s SD card.</p>



<pre class="wp-block-code"><code>$ <strong>sudo pishrink.sh raspberry-pi.img raspberry-pi_pishrink.img</strong>
Copying raspberry-pi.img to raspberry-pi_pishrink.img...
Creating new /etc/rc.local
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/loop2: 35832/959616 files (0.2% non-contiguous), 321790/3872384 blocks
resize2fs 1.43.4 (31-Jan-2017)
resize2fs 1.43.4 (31-Jan-2017)
Resizing the filesystem on /dev/loop2 to 382429 (4k) blocks.
Begin pass 2 (max = 40814)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 119)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 3178)
Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/loop2 is now 382429 (4k) blocks long.

Shrunk raspberry-pi_pishrink.img from 15G to 1.6G
$ <strong>ls -alh raspberry-pi*</strong>
-rw-r--r-- 1 root root  15G Feb 27 11:08 raspberry-pi.img
-rw-r--r-- 1 root root 1.6G Feb 27 11:30 raspberry-pi_pishrink.img
</code></pre>



<h2 class="wp-block-heading">Restoring a shrunk Pi image</h2>



<p class="wp-block-paragraph">As a test, the Raspbian system originally installed on a 16 GB SD card is to move to a microSD card with only 8 GB. To do this, I write the image shrunk with PiShrink back to the new card with <code>dd</code>, insert it into the Raspberry Pi and boot the shrunk system. To make full use of the available storage space, the system automatically reboots once during the first boot. After that, you land in the familiar Raspbian system – a <code>df -h</code> shows that the system now uses the entire SD card.</p>



<pre class="wp-block-code"><code>$ <strong>lsblk</strong>
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
&#91;...]
sdd      8:48   1   7.4G  0 disk
├─sdd1   8:49   1    63M  0 part /run/media/&#91;...]/boot
└─sdd2   8:50   1   7.3G  0 part /run/media/&#91;...]/0aed834e-8c8f-412d-a276-a26
$ <strong>sudo dd if=raspberry-pi_pishrink.img of=/dev/sdd bs=1M; sync</strong>
1560+1 records in
1560+1 records out
1636684288 bytes (1.6 GB, 1.5 GiB) copied, 116.203 s, 14.1 MB/s</code></pre>



<pre class="wp-block-code"><code>pi@raspberrypi:~ $ <strong>df -h</strong>
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.2G  990M  6.0G  14% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M  6.2M  457M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1   63M   21M   42M  33% /boot</code></pre>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae05898c84ed&quot;}" data-wp-interactive="core/image" data-wp-key="6ae05898c84ed" class="wp-block-image size-full wp-lightbox-container"><img loading="lazy" decoding="async" height="845" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2017/02/pishrink-beispiel-640x465.png 640w, https://linuxundich.de/wp-content/uploads/2017/02/pishrink-beispiel-768x558.png 768w, https://linuxundich.de/wp-content/uploads/2017/02/pishrink-beispiel.png 1164w" width="1164" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2017/02/pishrink-beispiel.png" alt="PiShrink running in the terminal; the file manager next to it shows the original at 15.9 GB and the shrunk copy at 811 MB." style="width:100%"/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">PiShrink reduces the image of a Raspberry Pi system to its minimum size.</figcaption></figure>



<p class="wp-block-paragraph">If you back up a Raspberry Pi system that isn&#8217;t based on Raspbian and has no <code>/etc/rc.local</code> – such as the Kodi distributions LibreELEC or OpenELEC mentioned above – error messages appear when shrinking it with PiShrink. The reason: by default, PiShrink tries to add a command to this file that later expands the partition automatically. To avoid this, you have to use the <code>-s</code> option. That way, you can shrink the image successfully even without an <code>rc.local</code>.</p>



<pre class="wp-block-code"><code>### Error messages when shrinking a LibreELEC image:
$ <strong>sudo pishrink.sh libreelec.img</strong>
&#91;...]
md5sum: /tmp/tmp.4ornQ3Va4y/etc/rc.local: No such file or directory
/home/&#91;...]/bin/pishrink.sh: line 63: &#91;: !=: unary operator expected
&#91;...]
### LibreELEC, OpenELEC and co. are better shrunk like this:
$ <strong>sudo pishrink.sh -s libreelec.img</strong>
Skipping autoexpanding process...
e2fsck 1.43.4 (31-Jan-2017)
/dev/loop2: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/loop2: 861/1810432 files (1.0% non-contiguous), 252448/7235584 blocks
resize2fs 1.43.4 (31-Jan-2017)
resize2fs 1.43.4 (31-Jan-2017)
Resizing the filesystem on /dev/loop2 to 49976 (1k) blocks.
Begin pass 2 (max = 15759)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 884)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 143)
Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/loop2 is now 49976 (1k) blocks long.

Shrunk libreelec.img from 7.5G to 563M</code></pre>



<p class="wp-block-paragraph">However, the restored system then doesn&#8217;t expand automatically, because LibreELEC (and, as far as I know, OpenELEC too) offers no option in its menus to manually expand the data partition to the full card size. The internal resizing routine only kicks in on a freshly copied first installation, as you can see in the <a href="https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/sysutils/busybox/scripts/fs-resize">script</a>. To make full use of the partition anyway, the only option is to fix it up manually with a partitioning tool such as GParted. On Linux, GParted is readily available; Windows users can use the tool via a <a href="https://gparted.org/liveusb.php">live CD or live USB stick</a>.</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae05898c8b4c&quot;}" data-wp-interactive="core/image" data-wp-key="6ae05898c8b4c" class="wp-block-image size-full wp-lightbox-container"><img loading="lazy" decoding="async" height="725" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2017/02/gparted-partition-vergroessern-640x511.png 640w, https://linuxundich.de/wp-content/uploads/2017/02/gparted-partition-vergroessern-768x613.png 768w, https://linuxundich.de/wp-content/uploads/2017/02/gparted-partition-vergroessern.png 908w" width="908" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2017/02/gparted-partition-vergroessern.png" alt="GParted shows a LibreELEC card with 6.85 GB of unallocated space and the dialog for resizing the partition." style="width:100%"/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">With tools such as GParted, you can quickly adjust the partition size again.</figcaption></figure>

<hr><p>☕ <strong>Support Linux und Ich</strong><br>Thanks for reading <a href="https://linuxundich.de/en/">Linux und Ich</a>. If you enjoy the blog and would like to support my work, you will find more information on the <a href="https://linuxundich.de/en/support/">donation page</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://linuxundich.de/en/pishrink-shrinks-raspberry-pi-images/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SSH Tips: Changed Host Keys, Killing and Parking Connections</title>
		<link>https://linuxundich.de/en/ssh-tips-changed-host-keys-killing-and-parking-connections/</link>
					<comments>https://linuxundich.de/en/ssh-tips-changed-host-keys-killing-and-parking-connections/#respond</comments>
		
		<dc:creator><![CDATA[Christoph Langner]]></dc:creator>
		<pubDate>Sat, 07 May 2016 06:32:42 +0000</pubDate>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">https://linuxundich.de/en/ssh-tips-changed-host-keys-killing-and-parking-connections/</guid>

					<description><![CDATA[SSH tips: remove changed host keys with ssh-keygen -R, kill hung connections and park sessions.]]></description>
										<content:encoded><![CDATA[
<p class="dropcapp wp-block-paragraph">If you like tinkering with the Raspberry Pi or other single-board computers such as the Banana Pi, Odroid and the like, you keep running into SSH. The images made for these mini computers are usually based on Linux and therefore mostly come with SSH access built in. In everyday tinkering, however, you set these machines up from scratch again and again, or you quickly pull the power plug to &#8220;just&#8221; restart the device. That throws SSH off balance: after installing a new system, the stored SSH key no longer matches, or the SSH client hangs when you suddenly pull the plug. You can solve these problems the quick and dirty way, but there is always a clean way, too.</p>

<span id="more-153"></span>

<p class="wp-block-paragraph">When establishing a connection via SSH, the SSH client usually stores the public SSH key of the remote system together with its hostname and IP address in the file <code>~/.ssh/known_hosts</code> in the current user&#8217;s home directory on the client machine. Among other things, this is done to prevent <a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack">man-in-the-middle attacks</a>, in which an attacker pretends to be the target machine in order to phish your login credentials. However, this security measure also kicks in when there is no threat at all: for example, when you set up a Pi from scratch and try to log in via SSH again. In such a case, SSH reports <code>WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED</code> in big letters.</p>

<h2 class="wp-block-heading">SSH after reinstalling the system</h2>

<pre class="wp-block-preformatted">$ <strong>grep 192.168.111.100 ~/.ssh/known_hosts</strong>
raspberrypi,192.168.111.100 ecdsa-sha2-nistp256 AAAAE2...ABBBBqf</pre>

<pre class="wp-block-preformatted">$ <strong>ssh pi@192.168.111.100</strong>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:6rR+0/i3KnPLds3EuGkfWiudIgu8VMpe1xq+X3I3yNM.
Please contact your system administrator.
Add correct host key in /home/toff/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/toff/.ssh/known_hosts:10
ECDSA host key for 192.168.111.100 has changed and you have requested strict checking.
Host key verification failed.</pre>

<p class="wp-block-paragraph">You could now open the file <code>~/.ssh/known_hosts</code> in a text editor and delete the offending line 10 from the list by hand, but there is a better way: with <code>ssh-keygen -R IP-address</code>, you remove the key from the file with a single command, so the next time you connect, you start from scratch – and have to confirm the key just like the very first time you connected to this machine. This also works if you use the hostname instead of the IP address to connect. To be on the safe side, the command copies the old state to <code>~/.ssh/known_hosts.old</code> in the same directory.</p>

<pre class="wp-block-preformatted">$ <strong>ssh-keygen -R 192.168.111.100</strong>
# Host 192.168.111.100 found: line 10
/home/toff/.ssh/known_hosts updated.
Original contents retained as /home/toff/.ssh/known_hosts.old</pre>

<pre class="wp-block-preformatted">$ <strong>ssh pi@192.168.111.100</strong>
The authenticity of host 'raspberrypi (192.168.111.100)' can't be established.
ECDSA key fingerprint is SHA256:6rR+0/i3KnPLds3EuGkfWiudIgu8VMpe1xq+X3I3yNM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.111.100' (ECDSA) to the list of known hosts.
pi@192.168.111.100's password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Apr 22 08:40:10 2016 from 192.168.178.57</pre>

<h2 class="wp-block-heading">Forcibly terminating an SSH connection</h2>

<p class="dropcapp wp-block-paragraph">If you are logged in to a remote machine via SSH and shut it down with <code>shutdown</code>, <code>halt</code> or <code>reboot</code>, the system doesn&#8217;t kill the SSH connection abruptly. It stops the SSH server cleanly during shutdown, so you end up back in the terminal of the client machine and can keep working in the same terminal window. Now, I – and surely other Pi tinkerers too – like to unplug the Raspberry Pi and plug it back in to restart it quickly and painlessly. This is certainly not ideal for the integrity of the data on the memory card, but if I&#8217;m going to set up the system on it from scratch anyway, I don&#8217;t much care.</p>

<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae05898cd261&quot;}" data-wp-interactive="core/image" data-wp-key="6ae05898cd261" class="wp-block-image wp-lightbox-container"><img loading="lazy" decoding="async" height="577" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2016/05/raspberry-pi-ssh-steuercodes-640x475.png 640w, https://linuxundich.de/wp-content/uploads/2016/05/raspberry-pi-ssh-steuercodes-768x570.png 768w, https://linuxundich.de/wp-content/uploads/2016/05/raspberry-pi-ssh-steuercodes.png 777w" width="777" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2016/05/raspberry-pi-ssh-steuercodes.png" alt="SSH connections can be managed with a set of escape sequences." style="width:100%"/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">SSH connections can be managed with a set of escape sequences.</figcaption></figure>

<p class="wp-block-paragraph">The downside is that SSH usually hangs in the terminal when you do this – after all, you just pulled the chair out from under it. You could now kill the SSH process or close the terminal window and open it again, but there is a clean solution for this situation, too: SSH knows a number of escape sequences that let you manage the current SSH session. You get an overview of the available commands if you type <code>~?</code> on a new line in the terminal. To be on the safe side, simply press Enter once beforehand.</p>

<pre class="wp-block-preformatted">pi@raspberrypi:~ # <strong>~?</strong>
Supported escape sequences:
 ~.   - terminate connection (and any multiplexed sessions)
 ~B   - send a BREAK to the remote system
 ~C   - open a command line
 ~R   - request rekey
 ~V/v - decrease/increase verbosity (LogLevel)
 ~^Z  - suspend ssh
 ~#   - list forwarded connections
 ~&amp;   - background ssh (when waiting for connections to terminate)
 ~?   - this message
 ~~   - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)</pre>

<p class="wp-block-paragraph">The first sequence shown in the help is exactly the function we&#8217;re looking for: if you type <code>~.</code> as text during an SSH session, you terminate the current SSH connection, no matter what. This doesn&#8217;t only work with a session that is still active and working (which you could close with <code>exit</code> at any time anyway), but also when, for example, you cut the power to the Pi and nothing happens in the terminal anymore. Here, too, it can help to press Enter once more before the actual command. Otherwise the escape sequence may come to nothing.</p>

<h2 class="wp-block-heading">Pausing and resuming an SSH connection</h2>

<p class="dropcapp wp-block-paragraph">The escape sequences can do other handy things, too. For example, you can suspend an SSH connection and resume it later without having to use a terminal multiplexer such as <code>screen</code> or <code>tmux</code>. If a process takes longer than expected, you can park the connection this way while the process on the remote machine keeps running. Unlike with the two terminal multiplexers mentioned, you don&#8217;t have to think ahead that the task might take longer and start them as a precaution. The corresponding sequence is the somewhat cryptic <code>~^Z</code>, where the caret doesn&#8217;t stand for a character but for the Ctrl key. So you type <kbd>~</kbd> and then press <kbd>Ctrl</kbd>+<kbd>Z</kbd>. You then land back in the terminal of the machine on which you originally ran <code>ssh</code>. From there, you can pick up the connection again by typing <code>fg</code> and pressing Enter.</p>

<figure data-wp-context="{&quot;imageId&quot;:&quot;6ae05898cd8be&quot;}" data-wp-interactive="core/image" data-wp-key="6ae05898cd8be" class="wp-block-image wp-lightbox-container"><img loading="lazy" decoding="async" height="664" sizes="auto, (max-width: 781px) 100vw, 680px" srcset="https://linuxundich.de/wp-content/uploads/2016/05/ssh-raspberry-pi-suspend-640x550.png 640w, https://linuxundich.de/wp-content/uploads/2016/05/ssh-raspberry-pi-suspend-768x661.png 768w, https://linuxundich.de/wp-content/uploads/2016/05/ssh-raspberry-pi-suspend.png 772w" width="772" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://linuxundich.de/wp-content/uploads/2016/05/ssh-raspberry-pi-suspend.png" alt="Pausing and resuming an SSH connection." style="width:100%"/><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">Pausing and resuming an SSH connection.</figcaption></figure>

<p class="wp-block-paragraph">If you work on a &#8220;truly&#8221; remote system over the internet, the connection may well drop. On the one hand, this is because the server terminates the connection after a period of inactivity; on the other hand, your own network infrastructure (read: the router) may interfere. However, you can prevent the timeout with a keep-alive function. Depending on the situation, you can either configure the SSH server accordingly (which of course requires root privileges) or call SSH with the appropriate parameters right away. In that case, you don&#8217;t need any special privileges on either system.</p>

<h3 class="wp-block-heading">Keep-alive on the server side</h3>

<pre class="wp-block-preformatted">### Default keep-alive settings:
$ <strong>grep Alive /etc/ssh/sshd_config</strong>
#TCPKeepAlive yes
#ClientAliveInterval 0
#ClientAliveCountMax 3
### Edit the SSH server configuration:
$ <strong>sudo nano /etc/ssh/sshd_config</strong>

### In the end, the relevant lines should look like this:
$ <strong>grep Alive /etc/ssh/sshd_config</strong>
TCPKeepAlive yes
ClientAliveInterval 60
ClientAliveCountMax 3

### Restart the SSH server once:
$ <strong>sudo systemctl restart sshd</strong></pre>

<h3 class="wp-block-heading">Keep-alive on the client side</h3>

<pre class="wp-block-preformatted">### Keep the SSH connection alive from the client side
$ <strong>ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=1 pi@raspberrypi</strong></pre>

<p class="wp-block-paragraph">In the first case, the setting applies to all users who want to log in to the system via SSH. As a rule, you should therefore only make this change if all users actually need it. Most of the time, though, you only need keep-alive in exceptional cases, so it makes sense to set the option only when needed when calling <code>ssh</code>. For me, this is the case with a web service I can log in to via SSH, for example. If I start long-running backups there, my router terminates the connection before the backup process can report success. With the keep-alive settings mentioned above, however, that&#8217;s no longer a problem.</p>

<hr><p>☕ <strong>Support Linux und Ich</strong><br>Thanks for reading <a href="https://linuxundich.de/en/">Linux und Ich</a>. If you enjoy the blog and would like to support my work, you will find more information on the <a href="https://linuxundich.de/en/support/">donation page</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://linuxundich.de/en/ssh-tips-changed-host-keys-killing-and-parking-connections/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
