Enrico's blog

Last 10 blog posts

2017-05-29 20:36:40+02:00

Egg-walking with qemu-nbd and kpartx

I wanted to retrieve a file from a VirtualBox VDI image for this blog post.

I followed these instructions and ended up here:

Once having used nbd0, only rebooting the system makes it possible to mount another image ... a little bit unpractical.

What happened was this:

# modprobe nbd
# qemu-nbd -c /dev/nbd0 file.vdi
# kpartx -d /dev/nbd0
# mount /dev/nbd0… EHI! Where's /dev/nbdpp1 ??
# qemu-nbd -d /dev/nbd0
# rmmod nbd
rmmod: ERROR: Module nbd is in use
# kpartx -d /dev/nbd0
read error, sector 0
llseek error
llseek error
llseek error
# rmmod nbd
rmmod: ERROR: Module nbd is in use
# WHAT THE…

It turns out it's really modprobe nbd max_part=16, otherwise max_part defaults to, uhm, zero? really? and kpartx cannot create device mappings because there are not enough (as in, not even a single one) partition devices available.

At this point, however, kpartx did create some mappings connected to, uhm, probably Ancient Beings from beyond spacetime, and because of those the device is in use and cannot be removed, and unmapping doesn't work either because the Ancient Beings from beyond spacetime are keeping the device busy by feeding on it.

I energized the pentacle and tried a desperate ritual of banishment:

# # Reconnect nbd0 to the vdi file to Restore the Balance
# qemu-nbd --verbose -c /dev/nbd0 file.vdi
# # This works now
# kpartx -vd /dev/nbd0
del devmap : nbd0p5
del devmap : nbd0p2
del devmap : nbd0p1
# # This too, the Ancient Beings lie asleep yet again
# modprobe nbd -r

At this point I managed to get my file, almost:

# modprobe nbd max_part=16
# qemu-nbd --verbose -c /dev/nbd0 file.vdi
NBD device /dev/nbd0 is now connected to file.vdi
# kpartx -va /dev/nbd0
add map nbd0p1 (254:12): 0 60260352 linear 43:0 2048
add map nbd0p2 (254:13): 0 2 linear 43:0 60264446
add map nbd0p5 (254:14): 0 2648064 linear 43:0 60264448
# mount /dev/nbd0p1 /mnt
mount: /dev/nbd0p1 is already mounted or /mnt busy
# # WHAT NOW?!
# lsblk
NAME                                       MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
…
nbd0                                        43:0    0    30G  0 disk
├─nbd0p1                                    43:1    0  28.8G  0 part
├─nbd0p2                                    43:2    0     1K  0 part
├─nbd0p5                                    43:5    0   1.3G  0 part
├─nbd0p1                                   254:12   0  28.8G  0 part
├─nbd0p2                                   254:13   0     1K  0 part
└─nbd0p5                                   254:14   0   1.3G  0 part
# # WHAAAT?!!
# kpartx -vd /dev/nbd0
del devmap : nbd0p5
del devmap : nbd0p2
del devmap : nbd0p1
# lsblk
NAME                                       MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
…
nbd0                                        43:0    0    30G  0 disk
├─nbd0p1                                    43:1    0  28.8G  0 part
├─nbd0p2                                    43:2    0     1K  0 part
└─nbd0p5                                    43:5    0   1.3G  0 part
# mount /dev/nbd0p1 /mnt
# # I got my file, my preciouss file!
# umount /mnt
# kpartx -vd /dev/nbd0
# qemu-nbd -d /dev/nbd0
# rmmod nbd
# # sit in a corner hugging my precious file and sobbing quietly

As can be seen from the multiple exclamation marks, those Ancient Beings from beyond spacetime did manage to have a bite on my sanity after all.

debian eng pdo sw
2017-05-29 20:12:46+02:00

Jessie live on UEFI systems

According to the Debian Wiki, you can't boot a Debian Live based on Jessie on a UEFI system:

