QEMU cheatsheet

The basics https://powersj.io/posts/ubuntu-qemu-cli/ Mount disk images It is ofter very convenient to mount a FS locally to be able to debug and/or fix a problem with a broken disk. Pre-requisite to everything: mkdir /tmp/rootfs To know the format of your disk: qemu-img info disk.img (note that qemu-img can output JSON to automate your stuff) Raw disk images losetup -f -P disk.img losetup -l | grep -v snap # to find the loop device you just created and yeah those snaps.... mount /dev/loopXpX /tmp/rootfs For anything else (QCOW2, VHD/VPC, etc…) modprobe nbd qemu-nbd --connect=/dev/nbd0 disk.img fdisk /dev/nbd0 -l # to find your partition mount /dev/nbd0pX /tmp/rootfs

November 19, 2021 · 105 words · Gauthier Jolly

Firewall, Tailscale and Ubuntu

I recently enabled the Firewall on my desktop on Ubuntu. I probably did a quick lookup online to find out that sudo ufw enable was enough to enable it. I entered the command and forgot about it. $ sudo ufw enable Firewall is active and enabled on system startup Obviously, (and to be honest I was waiting for it), it didn’t take long for things to go bad. A few weeks later, while I was not at home and wanted to SSH on my machine via tailscale, I realized that I couldn’t and quickly remember about the Firewall. ...

November 14, 2021 · 312 words · Gauthier Jolly

The UNIX `who` command

While working on a completely different project, I started to ask myself how the who command was working under the hood. In the end, I thought it was a good topic for a blog post. Who is who Let’s start with the basics. the who command allows you to list the users currently logged on the system. For example, on my machine: $ who gauthier tty2 2020-08-30 15:06 (tty2) gauthier pts/1 2020-08-30 15:06 (tmux(1555).%0) gauthier pts/2 2020-08-30 16:41 (tmux(1555).%6) gauthier pts/4 2020-08-30 15:57 (tmux(1555).%3) It tells me that I am logged on the “physical” terminal tty2 and on three pseudo terminals. Indeed my current session of Gnome Shell is running on tty2 and I have 3 tmux windows open. ...

August 31, 2020 · 1022 words · Gauthier Jolly