Lancement de Raspbian à partir de Qemu.
Distribution de travail : Ubuntu 12.04
1) Répertoire de travail :
[~] ➔ mkdir QEMU [~] ➔ cd QEMU/ [~/QEMU] ➔
2) Installation de paquetage :
[~/QEMU] ➔ sudo apt-get install kpartx
I) Installation de Qemu.
1) Téléchargement du code source de Qemu :
[~/QEMU] ➔ wget http://wiki.qemu-project.org/download/qemu-2.2.0.tar.bz2
2) Décompression de l’archive Qemu :
[~/QEMU] ➔ tar xvfj qemu-2.2.0.tar.bz2 [~/QEMU] ➔ cd qemu-2.2.0/ [~/QEMU/qemu-2.2.0] ➔
3) Configuration de la compilation :
[~/QEMU/qemu-2.2.0] ➔ ./configure
4) Compilation :
[~/QEMU/qemu-2.2.0] ➔ make
5) Installation de Qemu :
[~/QEMU/qemu-2.2.0] ➔ sudo make install [~/QEMU/qemu-2.2.0] ➔ cd ..
6) Vérification :
[~/QEMU] ➔ qemu-i386 -version qemu-i386 version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard
7) Liens :
http://www.pihomeserver.fr/2015/02/20/raspberry-pi-home-server-creer-rapidement-une-image-de-test/
http://wiki.qemu.org/
II) Construction de l’image minimal Raspbian pour l’installation en réseau.
1) Téléchargement du script de construction :
[~/QEMU] ➔ git clone https://github.com/debian-pi/raspbian-ua-netinst.git [~/QEMU] ➔ cd raspbian-ua-netinst/ [~/QEMU/raspbian-ua-netinst (master)] ➔
2) Téléchargement des paquetages Raspbian :
[~/QEMU/raspbian-ua-netinst (master)] ➔ ./update.sh
3) Construction de installateur initramfs et du paquetage .zip :
[~/QEMU/raspbian-ua-netinst (master)] ➔ ./build.sh
4) Construction de l’image de l’installateur :
[~/QEMU/raspbian-ua-netinst (master)] ➔ sudo ./buildroot.sh
5) Vérification :
[~/QEMU/raspbian-ua-netinst (master)] ➔ ls -l raspbian* -rw-r--r-- 1 root root 33554432 mars 9 22:11 raspbian-ua-netinst-20150309-gitf31b204.img -rw-r--r-- 1 root root 17398881 mars 9 22:12 raspbian-ua-netinst-20150309-gitf31b204.img.bz2 -rw-r--r-- 1 root root 10641236 mars 9 22:11 raspbian-ua-netinst-20150309-gitf31b204.img.xz -rw-rw-r-- 1 util01 util01 17513096 mars 9 22:10 raspbian-ua-netinst-20150309-gitf31b204.zip [~/QEMU/raspbian-ua-netinst (master)] ➔ cd ..
6) Lien :
https://github.com/debian-pi/raspbian-ua-netinst
III) Construction de la distribution :
1) Téléchargement du noyau spécifique à Qemu :
[~/QEMU] ➔ wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu
2) Copier l’image de l’installateur :
[~/QEMU] ➔ cp raspbian-ua-netinst/raspbian-ua-netinst-20150309-gitf31b204.img .
3) Script de construction de la distribution :
Remarque : Différences par rapport au script d’origine.
– Le répertoire temporaire est indiqué en « dur » : temp/
– Copie de ~/QEMU/raspbian-ua-netinst/installer-rpi2.cpio vers ~/QEMU/installer.cpio
– Supprimer la commande de suppression du répertoire temporaire.
Ouvrir :
raspbian-ua-netinst-qemu-prepare.sh
Ajouter :
#!/usr/bin/env bash check_tool() { if [ -z "$(which "$1")" ]; then echo "The required tool \"${1}\" was not found. Abort." exit 1 fi } SCRIPT_NAME="$(basename "$0")" DISK_IMAGE="$1" if [ -z "$DISK_IMAGE" ]; then echo "Usage: $SCRIPT_NAME DISK_IMAGE" exit 1 fi if [ "$(id -u)" != 0 ]; then sudo "$0" "$@" exit "$?" fi check_tool "qemu-img" check_tool "kpartx" TEMP_DIR="temp" qemu-img resize "$DISK_IMAGE" 486M LOOP_DEVICE_NAME="$(kpartx -avs "$DISK_IMAGE" | grep -o 'loop[0-9]' | head -n 1)" mkdir -p "$TEMP_DIR/installer" mkdir -p "$TEMP_DIR/disk-image/boot" mount "/dev/mapper/${LOOP_DEVICE_NAME}p1" "$TEMP_DIR/disk-image/boot" (cd "$TEMP_DIR/installer" && cpio -iv < ~/QEMU/"installer.cpio") (cd "$TEMP_DIR/installer" && sed -i '/^bootdev=/s|/dev/mmcblk0|/dev/sda|' "etc/init.d/rcS") (cd "$TEMP_DIR/installer" && sed -i '/^bootpartition=/s|/dev/mmcblk0p1|/dev/sda1|' "etc/init.d/rcS") (cd "$TEMP_DIR/installer" && sed -i '/^rootdev=/s|/dev/mmcblk0|/dev/sda|' "etc/init.d/rcS") (cd "$TEMP_DIR/installer" && sed -i '/^rootpartition=/s|$|/dev/sda2|' "etc/init.d/rcS") (cd "$TEMP_DIR/installer" && find . | cpio -H newc -ov > ../"installer-qemu.cpio") rm -rf "$TEMP_DIR/installer" mv "$TEMP_DIR/installer-qemu.cpio" . cat << EOF > "$TEMP_DIR/disk-image/boot/installer-config.txt" packages=whiptail,pppoeconf bootsize=+64M EOF cat << EOF > "$TEMP_DIR/disk-image/boot/post-install.txt" sed -i 's|/dev/sda2|/dev/mmcblk0p2|' "/rootfs/boot/cmdline.txt" sed -i 's|/dev/sda1|/dev/mmcblk0p1|' "/rootfs/etc/fstab" sed -i 's|/dev/sda2|/dev/mmcblk0p2|' "/rootfs/etc/fstab" echo "gpu_mem=16" >> "/rootfs/boot/config.txt" EOF sync umount "$TEMP_DIR/disk-image/boot" kpartx -d "$DISK_IMAGE" > "/dev/null"
Action :
chmod +x raspbian-ua-netinst-qemu-prepare.sh
4) Pre-installation : Configuration de installer.cpio
[~/QEMU] ➔ cp raspbian-ua-netinst/installer-rpi2.cpio installer.cpio
5) Lancement du script :
[~/QEMU] ➔ sudo ./raspbian-ua-netinst-qemu-prepare.sh raspbian-ua-netinst-20150309-gitf31b204.img
6) Lien :
http://pastebin.com/sqtQ19Ci
IV) Lancement de l’image Raspbian minimal :
1) Installation des paquetages pour la configuration de Raspbian minimal :
[~/QEMU] ➔ sudo chown util01:util01 raspbian-ua-netinst-20150309-gitf31b204.img [~/QEMU] ➔ qemu-system-arm -kernel "kernel-qemu" -initrd "installer-qemu.cpio" -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "consoleblank=0" "raspbian-ua-netinst-20150309-gitf31b204.img"
2) Lancement de l’image :
[~/QEMU] ➔ qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -append "root=/dev/sda2 rw vga=normal console=ttyAMA0,115200" -hda raspbian-ua-netinst-20150309-gitf31b204.img -redir tcp:5022::22 -serial stdio
3) Authorisation d’accés :
Login : root
Mot de passe : raspbian
Comments are closed, but trackbacks and pingbacks are open.