UEFI support in live images At this point, UEFI support exists only in Debian's installation images. The accompanying live images do not have support for UEFI boot, as the live-build software used to generate them still does not include it. Hopefully the debian-live developers will add this important feature soon.

Some people really needed it, though, so I kept looking.

Here's a script that takes a Jessie Debian Live .iso file and the device name for a USB pendrive, and gives you a pendrive that boots on UEFI:

#!/bin/sh
# License: do what you want but it's not my fault, I told you not to.

sh -ue

ISO=${1:?"Usage: $0 file.iso usbdev"}
DEV=${2:?"Usage: $0 file.iso usbdev"}

parted -s $DEV mklabel gpt mkpart primary fat32 1 100%
mkfs.vfat ${DEV}1
mount ${DEV}1 /mnt

bsdtar -C /mnt -xf $ISO

mkdir -p /mnt/efi/boot
# Shell.efi comes from https://svn.code.sf.net/p/edk2/code/trunk/edk2/ShellBinPkg/UefiShell/X64/
cp Shell.efi /mnt/efi/boot/Bootx64.efi
echo 'live\vmlinuz initrd=live\initrd.img append boot=live components' > /mnt/startup.nsh

umount /mnt

Only use it if you really need it, though: Stretch will support this out of the box, and it's coming soon.

debian eng pdo sw
2017-05-28 00:00:00+02:00

Conscio dell'immagine di me

L'uomo in casa deve…, sennò lei se ne approfitta.
Il bambino deve imparare che…, sennò se ne approfitta.
La gente se ne approfitta.
Si approfittano di te, non devono approfittarsi di te.
Te ne approfitti, eh?

Non dare subito la risposta semplice,
pensaci su, cerca di meglio,
guarda se c'era una domanda trabocchetto,
non voler vincere facile,
non essere pigro,
fai uno sforzo,
fai vedere che ci metti dell'impegno,
non dargli soddisfazione,
fatti valere.
Tu hai visto un bel mondo.

Devi…
non puoi tirarti indietro ora,
è importante,
devi esserci, non puoi dire di no,
non puoi deludere tutti.

Non puoi essere come…
i grassi, gli ingenui, i semplici, i creduloni, i brutti, quelli vestiti male, gli sfigati, quelli che…, quelli che non…
Non puoi uscire con…
i grassi, gli ingenui, i semplici, i creduloni, i brutti, quelli vestiti male, gli sfigati, quelli che…, quelli che non…
Ama chi vuoi, ma non…
i grassi, gli ingenui, i semplici, i creduloni, i brutti, quelli vestiti male, gli sfigati, quelli che…, quelli che non…
O non usciremo con te,
o non ti ameremo.

Ho imparato a fare attenzione alle narrative,
a controllare come viene percepito quello che dico,
prima di parlare, prima di chiedere,
prima di esistere in pubblico.

A non desiderare, in compagnia di altri,
quello che non bisogna fare,
fino ad essere, in compagnia di altri,
soltanto un altro.
ita life
2017-05-27 00:00:00+02:00

Gli altri

Gli Altri erano un mondo a parte,
una massa insensata, con logiche sue, logiche oscure.
Un mondo che a volte si interessava a me, travolgendomi,
poi perdeva interesse e se ne andava.

Lo dovevo tenere buono, per evitare di esserne travolto.
Avevo paura di finire al centro dei suoi interessi.
di diventare un suo hobby.

  "Non merito la tua attenzione,
  non ti chiedo niente,
  non mi metto in mostra,
  non ho bisogni,
  sto bene cosí,
  non causo problemi,
  ti do quello che chiedi,
  non ti disturbo,
  non guardarmi,
  non sono nessuno,
  non è me che stai cercando."

