{"id":450,"date":"2018-02-25T10:55:15","date_gmt":"2018-02-25T10:55:15","guid":{"rendered":"http:\/\/www.redfelineninja.org.uk\/daniel\/?p=450"},"modified":"2018-03-01T11:56:09","modified_gmt":"2018-03-01T11:56:09","slug":"running-an-iso-installer-image-for-arm64-aarch64-using-qemu-and-kvm","status":"publish","type":"post","link":"http:\/\/www.redfelineninja.org.uk\/daniel\/2018\/02\/running-an-iso-installer-image-for-arm64-aarch64-using-qemu-and-kvm\/","title":{"rendered":"Running an ISO installer image for arm64 (AArch64) using QEMU and KVM"},"content":{"rendered":"<p>Scattered across myriad blogs around the internet you will find many different ways to boot GNU\/Linux for arm64 (a.k.a. AArch64) using QEMU with or without KVM. However, when I recently wanted to quickly spin up a KVM VM on my Developerbox using the Debian Installer ISO images, I couldn&#8217;t find any end-to-end instructions. There is lots of <a href=\"https:\/\/wiki.linaro.org\/LEG\/UEFIforQEMU\">great<\/a> <a href=\"https:\/\/www.bennee.com\/~alex\/blog\/2014\/05\/09\/running-linux-in-qemus-aarch64-system-emulation-mode\/\">information<\/a> out there but I had to assemble the fragments myself. Having done that I thought I would share the results&#8230;<\/p>\n<p><!--more--><\/p>\n<p>To get started you will need:<\/p>\n<ul>\n<li><code>qemu-system-aarch64<\/code>, which can usually get using your distributions package manager (the package name is qemu-system-aarch64 on Fedora but on Debian qemu-system-arm contains both AArch32 and AArch64 support,<\/li>\n<li>A <a href=\"https:\/\/www.debian.org\/CD\/netinst\/\">Debian network installer ISO image<\/a> for arm64, I have tried both Debian 9 &#8220;Stretch&#8221; and Debian Testing &#8220;Buster&#8221;,<\/li>\n<li>A UEFI image for QEMU&#8217;s virt machine type, I use an <a href=\"http:\/\/snapshots.linaro.org\/components\/kernel\/leg-virt-tianocore-edk2-upstream\/latest\/QEMU-AARCH64\/RELEASE_GCC5\/QEMU_EFI.img.gz\">EDK II derived snapshot image<\/a> from Linaro<\/li>\n<\/ul>\n<p>Having downloaded the prerequisites we need to decompress the UEFI system firmware and create both the main disk image and a much smaller image to hold the EFI variable store: <\/p>\n<pre>\r\ngunzip QEMU_EFI.img.gz\r\nqemu-img create -f qcow2 debian.img 128G\r\nqemu-img create -f qcow2 varstore.img 64M\r\n<\/pre>\n<p>Note: <em>It&#8217;s generally better to make the <code>debian.img<\/code> too large rather than too small. qcow2 images are fairly efficient meaning unused space is not allocated and won&#8217;t waste space on the host machine.<\/em><\/p>\n<p>Almost there&#8230; it&#8217;s time to boot the installer.<\/p>\n<p>If you are running on an arm64 workstation and want to accelerate things using KVM try:<\/p>\n<pre>\r\nqemu-system-aarch64 \\\r\n    -cpu host -M virt,accel=kvm -m 4096 -nographic \\\r\n    -drive if=pflash,format=raw,file=QEMU_EFI.img \\\r\n    -drive if=pflash,file=varstore.img \\\r\n    -drive if=virtio,file=debian.img \\\r\n    -drive if=virtio,format=raw,file=debian-9.3.0-arm64-netinst.iso\r\n<\/pre>\n<p>Alternatively, for software simulation (on any host platform) try:<\/p>\n<pre>\r\nqemu-system-aarch64 \\\r\n    -cpu cortex-a53 -M virt -m 4096 -nographic \\\r\n    -drive if=pflash,format=raw,file=QEMU_EFI.img \\\r\n    -drive if=pflash,file=varstore.img \\\r\n    -drive if=virtio,file=debian.img \\\r\n    -drive if=virtio,format=raw,file=debian-9.3.0-arm64-netinst.iso\r\n<\/pre>\n<p>The installer should boot automatically and, for the most part, if you need help using the installer try the <a href=\"https:\/\/www.debian.org\/releases\/stable\/arm64\/\">Debian Installation Guide<\/a>. There is one more thing we need to look at here though; the installer may not be able to find the installation media automatically because we didn&#8217;t ask qemu to read the ISO image is a <a href=\"https:\/\/bugs.debian.org\/cgi-bin\/bugreport.cgi?bug=851429\">CD-ROM rather than an USB stick<\/a> (and we didn&#8217;t ask for that because it crashes the system firmware we are using). If this happens you&#8217;ll see the follow dialog:<\/p>\n<p><a href=\"http:\/\/www.redfelineninja.org.uk\/daniel\/?attachment_id=454\" rel=\"attachment wp-att-454\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-content\/uploads\/2018\/02\/Screenshot-from-2018-02-24-08-51-07.png\" alt=\"\" width=\"772\" height=\"509\" class=\"aligncenter size-full wp-image-454\" srcset=\"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-content\/uploads\/2018\/02\/Screenshot-from-2018-02-24-08-51-07.png 772w, http:\/\/www.redfelineninja.org.uk\/daniel\/wp-content\/uploads\/2018\/02\/Screenshot-from-2018-02-24-08-51-07-300x198.png 300w, http:\/\/www.redfelineninja.org.uk\/daniel\/wp-content\/uploads\/2018\/02\/Screenshot-from-2018-02-24-08-51-07-768x506.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p>To locate the installation media:<\/p>\n<ul>\n<li><em>Load CD-ROM drivers from removable media?<\/em>: Select <strong>No<\/strong><\/li>\n<li><em>Manually select a CD-ROM module and device?<\/em>: Select <strong>Yes<\/strong><\/li>\n<li><em>Module needed for accessing the CD-ROM<\/em>: Select <strong>none<\/strong><\/li>\n<li><en>Device file for accessing the CD-ROM<\/em>: Enter <code>\/dev\/vdb<\/code> and press <strong>Continue<\/strong><\/li>\n<\/ul>\n<p>Now complete the installation!<\/p>\n<p>Once you have everything installed can remove the final <code>-drive<\/code> option. There&#8217;s no problem if you don&#8217;t remove it though. The default boot device after installation is recorded in the varstore (that&#8217;s why we created it) and will be the Debian install inside <code>debian.img<\/code>.<\/p>\n<p>That&#8217;s about it really&#8230; although if you are a kernel hacker and want to quickly spin up a system with a custom kernel without going to the trouble of copying the kernel into the image you can (providing your kernel it&#8217;s too heavily modulized) try something like:<\/p>\n<pre>\r\nqemu-system-aarch64 \\\r\n    -cpu host -M virt,accel=kvm -m 4096 -nographic \\\r\n    -kernel arch\/arm64\/boot\/Image -append root=\/dev\/vda2 \\\r\n    -drive if=virtio,file=debian.img\r\n<\/pre>\n<p>Have fun!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scattered across myriad blogs around the internet you will find many different ways to boot GNU\/Linux for arm64 (a.k.a. AArch64) using QEMU with or without KVM. However, when I recently wanted to quickly spin up a KVM VM on my Developerbox using the Debian Installer ISO images, I couldn&#8217;t find any end-to-end instructions. There is &hellip; <a href=\"http:\/\/www.redfelineninja.org.uk\/daniel\/2018\/02\/running-an-iso-installer-image-for-arm64-aarch64-using-qemu-and-kvm\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Running an ISO installer image for arm64 (AArch64) using QEMU and KVM&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,29,5],"tags":[],"class_list":["post-450","post","type-post","status-publish","format-standard","hentry","category-96boards","category-linaro","category-software"],"_links":{"self":[{"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/posts\/450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/comments?post=450"}],"version-history":[{"count":10,"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/posts\/450\/revisions"}],"predecessor-version":[{"id":461,"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/posts\/450\/revisions\/461"}],"wp:attachment":[{"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/media?parent=450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/categories?post=450"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.redfelineninja.org.uk\/daniel\/wp-json\/wp\/v2\/tags?post=450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}