Création : Hôte : Debian Buster / 10.5, invités :
Image arm32 pour RaspBerry 4 : Rasperry PI OS Buster 10.4
Le paquet qemu-user-static et ses dépendances permet d'exécuter de façon transparente un programme binaire d'architecture étrangère sur une architecture hôte
Cette propriété peut-être utilisée pour émuler une image arm sur un hôte amd64 : l'image est montée dans le système hôte, les programmes lancés dans l'image en mode chroot sont alors automatiquement émulés et permettent par exemple de mettre à jour, ajouter ou supprimer des applications
Cette émulation se limite à l'espace utilisateur du système arm et ne permet donc pas d'émuler l'amorçage ou le matériel de la plateforme
Dans ce qui suit, la méthode est appliquée à deux images pour RaspBerry 4 :
l'image arm32 officielle (voir Annexe)
Références
https://wiki.debian.org/QemuUserEmulation
Sommaire
$ sudo aptitude install -t buster/backports qemu qemu-user-static binfmt-support$ aptitude versions ~iqemu-user-staticPaquet qemu-user-static : i 1:5.0-14~bpo10+1 buster-backports 100
On prend pour exemple l'image Raspberry Pi 4 fournie par Debian unofficial
$ wget https://raspi.debian.net/verified/20200909_raspi_4.img.xz$ unxz 20200909_raspi_4.img.xz
$ sudo parted 20200909_raspi_4.img printModel: (file)Disk xxxxx/20200909_raspi_4.img: 1573MBSector size (logical/physical): 512B/512BPartition Table: msdosDisk Flags: Number Start End Size Type File system Flags 1 1049kB 315MB 314MB primary fat16 lba 2 315MB 1573MB 1258MB primary ext4
La partition 1 est la partition d'amorçage (boot et firmwares)
La partition 2 est la partition racine.
$ truncate -s 6000MiB 20200909_raspi_4.img
soit en ajoutant par exemple 3GiB à la fin de l'image initiale
$ dd if=/dev/zero bs=1MiB count=3000 of=20200909_raspi_4.img conv=notrunc oflag=append
$ dd if=/dev/zero bs=1MiB count=8000 of=raspi4.img
et en y copiant l'image initiale
$ dd if=20200909_raspi_4.img of=raspi4.img conv=notrunc
La suite s'effectuera avec l'image raspi4.img.
$ sudo parted raspi4.img print free...Number Start End Size Type File system Flags 16,4kB 1049kB 1032kB Free Space 1 1049kB 315MB 314MB primary fat16 lba 2 315MB 1573MB 1258MB primary ext4 1573MB 8389MB 6816MB Free Space
$ sudo parted raspi4.img resizepart 2 100%
$ sudo losetup --show -P -f raspi4.img /dev/loop14$ lsblk -f /dev/loop14NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINTloop14 ├─loop14p1 vfat RASPIFIRM C80B-157C └─loop14p2 ext4 RASPIROOT 56e94ab7-95ad-49eb-8d23-ee52ff867e32
$ sudo e2fsck -f /dev/loop14p2$ sudo resize2fs /dev/loop14p2
$ sudo /dev/loop14p2 /mnt$ df -h /mntSys. de fichiers Taille Utilisé Dispo Uti% Monté sur/dev/loop14p2 7,4G 572M 6,5G 8% /mnt
$ cat /mnt/etc/fstab# The root file system has fs_passno=1 as per fstab(5) for automatic fsck.LABEL=RASPIROOT / ext4 rw 0 1# All other file systems have fs_passno=2 as per fstab(5) for automatic fsck.LABEL=RASPIFIRM /boot/firmware vfat rw 0 2proc /proc proc defaults 0 0
La partition 1 est prévue pour être montée en /boot/firmware
$ sudo mount /dev/loop14p1 /mnt/boot/firmware
$ sudo mount --bind /proc /mnt/proc$ sudo mount --bind /sys /mnt/sys$ sudo mount --bind /dev /mnt/dev $ sudo mount --bind /dev/pts /mnt/dev/pts
$ LC_ALL=C sudo chroot /mnt /bin/bash
Architecture
# uname -maarch64
Distribution
# cat /etc/issueDebian GNU/Linux 10 \n \l
Version
# cat /etc/debian_version 10.5
Sources des paquets
# cat /etc/apt/sources.listdeb http://deb.debian.org/debian buster main contrib non-freedeb http://deb.debian.org/debian-security buster/updates main contrib non-free# Backports are _not_ enabled by default.# Enable them by uncommenting the following line:# deb http://deb.debian.org/debian buster-backports main contrib non-freedeb http://deb.debian.org/debian/ unstable main contrib non-free # raspi 4 needs the latest kernel (5.5 or higher) and raspi-firmware newer than buster's
Noyau
# ls -l vmlinuzlrwxrwxrwx 1 root root 26 sept. 21 14:11 vmlinuz -> boot/vmlinuz-5.8.0-1-arm64
Nom d'hôte
# cat /etc/hostname rpi4-20200909
# apt update# apt upgrade
# apt install locales keyboard-configuration console-setup tzdata# dpkg-reconfigure locales # (sélectionner fr_FR.UTF-8 UTF-8 )# apt install bash-completion command-not-found aptitude sudo# update-command-not-found# apt-file update....
Sortir du chroot
# exit
Démonter les systèmes de fichier de l'hôte
$ sudo umount /mnt/proc /mnt/sys /mnt/dev/pts /mnt/dev
Démonter les partitions et les boucles de périphérique
$ sudo umount /mnt/boot/firmware /mnt$ sudo losetup -d /dev/loop14
$ lsblk -f /dev/loop14
La méthode pour l'émulation de l'image RaspBerry Pi4 officielle est identique à celle pour l'image Debian. Les principaux écarts et résultats sont indiqués ci-après
$ wget http://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2020-08-24/2020-08-20-raspios-buster-armhf-lite.zip
$ lsblk -f /dev/loop14NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINTloop14 ├─loop14p1 vfat boot 4AD7-B4D5 └─loop14p2 ext4 rootfs 2887d26c-6ae7-449d-9701-c5a4018755b0
$ cat /mnt/etc/fstab proc /proc proc defaults 0 0PARTUUID=907af7d0-01 /boot vfat defaults 0 2PARTUUID=907af7d0-02 / ext4 defaults,noatime 0 1
Machine
# uname --machinearmv7l
# cat /etc/issue Raspbian GNU/Linux 10 \n \l
# cat /etc/debian_version 10.4
Sources
# cat /etc/apt/sources.listdeb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi# Uncomment line below then 'apt-get update' to enable 'apt-get source'#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi# cat /etc/apt/sources.list.d/raspi.list deb http://archive.raspberrypi.org/debian/ buster main# Uncomment line below then 'apt-get update' to enable 'apt-get source'#deb-src http://archive.raspberrypi.org/debian/ buster main