Ho provato a chiedere: "lasciami stare"…

  "E perché?
  Come sei…
  Volevo solo chiederti…
  Volevo solo dirti…
  Volevo solo farti vedere…
  Volevo solo che tu…
  Dai, non fare cosí,
  stai al gioco!
  Non stare in un angolo!
  Dí qualcosa anche tu!
  Fammi divertire!"

E allora gli davo quello che chiedeva
finché non mi lasciava stare,
ma non è me che stava cercando.
ita life
2017-05-16 23:12:41+02:00

Accident on the motorway

There was an accident on the motorway, luckily noone got seriously wounded, but a truckful of sugar and a truckful of cereals completely spilled on the motorway, and took some time to clean.

19:15:23 19:45:07 20:02:37 20:11:52 20:28:43 20:32:34 20:44:03 21:27:41 21:44:20 22:10:50

eng life pdo
2017-05-02 15:45:38+02:00

Vector Discordian Pope Cards

I like Discordian Pope cards.

I wanted to print a batch, but online I could only find low-quality .jpg versions, so I took inkscape, used the low-quality as a template grayed out in a background immutable layer, and redid them properly.

Here are the results:

Preview:

Discordian Pope Card, Front Discordian Pope Card, Back

I release them under the WTFPL license: you can print them, redistribute them, and modify them at will.

The fonts I used are:

Update: now available as a git repo

eng life pdo
2017-04-25 00:00:00+02:00

Modena City Ramblers - Bella Ciao

Today is Liberation Day, and Bella Ciao will be sung a lot, remembering the Partisan movement.

Modena City Ramblers made a popular version.

The song originated before the second world war, as a song sung by mondine, women seasonally hired, or rather exploited, to work in flooded rice fields.

Here's a performance of the original version sung by Milva.

It is said that they were forbidden to talk during their work, so they sang instead, developing a peculiar singing style that could carry across the fields.

Here's Coro delle Mondine di Bentivoglio performing Son la Mondina, son la sfruttata in the original style.

eng songs
2017-04-24 00:00:00+02:00

Giorgio Gaber - Io non mi sento italiano

Giorgio Gaber's Io non mi sento italiano, singing about Italian national identity.

eng songs
2017-04-23 00:00:00+02:00

Fratelli di Soledad - Brescia Bologna Ustica

From organized crime in Italy to controlling politial consensus via mass murders with Fratelli di Soledad' Brescia Bologna Ustica, dedicated in particular to the mass murders of Piazza della Loggia bombing in Brescia, Bologna massacre, and Ustica massacre, were investigations have been and still are particularly hard, with state agencies actively obstructing them.

eng songs
2017-04-22 20:48:43+02:00

Splitting a git-annex repository

I have a git annex repo for all my media that has grown to 57866 files and git operations are getting slow, especially on external spinning hard drives, so I decided to split it into separate repositories.

This is how I did it, with some help from #git-annex. Suppose the old big repo is at ~/oldrepo:

# Create a new repo for photos only
mkdir ~/photos
cd photos
git init
git annex init laptop

# Hardlink all the annexed data from the old repo
cp -rl ~/oldrepo/.git/annex/objects .git/annex/

# Regenerate the git annex metadata
git annex fsck --fast

# Also split the repo on the usb key
cd /media/usbkey
git clone ~/photos
cd photos
git annex init usbkey
cp -rl ../oldrepo/.git/annex/objects .git/annex/
git annex fsck --fast

# Connect the annexes as remotes of each other
git remote add laptop ~/photos
cd ~/photos
git remote add usbkey /media/usbkey

At this point, I went through all repos doing standard cleanup:

# Remove unneeded hard links
git annex unused
git annex dropunused --force 1-12345

# Sync
git annex sync

To make sure nothing is missing, I used git annex find --not --in=here to see if, for example, the usbkey that should have everything could be missing some thing.

Update: Antoine Beaupré pointed me to this tip about Repositories with large number of files which I will try next time one of my repositories grows enough to hit a performance issue.

debian eng gitannex pdo sw