<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>qemu &#8211; richliu&#039;s blog</title>
	<atom:link href="https://richliu.com/tag/qemu/feed/" rel="self" type="application/rss+xml" />
	<link>https://richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Sat, 03 Feb 2024 14:53:42 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[Gentoo] Upgrade From x64 to ARM64</title>
		<link>https://richliu.com/2024/02/03/5761/gentoo-upgrade-from-x64-to-arm64/</link>
					<comments>https://richliu.com/2024/02/03/5761/gentoo-upgrade-from-x64-to-arm64/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 03 Feb 2024 14:53:39 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[virt-manager]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=5761</guid>

					<description><![CDATA[<p>Describe how to move Gentoo x64 to ARM64 platform. </p>
<p>The post <a rel="nofollow" href="https://richliu.com/2024/02/03/5761/gentoo-upgrade-from-x64-to-arm64/">[Gentoo] Upgrade From x64 to ARM64</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>時隔多年，終於又迎來一次大升級，之前寫過幾篇升級的文章，像是<br />電腦升級 <a href="https://richliu.com/2015/08/06/1827/%e9%9b%bb%e8%85%a6%e5%8d%87%e7%b4%9a-i7-5775c-asus-z97-ausb3-1/">i7 5775c + ASUS Z97-A/USB3.1</a> : 後來 Desktop 還升級了二次，一次是換 i5-9600K，中間還買了 2080 ，最近一次是換 AMD 7900，又買了一張 3090 （當然是買前生產力買後遊戲機），不過因為懶得寫就沒記錄了<br /><a href="https://richliu.com/2013/12/26/1583/gentoo-%e9%9b%bb%e8%85%a6%e5%8d%87%e7%b4%9a%e6%a1%88-32bit-64bit-linux/">[Gentoo] 電腦升級案 32bit -> 64bit Linux</a> : 十年前的升級紀錄，和本篇要寫的文章很像，不過這次就是升級到不同平台架構的機器上了<br /><a href="https://richliu.com/2006/10/17/366/%e5%b1%b1%e5%af%a8%e6%9b%b4%e6%96%b0%e8%a8%98%e9%8c%84/">山寨更新記錄</a> : 早年 BBS 的更新紀錄，現在的話就不會用這種 Raid 盒，都是改用 Software Raid ，便宜！</p>



<p>這次升級要從 x64 平台升級到 ARM64 平台，雖然目前 Linux 下 ARM64 支援度還是不錯，但是兩個平台能用的東西還是有差異，主要是紀錄一下升級過程中有什麼需要注意的事情</p>



<span id="more-5761"></span>



<h2 class="wp-block-heading">ARM64 Hardware Prepareation </h2>



<p>CPU Board: Ampere Altra CPU + AsRock ALTRAD8U : 這個組合現在已經能在 <a href="https://www.newegg.com/p/N82E16813140134" target="_blank" rel="noopener">newegg </a>上買到了，也是目前最強大的 ARM64 平台，當 homelab 平台非常適合<br /><br />DRAM: 買這種主機板用的都是 RDIMM ，有可能便宜有可能貴，可以查 Gigabyte 的 QVL List[<a href="https://www.gigabyte.com/tw/Enterprise/Rack-Server/R152-P33-rev-100#Support-QvlPdfSupportList" target="_blank" rel="noopener">Ref</a>] 內的 DRAM list 購買，有朋友就是在日本買到DDR4 2933 32GB RDIMM 一隻5000羊的DDR，目前匯率 NT$1,100.- 非常便宜<br /><br />Network: AsRock ALTRAD8U 有 1*Intel i210 Ethernet 和 2*10G Intel x550 Ethernet ，這部份到不是問題，我另外拿了舊的 Intel x540 4 Port ethernet 當小 switch 用<br /><br />SATA:  這種板子預設都沒有 SATA interface 了，所以要買 SATA 卡，有 PCIe 轉 SATA ，這個要注意 PCIe bandwidth 和 SATA 數量，一分錢一份貨。<br />如果要追求速度，淘寶上也可以買到便宜 SAS 外接 SATA ，淘寶的 LSI SAS 8port internal 卡大部份 NT$2500 到 NT$6000 都有，記得買轉接線要看好規格，SAS 接頭的規格很多，一不小心就會弄錯<br /><br />SSD: 板子上介面有 2* M.2 2280，如果覺得不夠，可以買 OCU 轉 U.2 轉接線，或是還有 PCIe slot ，可以買 PCIe 轉 M.2 都可以。但是 U.2 的硬碟不一定好買，而且常常價位偏高，但是相對上是比較便宜的選擇</p>



<h2 class="wp-block-heading">Software Move To ARM64 Platform </h2>



<h3 class="wp-block-heading">QEMU/Libvirt</h3>



<p>這部份應該是最難的部份，不過理論上也不是不可以，我原來是 VirtualBox ，但是 ARM64 沒有 VirtualBox ，只有 Proxmox 有，剛看了一下，還支援 riscv64,loongarch64 [<a href="https://github.com/jiangcuo/Proxmox-Port" target="_blank" rel="noopener">ref</a>]，不過我個人不太想再學一套，所以還是用 virt-manager/libvirtd 這套，一般用途 virt-manager 和 libvirtd 應該也很夠用了。</p>



<p>目前用到現在都可以用，Ubuntu 22.04，Windows 10 for x86，Windows 11 for ARM，安裝沒什麼問題。只有 Windows 10 for x86 非常慢，慢到我不想再開了，不知道為什麼。</p>



<p><strong>Qemu bridge devices</strong>: 這個應該是問題，如果是以前用 VirtualBox ，可以直接選 NIC card interface ，但是 virt-manager 似乎沒這個選項，所以要直接設定到 bridge device，不過影響不是很大，就只是設定一個 bridge device，然後將 host internet ethernet port device 綁上去就好了</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img fetchpriority="high" decoding="async" width="824" height="383" src="https://richliu.com/wp-content/uploads/2024/02/image-12.png" alt="" class="wp-image-5762" style="aspect-ratio:2.151436031331593;width:784px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-12.png 824w, https://richliu.com/wp-content/uploads/2024/02/image-12-600x279.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-12-768x357.png 768w" sizes="(max-width: 824px) 100vw, 824px" /></figure>
</div>


<p>其他可能是如果 Libvirt 要用 graphic 輸出，不能用 qxl ，只能用 VGA or ramfb ，尤其是 windows 只能用 ramfb，如果 Guest 是 Linux 可以用 VGA ，顯示比較正常，如果連 GUI 都沒有，就直接看 console 輸出吧，問題更少</p>



<h3 class="wp-block-heading">Qemu file sharing </h3>



<p>QEMU 支援 virtiofs ，不過這個功能在 gentoo 內 ARM64 是不能用的，因為不能用，所以我也不知道 x64 那邊會有什麼限制<br />另外一個是 virtio-9p ，這個缺點是分享進 VM  之後，沒辦法使用 user 權限存取，用 root 身份限制也很多，像是存取 non-root user 檔案會有問題[<a href="https://serverfault.com/questions/559726/kvm-guest-cannot-write-to-9p-share-owned-by-non-root" target="_blank" rel="noopener">ref</a>]<br /><br />有其他需求的人可以考慮改用 samba or nfs ，但是效能就會大大下降了，這點可能是有效能需求的人要考量的</p>



<h3 class="wp-block-heading">Firewall </h3>



<p>原來的 Firewall script 似乎沒辦法和 Libvirt 一起工作，我又不想修改，最後比較簡單的作法就是在我的 script 執行完之後，再重啟 libvirtd ，這樣就正常了。<br />正常後別忘了執行 /etc/init.d/iptables save 儲存，這樣重開機之後才會正常執行 firewall rule. </p>



<h3 class="wp-block-heading">Docker</h3>



<p>試了一下似乎沒什麼問題，但是目前沒什麼要跑的 APP ，所以應該測不出什麼<br />不過之前 arm64 k8s docker [<a href="https://richliu.com/2023/09/17/5329/arm64-kubernetes-qemu-metallb-linkerd-numa/">ref</a>]都跑過了，應該踩雷的機會低很多</p>



<h3 class="wp-block-heading">Other Software</h3>



<p>在 Linux 下轉移到 ARM64 平台問題不大，大部份的 software 都是安裝之後 copy 過去<br />就算是在系統上有資料的 mysql 和 apache 都是這樣</p>



<p>這次我用了一個方式轉移 configuration files<br />1. 將要轉移的程式設定檔 commit 到 git server <br />2. 從新機器將 git server 拉回來 configuration files <br />3. diff 之後將新的設定套上去<br /><br />因為我是 gentoo 玩家，gentoo 升級 packages 常常需 merge configuration files 了，所以這個轉移的過程不難，只是很耗費時間而已。不過因此絕大部份的設定檔都沒有問題，反而是少數系統本身自帶的設定檔反而怪怪的</p>



<h3 class="wp-block-heading">KDE</h3>



<p>之前我都遠端跑 vnc + kde ，不過 Gentoo 有個 BUG 就是 plasmashell 的 CPU usage 會很高<br />這次換 virt-manager 之後可以用 ssh remote control VM，發現這個方式還不錯，反正我也只有用到這個功能，KDE 等有需求的時候再開 vnc 就好了，平時是不需要開的</p>



<h2 class="wp-block-heading">搬移步驟</h2>



<p>1. 備份系統碟，以備不時之需<br />2. 重新規劃電腦的網路卡，如果只有一張就直接設成 bridge interface <br />3. software raid 的部份可以參考自己之前的文章 <a href="https://richliu.com/2011/05/16/1078/linux-software-raid-%E7%B3%BB%E7%B5%B1%E8%BD%89%E7%A7%BB/">Linux Software Raid 系統轉移</a><br />4. UEFI 的部份可以參考自己之前的文章<a href="https://richliu.com/2020/07/09/4295/gentoo-arm64-uefi-install-guide/"> Gentoo ARM64 UEFI Install Guide</a><br />5. 搬移 APPs<br />5.1 重要的 APP 才要搬資料，ex: Web, mysql <br />5.2 不重要的 APP 只要搬設定檔，ex: apt-cache-ng, squid 等等<br />5.3 如果是切換平台，要確定 VM 沒問題才能切</p>



<h2 class="wp-block-heading">Known Issues </h2>



<h3 class="wp-block-heading">IPv6 Default Router</h3>



<p>不知道為什麼，在 wan 的 bridge interface 會增加一個 default route fe80::1 ，這個設定會讓 IPv6 失效，後來解決方式是在 LAN 端加上一個 IP address fe80::1 才解決</p>



<h3 class="wp-block-heading">efi boot </h3>



<p>因為我系統碟是做 software raid  ，每次編完 kernel 再 update grub 時，記得 efi boot 時有時會 fail ，試著將兩顆 nvme 都 mount 上來加上再安裝一次 efi partition 似乎才會正常，找了一下沒找到原因，不管了，反正能動就好</p>



<pre class="wp-block-preformatted">grub-mkconfig -o /boot/grub/grub.cfg
umount /boot/efi
mount /dev/nvme0n1p1 /boot/efi
grub-install --target=arm64-efi --efi-directory=/boot/efi --bootloader-id=Gentoo
umount /boot/efi
mount /dev/nvme1n1p1 /boot/efi
grub-install --target=arm64-efi --efi-directory=/boot/efi --bootloader-id=Gentoo
umount /boot/efi
</pre>



<p>ref.<br />None</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2024/02/03/5761/gentoo-upgrade-from-x64-to-arm64/">[Gentoo] Upgrade From x64 to ARM64</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2024/02/03/5761/gentoo-upgrade-from-x64-to-arm64/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Install ARM64 Windows 11 on ARM64 QEMU System</title>
		<link>https://richliu.com/2024/02/03/5752/install-arm64-windows-11-on-arm64-qemu-system/</link>
					<comments>https://richliu.com/2024/02/03/5752/install-arm64-windows-11-on-arm64-qemu-system/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 03 Feb 2024 03:58:49 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Altra]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[Windows 11]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=5752</guid>

					<description><![CDATA[<p>Chinese article version: 在 ARM64 QEMU System 上安裝 ARM64  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2024/02/03/5752/install-arm64-windows-11-on-arm64-qemu-system/">Install ARM64 Windows 11 on ARM64 QEMU System</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="wp-block-image">
<figure class="alignright size-full is-resized"><img decoding="async" width="1338" height="921" src="https://richliu.com/wp-content/uploads/2024/02/image.png" alt="" class="wp-image-5725" style="aspect-ratio:1.4527687296416938;width:279px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image.png 1338w, https://richliu.com/wp-content/uploads/2024/02/image-600x413.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-768x529.png 768w" sizes="(max-width: 1338px) 100vw, 1338px" /></figure>
</div>


<p>Chinese article version: <a href="https://richliu.com/2024/02/02/5724/%e5%9c%a8-arm64-qemu-system-%e4%b8%8a%e5%ae%89%e8%a3%9d-arm64-windows-11/">在 ARM64 QEMU System 上安裝 ARM64 Windows 11</a></p>



<p>Nowadays, ARM64 systems have become relatively mature, and recently, Windows 11 for ARM64 can also be installed on these systems. Naturally, there are people who want to run it on QEMU. However, most articles on this topic are not well-organized.</p>



<p>Here, let&#8217;s document the things what I discoverd and need to be prepared.</p>



<span id="more-5752"></span>



<h2 class="wp-block-heading">Preparations Hardware and Software</h2>



<p>1) System: Ampere Altra CPU<br />Small ARM64 dev boards like RPI4 or RPI5 should also work, but installing on them might not be necessary, because it only has limitation CPU power and Memory. A more cost-effective solution is to use Apple Mx series CPUs [<a href="https://gist.github.com/CombinedEffort/bb7ffd950692f80a42f0400bd9c10ac3" target="_blank" rel="noopener">ref</a>], as they are also ARM64, and many people purchase them for installing Linux.</p>



<p>2) ARM64 ISO Image <br />While there are numerous options available on internet, for a relatively legal acquisition of the ISO image, it is recommended to use <a href="https://github.com/richliu/Windows-11-On-Ampere" target="_blank" rel="noopener">Windows-11-On-Ampere</a><br />This step can be a bit complex, but the key is to use UUP Dump to fetch the Windows ISO and then use Rufus to burn it onto a USB Flash drive. During the burning process, Rufus can override some of the restrictions of Windows 11, such as TPM Support, which may not be fully supported on ARM64 CPUs.</p>



<p>3) Windows Virtio Driver </p>



<p>Download the Windows Virtio driver and place it into the USB Disk that was created in the previous step. </p>



<p>Here has download URL can download the Windows virtio driver : <a href="https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers#Using_the_ISO" target="_blank" rel="noopener">Proxmox Windows VirtIO Drivers</a>, alternative download website: &nbsp;<a href="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" target="_blank" rel="noopener">download the latest stable</a> or &nbsp;<a href="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso" target="_blank" rel="noopener">download the most recent</a>. <br />After downloading, extract the ISO contents and place them onto the USB Disk.</p>



<p>4) Convert USB Dump to Image <br />Linux users are likely familiar with this step.</p>



<pre class="wp-block-preformatted">dd if=/dev/sda of=/storage/Win11_ARM64_INSTALL.img</pre>



<p><br />Why go through these steps? The primary reason is that within QEMU, it seems Windows cannot simultaneously configure two ISO devices. I encountered a freeze when attempting to install using the straightforward method. Hence, I went through this elaborate process to make it install smoothly.</p>



<p>5) virt-manager <br />Most examples available to others involve pure QEMU commands. However, this time, I wanted to avoid typing a bunch of commands and preferred a more user-friendly approach. Therefore, the examples provided here utilize virt-manager. Nonetheless, I believe the underlying logic is the same.</p>



<h2 class="wp-block-heading">New Virtual Machine on QEMU</h2>


<div class="wp-block-image">
<figure class="alignright size-full is-resized"><img decoding="async" width="453" height="515" src="https://richliu.com/wp-content/uploads/2024/02/image-1.png" alt="" class="wp-image-5726" style="aspect-ratio:0.8796116504854369;width:289px;height:auto"/></figure>
</div>


<p>Virt Type: KVM<br />Architecutre: aarch64 <br />Machine Type: virt </p>



<p>Next step, choice the ISO image we just created Win11_ARM64_INSTALL.img, Choose &#8220;the operaion system you are installing:  Microsoft Windows 11&#8221;</p>



<p>For the CPU and memory, I used 16 cores and 16GB, which should be sufficient. A smaller combination might work, but I haven&#8217;t tested it because I&#8217;m too lazy to do so.</p>



<p>It&#8217;s recommended to set up the Disk Image manually, virt-manager tends to allocate the entire specified disk space right from the start, which may not be space-efficient. Windows 11, with its minimum space requirement of 52GB, can be allocated around 60GB or more based on your needs. Here is example command to pre-create qemu image. </p>



<p>qemu-img create -f qcow2 MyImage.qcow2 60G</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="463" height="450" src="https://richliu.com/wp-content/uploads/2024/02/image-2.png" alt="" class="wp-image-5727" style="aspect-ratio:1.028888888888889;width:290px;height:auto"/></figure>
</div>


<p>Before executing, choose &#8220;Customize configuration before install.&#8221; There are certain adjustments to make. Remember to enable the XML editing feature within virt-manager beforehand. Go to the main program, select Edit -&gt; Preferences -&gt; Enable XML editing, and ensure it is checked.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="512" height="339" src="https://richliu.com/wp-content/uploads/2024/02/image-4.png" alt="" class="wp-image-5729" style="aspect-ratio:1.5103244837758112;width:288px;height:auto"/></figure>
</div>


<p><br />In the XML section related to CPUs, locate the segment pertaining to &#8216;hyperv,&#8217; and modify it with the following settings:</p>



<pre class="wp-block-preformatted">    &lt;hyperv mode="custom"&gt;
      &lt;relaxed state="off"/&gt;
      &lt;vapic state="off"/&gt;
      &lt;spinlocks state="off"/&gt;
    &lt;/hyperv&gt;</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="896" height="604" src="https://richliu.com/wp-content/uploads/2024/02/image-3.png" alt="" class="wp-image-5728" style="aspect-ratio:1.4834437086092715;width:520px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-3.png 896w, https://richliu.com/wp-content/uploads/2024/02/image-3-600x404.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-3-768x518.png 768w" sizes="auto, (max-width: 896px) 100vw, 896px" /></figure>
</div>


<p>In the CPU section, change the quantity from &#8216;sockets&#8217; to &#8216;cores.&#8217; Below is an example for 16 cores:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="439" height="438" src="https://richliu.com/wp-content/uploads/2024/02/image-8.png" alt="" class="wp-image-5733" style="aspect-ratio:1.0022831050228311;width:311px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-8.png 439w, https://richliu.com/wp-content/uploads/2024/02/image-8-300x300.png 300w" sizes="auto, (max-width: 439px) 100vw, 439px" /></figure>
</div>


<p>Add those hardware setting into current configuration: <br />Input -&gt; USB Keyboard<br />Input -&gt; EvTouch USB Graphics Tablet <br />Graphics -&gt; Spice server<br />Video -&gt; Ramfb </p>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="550" height="624" data-id="5735" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_1.png" alt="" class="wp-image-5735" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_1.png 550w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_1-529x600.png 529w" sizes="auto, (max-width: 550px) 100vw, 550px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="550" height="622" data-id="5736" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_2.png" alt="" class="wp-image-5736" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_2.png 550w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_2-531x600.png 531w" sizes="auto, (max-width: 550px) 100vw, 550px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="553" height="624" data-id="5737" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_3.png" alt="" class="wp-image-5737" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_3.png 553w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_3-532x600.png 532w" sizes="auto, (max-width: 553px) 100vw, 553px" /></figure>
</figure>



<p><br /><br /><br />For the Video option, it is essential to choose Ramfb; otherwise, the graphics might not display properly. QXL or Virtio should not be used. Virtio-gpu-pci hasn&#8217;t been tested, but some suggest it might work[<a href="https://github.com/utmapp/UTM/issues/3293" target="_blank" rel="noopener">ref</a>].</p>



<p>Lastly, in Storage, add a USB CDROM device and set it up with the Win11_ARM64_INSTALL.img file you created earlier.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="600" height="646" src="https://richliu.com/wp-content/uploads/2024/02/image-6.png" alt="" class="wp-image-5731" style="aspect-ratio:0.9287925696594427;width:276px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-6.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-6-557x600.png 557w" sizes="auto, (max-width: 600px) 100vw, 600px" /></figure>
</div>


<p>In the Boot Options section, enable the option for USB CDROM 1, and then you should be ready to boot.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="646" height="597" src="https://richliu.com/wp-content/uploads/2024/02/image-7.png" alt="" class="wp-image-5732" style="aspect-ratio:1.082077051926298;width:388px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-7.png 646w, https://richliu.com/wp-content/uploads/2024/02/image-7-600x554.png 600w" sizes="auto, (max-width: 646px) 100vw, 646px" /></figure>
</div>


<p>If the configuration is correct, you should be able to boot to this screen successfully.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="1246" height="935" src="https://richliu.com/wp-content/uploads/2024/02/image-9.png" alt="" class="wp-image-5734" style="aspect-ratio:1.3326203208556149;width:616px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-9.png 1246w, https://richliu.com/wp-content/uploads/2024/02/image-9-600x450.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-9-768x576.png 768w" sizes="auto, (max-width: 1246px) 100vw, 1246px" /></figure>
</div>


<p><br />If following the above steps results in a hang during the installation process, you can try adjusting the boot options by changing the boot order. Try setting &#8220;disk&#8221; first and &#8220;USB CD ROM&#8221; second.</p>



<h2 class="wp-block-heading">Install Windows</h2>



<p>Under normal circumstances, Windows might not detect the disk. In such cases, select &#8220;Load driver&#8221; -&gt; &#8220;25982_1000_ARM64_EN-US(C:)&#8221; -&gt; &#8220;Virtio-driver&#8221; -&gt; &#8220;viostor&#8221; -&gt; &#8220;win11&#8221; -&gt; &#8220;ARM64&#8221; (Note: The labels and directories here may vary based on different configurations).</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="927" height="693" src="https://richliu.com/wp-content/uploads/2024/02/image-10.png" alt="" class="wp-image-5739" style="aspect-ratio:1.3376623376623376;width:495px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-10.png 927w, https://richliu.com/wp-content/uploads/2024/02/image-10-600x449.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-10-768x574.png 768w" sizes="auto, (max-width: 927px) 100vw, 927px" /></figure>
</div>


<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1116" height="693" data-id="5740" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_5.png" alt="" class="wp-image-5740" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_5.png 1116w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_5-600x373.png 600w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_5-768x477.png 768w" sizes="auto, (max-width: 1116px) 100vw, 1116px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="931" height="693" data-id="5741" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_6.png" alt="" class="wp-image-5741" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_6.png 931w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_6-600x447.png 600w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_6-768x572.png 768w" sizes="auto, (max-width: 931px) 100vw, 931px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="928" height="693" data-id="5742" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_7.png" alt="" class="wp-image-5742" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_7.png 928w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_7-600x448.png 600w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_7-768x574.png 768w" sizes="auto, (max-width: 928px) 100vw, 928px" /></figure>
</figure>



<p>In the final step, for the NIC driver, when prompted to connect to the network upon the initial entry into Windows 11, select &#8220;Install driver&#8221; -&gt; &#8220;25982_1000_ARM64_EN-US(D:)&#8221; -&gt; &#8220;Virtio-driver&#8221; -&gt; &#8220;NetKVM&#8221; -&gt; &#8220;win11&#8221; -&gt; &#8220;ARM64&#8221;.</p>



<p>With this, you should have successfully completed the installation of Windows 11.</p>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1047" height="715" data-id="5743" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_8.png" alt="" class="wp-image-5743" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_8.png 1047w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_8-600x410.png 600w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_8-768x524.png 768w" sizes="auto, (max-width: 1047px) 100vw, 1047px" /></figure>



<figure class="wp-block-image size-large"><img decoding="async" data-id="5744" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_9.png" alt="" class="wp-image-5744"/></figure>
</figure>



<p>Happy Playing Windows 11 on ARM64 Qemu </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1175" height="874" src="https://richliu.com/wp-content/uploads/2024/02/image-11.png" alt="" class="wp-image-5745" srcset="https://richliu.com/wp-content/uploads/2024/02/image-11.png 1175w, https://richliu.com/wp-content/uploads/2024/02/image-11-600x446.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-11-768x571.png 768w" sizes="auto, (max-width: 1175px) 100vw, 1175px" /></figure>



<p>ref.<br /><a href="https://github.com/virtio-win/virtio-win-pkg-scripts" target="_blank" rel="noopener">virtio-win / virtio-win-pkg-scripts</a><br /></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2024/02/03/5752/install-arm64-windows-11-on-arm64-qemu-system/">Install ARM64 Windows 11 on ARM64 QEMU System</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2024/02/03/5752/install-arm64-windows-11-on-arm64-qemu-system/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>在 ARM64 QEMU System 上安裝 ARM64 Windows 11</title>
		<link>https://richliu.com/2024/02/02/5724/%e5%9c%a8-arm64-qemu-system-%e4%b8%8a%e5%ae%89%e8%a3%9d-arm64-windows-11/</link>
					<comments>https://richliu.com/2024/02/02/5724/%e5%9c%a8-arm64-qemu-system-%e4%b8%8a%e5%ae%89%e8%a3%9d-arm64-windows-11/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 02 Feb 2024 15:59:28 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Altra]]></category>
		<category><![CDATA[Ampere]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[Windows 11]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=5724</guid>

					<description><![CDATA[<p>Install ARM64 Windows 11 on ARM64 QEMU system</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2024/02/02/5724/%e5%9c%a8-arm64-qemu-system-%e4%b8%8a%e5%ae%89%e8%a3%9d-arm64-windows-11/">在 ARM64 QEMU System 上安裝 ARM64 Windows 11</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="wp-block-image">
<figure class="alignright size-full is-resized"><img loading="lazy" decoding="async" width="1338" height="921" src="https://richliu.com/wp-content/uploads/2024/02/image.png" alt="" class="wp-image-5725" style="aspect-ratio:1.4527687296416938;width:279px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image.png 1338w, https://richliu.com/wp-content/uploads/2024/02/image-600x413.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-768x529.png 768w" sizes="auto, (max-width: 1338px) 100vw, 1338px" /></figure>
</div>


<p>English please see : <a href="https://richliu.com/2024/02/03/5752/install-arm64-windows-11-on-arm64-qemu-system/(在新分頁中開啟)">Install ARM64 Windows 11 on ARM64 QEMU System</a></p>



<p>現在 ARM64 的系統相對成熟了，最近 Windows 11 for ARM64 也可以在系統上安裝，自然也會有人想弄到 QEMU 上去，不過看來看去，大部份都沒有整理完畢的文章</p>



<p>這邊記錄一下需要準備的東西</p>



<span id="more-5724"></span>



<h2 class="wp-block-heading">準備</h2>



<p>1) 系統：Ampere Altra CPU <br />RPI4 or RPI5 這種開發板應該也可以，因為這些板子只有有限的 CPU Power 和記憶體，就沒有安裝 qemu 的必要性，便宜一點的解決方案就是 Apple Mx 系列的 CPU [<a href="https://gist.github.com/CombinedEffort/bb7ffd950692f80a42f0400bd9c10ac3" target="_blank" rel="noopener">ref</a>]，因為也是 ARM64 ，而且很多人也是買來安裝 Linux</p>



<p>2) ARM64 ISO Image <br />網路上應該很多，不過如果要相對合法取得 ISO image ，推薦 <a href="https://github.com/richliu/Windows-11-On-Ampere" target="_blank" rel="noopener">Windows-11-On-Ampere</a><br />這步驟有點複雜，不過重點是用 UUP Dump 抓回 Windows ISO ，然後用 Rufus 燒到 USB Flash ，在燒錄的時候 Rufus 可以解除一些 Windows 11 的限制，像是 TPM Support 等等這些在 ARM64 CPU 還不完全支援的設定</p>



<p>3) Windows Virtio Driver </p>



<p>下載 Windows virtio driver，然後放進去剛剛那一步做到的 USB Disk </p>



<p><a href="https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers#Using_the_ISO" target="_blank" rel="noopener">Proxmox Windows VirtIO Drivers</a> 這邊有下載點，&nbsp;<a href="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" target="_blank" rel="noopener">download the latest stable</a> or &nbsp;<a href="https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso" target="_blank" rel="noopener">download the most recent</a>&nbsp;，都可以下載到 VirtIO ISO，下載完將 ISO 解開放到 USB Disk </p>



<p>4) 將 USB Dump 成 Image <br />Linux user 應該很熟這個步驟</p>



<pre class="wp-block-preformatted">dd if=/dev/sda of=/storage/Win11_ARM64_INSTALL.img</pre>



<p>為什麼要這樣做？最大的原因就是 QEMU 內 Windows 現在似乎沒辦法同時設定二個 ISO 設備，我之前這樣裝會卡住。所以就繞了一大串讓它可以裝，還可以吧</p>



<p>5) virt-manager <br />其他人能找到的範例都是 qemu command ，不過我這次實在是不想打一堆指令，只想點點點，所以這次的範例都是用 virt-manager ，不過我相信背後的思路都是一樣的</p>



<h2 class="wp-block-heading">New Virtual Machine </h2>


<div class="wp-block-image">
<figure class="alignright size-full is-resized"><img loading="lazy" decoding="async" width="453" height="515" src="https://richliu.com/wp-content/uploads/2024/02/image-1.png" alt="" class="wp-image-5726" style="aspect-ratio:0.8796116504854369;width:289px;height:auto"/></figure>
</div>


<p>Virt Type: KVM<br />Architecutre: aarch64 <br />Machine Type: virt </p>



<p>下一步，ISO image 選剛剛做好的 Win11_ARM64_INSTALL.img，Choose the operaion system you are installing: 選 Microsoft Windows 11</p>



<p>CPU 和記憶體我用 16 cores 和 16GB，小一點應該也可以，不過我懶得試了</p>



<p>如果空間不夠，Disk Image 建議自己設定，virt-manager 設定會一開始就 allocate 設定的 disk space ，不省空間，Windows 11 最小需求空間是 52G ，可以設 60G 或是更大，看需求<br />這邊是範例命令，可以預先建好硬碟空間</p>



<p>qemu-img create -f qcow2 MyImage.qcow2 60G</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="463" height="450" src="https://richliu.com/wp-content/uploads/2024/02/image-2.png" alt="" class="wp-image-5727" style="aspect-ratio:1.028888888888889;width:290px;height:auto"/></figure>
</div>


<p>在執行之前選擇 Customize configuration before install，有些東西要修改，記得要先開啟 virt-manager 內的 XML 修改功能，在主程式下的 Edit -&gt; Perferences -&gt; Enable XML editing ，請勾選</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="512" height="339" src="https://richliu.com/wp-content/uploads/2024/02/image-4.png" alt="" class="wp-image-5729" style="aspect-ratio:1.5103244837758112;width:288px;height:auto"/></figure>
</div>


<p>在 CPUs 的 XML 這一段，找到 hyperv 這一段，改成如下的設定</p>



<pre class="wp-block-preformatted">    &lt;hyperv mode="custom"&gt;
      &lt;relaxed state="off"/&gt;
      &lt;vapic state="off"/&gt;
      &lt;spinlocks state="off"/&gt;
    &lt;/hyperv&gt;</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="896" height="604" src="https://richliu.com/wp-content/uploads/2024/02/image-3.png" alt="" class="wp-image-5728" style="aspect-ratio:1.4834437086092715;width:520px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-3.png 896w, https://richliu.com/wp-content/uploads/2024/02/image-3-600x404.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-3-768x518.png 768w" sizes="auto, (max-width: 896px) 100vw, 896px" /></figure>
</div>


<p>在 CPU 數量，要從 sockets 改成 Cores，以下就是 16 Cores 的範例</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="439" height="438" src="https://richliu.com/wp-content/uploads/2024/02/image-8.png" alt="" class="wp-image-5733" style="aspect-ratio:1.0022831050228311;width:311px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-8.png 439w, https://richliu.com/wp-content/uploads/2024/02/image-8-300x300.png 300w" sizes="auto, (max-width: 439px) 100vw, 439px" /></figure>
</div>


<p>Add hardware ，加入以下設定<br />Input -&gt; USB Keyboard<br />Input -&gt; EvTouch USB Graphics Tablet <br />Graphics -&gt; Spice server<br />Video -&gt; Ramfb </p>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-4 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="550" height="624" data-id="5735" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_1.png" alt="" class="wp-image-5735" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_1.png 550w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_1-529x600.png 529w" sizes="auto, (max-width: 550px) 100vw, 550px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="550" height="622" data-id="5736" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_2.png" alt="" class="wp-image-5736" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_2.png 550w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_2-531x600.png 531w" sizes="auto, (max-width: 550px) 100vw, 550px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="553" height="624" data-id="5737" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_3.png" alt="" class="wp-image-5737" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_3.png 553w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_3-532x600.png 532w" sizes="auto, (max-width: 553px) 100vw, 553px" /></figure>
</figure>



<p><br /><br />Video 選項一定要用 Ramfb ，否則 Graphics 會出不來，qxl or virtio 都不能用，virtio-gpu-pci 沒試過，有人說可以用[<a href="https://github.com/utmapp/UTM/issues/3293" target="_blank" rel="noopener">ref</a>]<br />最後是 Storage 增加 USB CDROM device，並且將剛剛的 Win11_ARM64_INSTALL.img  設定上去</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="600" height="646" src="https://richliu.com/wp-content/uploads/2024/02/image-6.png" alt="" class="wp-image-5731" style="aspect-ratio:0.9287925696594427;width:276px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-6.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-6-557x600.png 557w" sizes="auto, (max-width: 600px) 100vw, 600px" /></figure>
</div>


<p>在 Boot Options 這邊 enable USB CDROM 1的選項，然後就可以開機了</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="646" height="597" src="https://richliu.com/wp-content/uploads/2024/02/image-7.png" alt="" class="wp-image-5732" style="aspect-ratio:1.082077051926298;width:388px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-7.png 646w, https://richliu.com/wp-content/uploads/2024/02/image-7-600x554.png 600w" sizes="auto, (max-width: 646px) 100vw, 646px" /></figure>
</div>


<p>如果設定正確，那就可以正常開機到這個畫面</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="1246" height="935" src="https://richliu.com/wp-content/uploads/2024/02/image-9.png" alt="" class="wp-image-5734" style="aspect-ratio:1.3326203208556149;width:616px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-9.png 1246w, https://richliu.com/wp-content/uploads/2024/02/image-9-600x450.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-9-768x576.png 768w" sizes="auto, (max-width: 1246px) 100vw, 1246px" /></figure>
</div>


<p>如果照著以上步驟卻在安裝過程卡住了，可以試著調整 boot option 切換一下開機的順序<br />先 disk 後 USB CD ROM . </p>



<h2 class="wp-block-heading">Install Windows</h2>



<p>正常狀況下，Windows 是找不到 disk 的，要選 load driver -&gt; 25982_1000_ARM64_EN-US(C:) -&gt; Virtio-driver -&gt; viostor -&gt; win11 -&gt; ARM64   (註：這部份的標籤和目錄可能因不同的設定而異）</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="927" height="693" src="https://richliu.com/wp-content/uploads/2024/02/image-10.png" alt="" class="wp-image-5739" style="aspect-ratio:1.3376623376623376;width:495px;height:auto" srcset="https://richliu.com/wp-content/uploads/2024/02/image-10.png 927w, https://richliu.com/wp-content/uploads/2024/02/image-10-600x449.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-10-768x574.png 768w" sizes="auto, (max-width: 927px) 100vw, 927px" /></figure>
</div>


<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-5 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1116" height="693" data-id="5740" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_5.png" alt="" class="wp-image-5740" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_5.png 1116w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_5-600x373.png 600w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_5-768x477.png 768w" sizes="auto, (max-width: 1116px) 100vw, 1116px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="931" height="693" data-id="5741" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_6.png" alt="" class="wp-image-5741" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_6.png 931w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_6-600x447.png 600w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_6-768x572.png 768w" sizes="auto, (max-width: 931px) 100vw, 931px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="928" height="693" data-id="5742" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_7.png" alt="" class="wp-image-5742" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_7.png 928w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_7-600x448.png 600w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_7-768x574.png 768w" sizes="auto, (max-width: 928px) 100vw, 928px" /></figure>
</figure>



<p>最後一段，NIC driver ，在初次進入 Windows 11 時，要求要連線到網路時，選 Install driver -&gt; 25982_1000_ARM64_EN-US(D:) -&gt; Virtio-driver -&gt; NetKVM-&gt; win11 -&gt; ARM64</p>



<p>這樣就可以完成安裝 Windows 11 了</p>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-6 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1047" height="715" data-id="5743" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_8.png" alt="" class="wp-image-5743" srcset="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_8.png 1047w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_8-600x410.png 600w, https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_8-768x524.png 768w" sizes="auto, (max-width: 1047px) 100vw, 1047px" /></figure>



<figure class="wp-block-image size-large"><img decoding="async" data-id="5744" src="https://richliu.com/wp-content/uploads/2024/02/windows11_qemu_9.png" alt="" class="wp-image-5744"/></figure>
</figure>



<p>Happy Playing Windows 11 on ARM64 Qemu </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1175" height="874" src="https://richliu.com/wp-content/uploads/2024/02/image-11.png" alt="" class="wp-image-5745" srcset="https://richliu.com/wp-content/uploads/2024/02/image-11.png 1175w, https://richliu.com/wp-content/uploads/2024/02/image-11-600x446.png 600w, https://richliu.com/wp-content/uploads/2024/02/image-11-768x571.png 768w" sizes="auto, (max-width: 1175px) 100vw, 1175px" /></figure>



<p>ref.<br /><a href="https://github.com/virtio-win/virtio-win-pkg-scripts" target="_blank" rel="noopener">virtio-win / virtio-win-pkg-scripts</a><br /></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2024/02/02/5724/%e5%9c%a8-arm64-qemu-system-%e4%b8%8a%e5%ae%89%e8%a3%9d-arm64-windows-11/">在 ARM64 QEMU System 上安裝 ARM64 Windows 11</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2024/02/02/5724/%e5%9c%a8-arm64-qemu-system-%e4%b8%8a%e5%ae%89%e8%a3%9d-arm64-windows-11/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ARM64 Kubernetes Qemu Metallb Linkerd Numa</title>
		<link>https://richliu.com/2023/09/17/5329/arm64-kubernetes-qemu-metallb-linkerd-numa/</link>
					<comments>https://richliu.com/2023/09/17/5329/arm64-kubernetes-qemu-metallb-linkerd-numa/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 16 Sep 2023 16:46:48 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[kubernetes]]></category>
		<category><![CDATA[libvirt]]></category>
		<category><![CDATA[linkerd]]></category>
		<category><![CDATA[metallb]]></category>
		<category><![CDATA[numa]]></category>
		<category><![CDATA[qemu]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=5329</guid>

					<description><![CDATA[<p>Sometime I feelt hat k8s make me frustrated, Latest tim [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2023/09/17/5329/arm64-kubernetes-qemu-metallb-linkerd-numa/">ARM64 Kubernetes Qemu Metallb Linkerd Numa</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Sometime I feelt hat k8s make me frustrated,  Latest time I wrote this document is 4 years ago, that&#8217;s old version, but when I want to use k8s as container manager again, seems that something different and network won&#8217;t work, original document cannot work anymore, it needs to have new document to record that. </p>



<p>My hardware also different, if you don&#8217;t have such powerful machine, it can skip numa part, that&#8217;s only for high end ARM64 machine. <br />The hardware is <a href="https://amperecomputing.com/systems/altra/2u-mt-collins-2s-sas-3.5" target="_blank" rel="noreferrer noopener">Ampere Mt. Collins</a> which has 2*Ampere Altra 80 Cores CPU and 8*32G Memory, my experiment is run different VM on different CPU, to seperate them and lock it on different numa node. </p>



<span id="more-5329"></span>



<p>There are two CPUs, so, it can create 3 nodes, so, I have plan to allocate resource like that. <br />1. k8s master on socket 0: 10 CPUs, 16G memory <br />2. k8s node1 on socket 0 : 70 CPUs, 100G memory <br />3. k8s node2 on socket 1:  80 CPUs, 120G memory </p>



<p>Kubernetes version v1.28.2<br />Ubuntu 22.04</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Notice: Before reading this document, this document is personal experiment, not Ampere official document, take your own risk. </mark></strong></p>



<h2 class="wp-block-heading">Prepare VM from libvirt </h2>



<p>The server has remote control system which problem sufficent resolution to use GUI on server, so, I install ubuntu 22.04 on host system, than use virt-manager to create k8s master node, for qemu image, I create the disk image alone, seems create image when run install will allocate all disk space, seems that&#8217;s a virt-manager bug. <br />And the host network is configured to be a bridge interface, in my case, that&#8217;s br0. </p>



<p>So, when uses virt-manager to create VM, it can bridge network interface to br0. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2125" height="1179" src="https://richliu.com/wp-content/uploads/2023/09/image-1.png" alt="" class="wp-image-5330" srcset="https://richliu.com/wp-content/uploads/2023/09/image-1.png 2125w, https://richliu.com/wp-content/uploads/2023/09/image-1-600x333.png 600w, https://richliu.com/wp-content/uploads/2023/09/image-1-768x426.png 768w, https://richliu.com/wp-content/uploads/2023/09/image-1-1536x852.png 1536w, https://richliu.com/wp-content/uploads/2023/09/image-1-2048x1136.png 2048w" sizes="auto, (max-width: 2125px) 100vw, 2125px" /><figcaption class="wp-element-caption">After installed first VM, it can copy the master image to another VMs images and named it as k8s-node1 and k8s-node2. <br />need to modify the /etc/hostname, /etc/hosts and /etc/netplan/00-installer-config.yaml in the guest. <br />Remeber to change the CPU number and memory size on virt-manager GUI, different VM needs to use different VM image. it can keep other options by default. </figcaption></figure>



<h2 class="wp-block-heading">Configure the VM with Numa </h2>



<p>It can use numastat to check currnet numa status, this system has two numa nodes. it can use numastat and numactl to get more numa information.</p>



<pre class="wp-block-preformatted"># numastat -n

Per-node numastat info (in MBs):
                          Node 0          Node 1           Total
                 --------------- --------------- ---------------
Numa_Hit               591239.17       791075.41      1382314.58
Numa_Miss                   0.00            0.00            0.00
Numa_Foreign                0.00            0.00            0.00
Interleave_Hit              8.63            7.13           15.77
Local_Node             519434.17       777974.99      1297409.16
Other_Node              71805.00        13100.42        84905.42

# numactl --hardware
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
node 0 size: 128377 MB
node 0 free: 80224 MB
node 1 cpus: 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
node 1 size: 126426 MB
node 1 free: 93888 MB
node distances:
node   0   1
  0:  10  20
  1:  20  10</pre>



<p>virt-manager doesn&#8217;t have advance command to assign CPU, probably modify xml can get that purpose, but it more converince to use the &#8220;virsh&#8221; cli command to adjust VM parameters. &#8220;virsh list&#8221; show current VMs, &#8220;virsh vcpupin list current VM CPU scheduling&#8221;, &#8220;virsh vcpupin <em>domain-id vcpu cpulist</em>&#8221; to modify the VCPU run on which one CPU. </p>



<p>For memory, it needs to use &#8220;virsh numatune&#8221; to lock the memory on different node. <br />&#8220;virsh numatune domain [&#8211;mode mode] [&#8211;nodeset nodeset] [[&#8211;config] [&#8211;live] | [&#8211;current]]&#8221;, &#8211;current can update current running VM machine. </p>



<pre class="wp-block-preformatted">$ virsh list
 Id   Name          State
-----------------------------
 9    k8s-master   running
 10   k8s-node1     running

$ virsh vcpupin k8s-master
 VCPU   CPU Affinity
----------------------
 0      0-159
 1      0-159
 2      0-159
 3      0-159
 4      0-159
 5      0-159
 6      0-159
 7      0-159
 8      0-159
 9      0-159

# this command can lock 9 k8s-master's VCPU 0 on physical CPU 0. 
$ virsh vcpupin 9 0 0 

# Show current VM's numatune, for example, following is unset status. 
$ virsh numatune 9
numa_mode      : strict
numa_nodeset   :

$ virsh numatune 9 --nodeset 0

# the numa_nodeset was set to 0
$ virsh numatune 9
numa_mode      : strict
numa_nodeset   : 0

</pre>



<p>The problem is, seems this script need to run everytime, alternativate solution is to modify XML, but Mt. collis has 160 cores, I won&#8217;t to modify the XML file. script is more converience on this situation, following is my sample script to adjust k8s-master, k8s-node1, and k8s-node2&#8217;s parameter, it can easy to modify it if you install other system or AltraMax CPU. </p>



<pre class="wp-block-preformatted">#!/bin/bash

configure_vm(){
        local VM_NAME="$1"
        local VM_VCPU="$2"
        local VM_CPU="$3"
        local VM_NUMA="$4"
        local VM_TYPE="$5" # VM_TYPE for MASTER or NODE0, NODE1 .. self define name

        id=$(virsh list | grep $VM_NAME | awk '{print $1}')
        state=$(virsh list | grep $VM_NAME | awk '{print $3}')

        if [ "$state" != "running" ]; then
          echo "$VM_TYPE is not running"
          exit 1
        else
          echo "configure $VM_TYPE"
        fi
        numa_nodeset=$(virsh numatune $id | grep numa_nodeset | awk '{print $3}')

        start_cpu=$(echo $VM_VCPU | cut -d'-' -f1)
        end_cpu=$(echo $VM_VCPU | cut -d'-' -f2)
        for ((vcpu = start_cpu; vcpu &lt;= end_cpu; vcpu++)); do
          # echo "$id $vcpu $VM_CPU"
          virsh vcpupin $id $vcpu $VM_CPU > /dev/null
        done
        if [ -n "$numa_nodeset" ]; then
          echo "$VM_TYPE numa_nodeset is $numa_nodeset"
        else
          # echo "$id $VM_NUMA"
          virsh numatune $id --nodeset $VM_NUMA
        fi
}

configure_vm "k8s-master" "0-9" "0-9" "0" "Master"
configure_vm "k8s-node1" "0-69" "10-79" "0" "Node0"
configure_vm "k8s-node2" "0-79" "80-159" "1" "Node1"


====

# After run the script, it can run numastat &lt;pid> to see the qemu runs numa status. ex:
$ sudo numastat 206601

Per-node process memory usage (in MBs) for PID 206601 (qemu-system-aar)
                           Node 0          Node 1           Total
                  --------------- --------------- ---------------
Huge                         0.00            0.00            0.00
Heap                        11.51            0.00           11.51
Stack                        0.04            0.00            0.04
Private                   5984.93            0.00         5984.94
----------------  --------------- --------------- ---------------
Total                     5996.48            0.00         5996.48

</pre>



<p>In here, on socket 0 , 0-9 and 0-69 is vcpu, so, all start from 0. After run this script, it can use &#8220;virsh vcpupin&#8221; and &#8220;virsh numatune&#8221; to get current setting. Maybe cpuset parameter in XML can more easy to get this function, but I have not try it. </p>



<p></p>



<h2 class="wp-block-heading">Install K8s </h2>



<p>Here is my script, just reference some later blog and my previous configurtion script, so, it can copy and paste to system and run it directly. </p>



<p>Install basic system and k8s</p>



<pre class="wp-block-preformatted"># setup timezone
sudo apt install ntpdate -y
sudo ntpdate watch.stdtime.gov.tw
sudo timedatectl set-timezone Asia/Taipei

# install and enable docker

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/docker.gpg
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt update
sudo apt install -y containerd.io

containerd config default | sudo tee /etc/containerd/config.toml >/dev/null 2>&amp;1
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml

sudo systemctl restart containerd
sudo systemctl enable containerd

echo "----------------"
echo "   swapoff"
echo "----------------"
sudo swapoff -a
sudo sed -i '/swap/ s/^\(.*\)$/#\1/g' /etc/fstab

# Install k8s
sudo apt -y install apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
sudo apt update

sudo apt-get -y install kubelet
sudo apt-get -y install kubeadm
sudo apt-get -y install kubectl
sudo apt-mark hold kubelet kubeadm kubectl

# Update kernel parametes
cat &lt;&lt;EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables  = 1
net.ipv4.ip_forward                 = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF

# update sysctl
sudo sysctl --system

sudo tee /etc/modules-load.d/containerd.conf &lt;&lt;EOF
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter

echo "if this is work node, it can run kubeadm join now"

echo "alias k=kubectl" >> .bashrc</pre>



<h3 class="wp-block-heading">Setup Master Node</h3>



<p>Run this script on master node. </p>



<pre class="wp-block-preformatted">sudo kubeadm init --pod-network-cidr=10.244.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

# echo "enable master to run pods"
# kubectl taint nodes --all node-role.kubernetes.io/master-
</pre>



<p>It will shows some message below, then run it on k8s-node1 and k8s-node2</p>



<p>kubeadm join 192.168.110.230:6443 &#8211;token e14f7k.35c3jpny81ry70re \</p>



<p>        &#8211;discovery-token-ca-cert-hash sha256:6636a7e4ec3542f19152f308f0789c52287b743b60efa3c13e7c23ce1147c581</p>



<p>If forgot command above, it can create another token to let other k8s node join, ex:</p>



<pre class="wp-block-preformatted">kubeadm token create --print-join-command</pre>



<h3 class="wp-block-heading">Flannel : Network fabric for container</h3>



<p>K8s need a network fabric to provide internal network topology, there are many choices, but we will install matellb later, some other network like calico might have potential issue, so, we choice flannel as network fabric.</p>



<pre class="wp-block-preformatted">kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml</pre>



<p>After run this command, the k8s node status will change to Ready, if not install network fabric, the node status will be NotReady. </p>



<pre class="wp-block-preformatted">$ kubectl get nodes
NAME         STATUS   ROLES           AGE   VERSION
k8s-master   Ready    control-plane   26h   v1.28.2
k8s-node1    Ready    &lt;none>          26h   v1.28.2
k8s-node2    Ready    &lt;none>          26h   v1.28.2</pre>



<h3 class="wp-block-heading">Helm: Kubbernetes Applications Manager</h3>



<p>Install helm to further install metallb purpose, on previous article, helm2 needs another application to connect to k8s, but helm3 doesn&#8217;t need it, more easy to use on k8s. </p>



<pre class="wp-block-preformatted">curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 -o /tmp/get_helm.sh
chmod 700 /tmp/get_helm.sh
sudo /tmp/get_helm.sh</pre>



<h3 class="wp-block-heading">Metallb: Bere metal load-balancer for K8s</h3>



<p>Install k8s on private side, it needs load-balancer to provide external IP to communication with internet or intranet. If you install Metallb, the &#8220;kubectl get svc&#8221;, the EXTERNAL-IP shows &#8220;Pending&#8221;, and k8s doesn&#8217;t response the arp on host, probably it doesn&#8217;t configure kube-proxy, it you have experience on previous metallb installtion, it might miss this part. </p>



<pre class="wp-block-preformatted">PATH=$PATH:/usr/local/bin/

helm repo add metallb https://metallb.github.io/metallb
helm --namespace metallb-system install --create-namespace metallb metallb/metallb -f metallb-values.yaml

# https://metallb.universe.tf/installation/
# see what changes would be made, returns nonzero returncode if different
kubectl get configmap kube-proxy -n kube-system -o yaml | \
        sed -e "s/strictARP: false/strictARP: true/" | \
        kubectl diff -f - -n kube-system

# actually apply the changes, returns nonzero returncode on errors only
kubectl get configmap kube-proxy -n kube-system -o yaml | \
        sed -e "s/strictARP: false/strictARP: true/" | \
        kubectl apply -f - -n kube-system
</pre>



<p>metallb-values.yaml is also different like previous setting, it needs to configure L2Advertisement on metallb, without it, your metallb won&#8217;t work. Follwing is metallb-values.yaml  file. </p>



<pre class="wp-block-preformatted">apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: primary-pool
  namespace: metallb-system
spec:
  addresses:
  - 192.168.110.200-192.168.110.219

---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: l2adv
  namespace: metallb-system
spec:
  ipAddressPools:
  - primary-pool
</pre>



<h3 class="wp-block-heading">Traefik: TBD</h3>



<h3 class="wp-block-heading">Linkerd</h3>



<p>Just show the install script here</p>



<pre class="wp-block-preformatted">curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh

echo "export PATH=$PATH:/home/$USER/.linkerd2/bin" >> ~/.bashrc

linkerd install --crds | kubectl apply -f -
linkerd install | kubectl apply -f -
linkerd viz install | kubectl apply -f -</pre>



<h3 class="wp-block-heading">Other</h3>



<p>it can insert isolinux to host linux kernel parameter to isolate the Linux scheduling to k8s nodes. (TBD)</p>



<pre class="wp-block-preformatted">isolcpus=10-159 nohz=on nohz_full=10-159</pre>



<h2 class="wp-block-heading">Test with Nginx </h2>



<p>It can deploy nginx to test this system </p>



<pre class="wp-block-preformatted">kubectl create deploy nginx --image=nginx
kubectl expose deploy nginx --port=80 --target-port=80 --type=LoadBalancer
kubectl get svc nginx
NAME    TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)        AGE
nginx   LoadBalancer   10.99.211.255   192.168.110.200   80:31011/TCP   25h</pre>



<p>Now, it can try to access http://192.168.110.200. <br />if want to Delete nginx deploy, run following command. </p>



<pre class="wp-block-preformatted">kubectl delete deploy nginx
kubectl delete svc nginx</pre>



<h2 class="wp-block-heading">Test Numa</h2>



<p>It can run emojivoto to test the system only runs on socket1, use it because it can general a lot of traffic between pods. </p>



<pre class="wp-block-preformatted">curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/emojivoto.yml \
  | kubectl apply -f -</pre>



<p>Now it can use htop to show all CPUs, and we can see most traffic on CPU 1~10 and 81~160. There are a little CPU usage on CPU 78 and 80, but it should be Linux regular scheduling(I have not add isocpu to host CPU this time)</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1982" height="857" src="https://richliu.com/wp-content/uploads/2023/09/image-2.png" alt="" class="wp-image-5338" srcset="https://richliu.com/wp-content/uploads/2023/09/image-2.png 1982w, https://richliu.com/wp-content/uploads/2023/09/image-2-600x259.png 600w, https://richliu.com/wp-content/uploads/2023/09/image-2-768x332.png 768w, https://richliu.com/wp-content/uploads/2023/09/image-2-1536x664.png 1536w" sizes="auto, (max-width: 1982px) 100vw, 1982px" /><figcaption class="wp-element-caption">ref.<br /><a href="https://richliu.com/2019/11/01/4197/arm64-kubernetes-nginx-traefik-ingress-load-balance/" target="_blank" rel="noreferrer noopener">ARM64 Kubernetes Nginx Traefik Ingress Load Balance</a><br /><a href="https://richliu.com/2019/09/25/4160/install-kubernetes-on-arm64-ubuntu-18-04/" target="_blank" rel="noreferrer noopener">Install Kubernetes on ARM64 Ubuntu 18.04 (with QEMU)</a><br /><a href="https://richliu.com/2020/01/14/4256/kubernetes-install-nginx-ingress-on-arm64/" target="_blank" rel="noreferrer noopener">Kubernetes install nginx-ingress on ARM64</a><br /><a href="https://metallb.universe.tf/troubleshooting/" target="_blank" rel="noreferrer noopener">TROUBLESHOOTING METALLB</a><br /><a href="https://github.com/metallb/metallb/issues/1591" target="_blank" rel="noreferrer noopener">Reassignment Duplicate IP after deleting IP pool #1591</a><br /><a href="https://access.redhat.com/documentation/zh-tw/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/sect-virtualization_tuning_optimization_guide-numa-numa_and_libvirt" target="_blank" rel="noreferrer noopener">9.3. libvirt NUMA Tuning</a><br /></figcaption></figure>
<p>The post <a rel="nofollow" href="https://richliu.com/2023/09/17/5329/arm64-kubernetes-qemu-metallb-linkerd-numa/">ARM64 Kubernetes Qemu Metallb Linkerd Numa</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2023/09/17/5329/arm64-kubernetes-qemu-metallb-linkerd-numa/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Unable to complete install: internal error: cannot load AppArmor profile libvirt</title>
		<link>https://richliu.com/2023/03/05/5128/unable-to-complete-install-internal-error-cannot-load-apparmor-profile-libvirt/</link>
					<comments>https://richliu.com/2023/03/05/5128/unable-to-complete-install-internal-error-cannot-load-apparmor-profile-libvirt/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sun, 05 Mar 2023 08:12:43 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[libvirtd]]></category>
		<category><![CDATA[qemu]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=5128</guid>

					<description><![CDATA[<p>ARM64 系統 + Ubuntu 20.04 裝 virt-manager 碰到一些問題，第一關是碰到 li [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2023/03/05/5128/unable-to-complete-install-internal-error-cannot-load-apparmor-profile-libvirt/">Unable to complete install: internal error: cannot load AppArmor profile libvirt</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>ARM64 系統 + Ubuntu 20.04 裝 virt-manager 碰到一些問題，第一關是碰到 libvirtd 被 mask 掉了，這個簡單</p>



<span id="more-5128"></span>



<p>下</p>



<pre class="wp-block-preformatted">systemctl umask libvertd </pre>



<p>就可以 unmask 了，這指令我實在是太少用，都記不起來以前有沒有碰過，第二關忘了是什麼錯誤訊息，大致上好像是沒辦法 link 到 libvirtd-ro 之類的，索性手動啟動所有的 libvirtd-* service </p>



<pre class="wp-block-preformatted">$ sudo systemctl start virtlogd
$ sudo systemctl enable virtlogd
$ sudo systemctl enable virtlockd
$ sudo systemctl start virtlockd
$ sudo systemctl start libvirtd-admin.socket
$ sudo systemctl enable libvirtd-admin.socket
$ sudo systemctl start libvirtd-ro.socket
$ sudo systemctl enable libvirtd-ro.socket
$ sudo systemctl enable libvirtd.socket
$ sudo systemctl start libvirtd.socket
</pre>



<p>最後應該是出現了一個 AppArmor 的錯誤訊息，像是這個</p>



<pre class="wp-block-preformatted">Unable to complete install: 'internal error: cannot load AppArmor profile 'libvirt-df1a8e70-7a27-41e4-a7cc-ea065d3b3699''

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/createvm.py", line 2089, in _do_async_install
    guest.installer_instance.start_install(guest, meter=meter)
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 542, in start_install
    domain = self._create_guest(
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 491, in _create_guest
    domain = self.conn.createXML(install_xml or final_xml, 0)
  File "/usr/lib/python3/dist-packages/libvirt.py", line 4034, in createXML
    if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
libvirt.libvirtError: internal error: cannot load AppArmor profile 'libvirt-df1a8e70-7a27-41e4-a7cc-ea065d3b3699'
</pre>



<p>試過了很多方式，都沒有辦法繞過 AppArmor ，最後只好放大絕，不要讓 qemu 使用 AppArmor ，不安全就算了對吧，</p>



<pre class="wp-block-preformatted">$ sudo vim /etc/libvirt/qemu.conf

# Set
security_driver = "none"</pre>



<p>然後找到　security_driver  這個參數，設定成 &#8220;none&#8221; ，再重新啟動 libvirtd 就可以了<br />真是莫名其妙的 BUG ，因為其他台機器沒有碰到類似的問題</p>



<p>ref.<br /><a href="unable to set AppArmor profile" target="_blank" rel="noreferrer noopener">libvirt: error : unable to set AppArmor profile</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2023/03/05/5128/unable-to-complete-install-internal-error-cannot-load-apparmor-profile-libvirt/">Unable to complete install: internal error: cannot load AppArmor profile libvirt</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2023/03/05/5128/unable-to-complete-install-internal-error-cannot-load-apparmor-profile-libvirt/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>QEMU Network Problem When Run With Docker</title>
		<link>https://richliu.com/2019/10/16/4190/qemu-network-problem-when-run-with-docker/</link>
					<comments>https://richliu.com/2019/10/16/4190/qemu-network-problem-when-run-with-docker/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 16 Oct 2019 06:44:21 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[qemu]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=4190</guid>

					<description><![CDATA[<p>如果 Docker 和 QEMU 同時執行時，QEMU 內部透過 tap interface bridge 到 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2019/10/16/4190/qemu-network-problem-when-run-with-docker/">QEMU Network Problem When Run With Docker</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>如果 Docker 和 QEMU 同時執行時，QEMU 內部透過 tap interface bridge 到 host network 的網路會出不去<br /><br />這個問題的原因是 Docker 起來之後，會將 iptables 的 packet forward 預設變成 DROP<br /><br />這時可以在 Docker 起來的時候將 bridge interface 加到 iptables 規則內即可，首先編輯 systemd docker service </p>



<span id="more-4190"></span>



<pre class="wp-block-preformatted">EDITOR=vim sudo -E systemctl edit docker</pre>



<p>加上這一段</p>



<pre class="wp-block-preformatted">[Service] 
ExecStartPre=/sbin/iptables -A FORWARD -p all -i br0 -j ACCEPT 
ExecStopPost=/sbin/iptables -D FORWARD -p all -i br0 -j ACCEPT</pre>



<p><br />再重啟你的 Docker 就好了</p>



<pre class="wp-block-preformatted">sudo systemctl stop docker 
sudo systemctl start docker </pre>



<p>要不然就簡單一點，將 FORWARD rule 從預設 DROP 變成 ACCEPT</p>



<pre class="wp-block-preformatted">[Service] 
ExecStartPre=/sbin/iptables -P FORWARD ACCEPT </pre>



<p>ref<br /><a href="https://bbs.archlinux.org/viewtopic.php?id=233727" target="_blank" rel="noreferrer noopener" aria-label="[SOLVED] Docker breaks existing bridge I use for KVM/QEMU (opens in a new tab)">[SOLVED] Docker breaks existing bridge I use for KVM/QEMU</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2019/10/16/4190/qemu-network-problem-when-run-with-docker/">QEMU Network Problem When Run With Docker</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2019/10/16/4190/qemu-network-problem-when-run-with-docker/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntu 18.04 Change Mac Address on QEMU via Netplan</title>
		<link>https://richliu.com/2019/09/09/4146/ubuntu18-04changemacaddressonqemuvianetplan/</link>
					<comments>https://richliu.com/2019/09/09/4146/ubuntu18-04changemacaddressonqemuvianetplan/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 09 Sep 2019 15:40:32 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[mac address]]></category>
		<category><![CDATA[netplan]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=4146</guid>

					<description><![CDATA[<p>This is a quick note about how to modify mac address fo [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2019/09/09/4146/ubuntu18-04changemacaddressonqemuvianetplan/">Ubuntu 18.04 Change Mac Address on QEMU via Netplan</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This is a quick note about how to modify mac address for qemu image with ubuntu 18.04 cloud image. <br /><br />but I have not found a working way only change mac address in system </p>



<span id="more-4146"></span>



<h4 class="wp-block-heading">Add mac parameter to qemu command</h4>



<p>in qemu command line, add mac= parameter to netdev option , ex:</p>



<pre class="wp-block-preformatted">-device virtio-net-device,netdev=net2,<strong>mac=52:54:00:56:12:34</strong> \</pre>



<h4 class="wp-block-heading">Modify netplan</h4>



<p>edit file /etc/netplan/50-cloud-init.yaml, and add section match, ex</p>



<pre class="wp-block-preformatted">network:
     version: 2
     ethernets:
         eth0:
             dhcp4: true
<strong>             match:
                 macaddress: 52:54:00:56:12:34</strong>
             set-name: eth0</pre>



<p>now, you can shutdown qemu system and restart . <br /><br />* Notice: if used ubuntu cloud image, please assign mac address before init it. <br />suppose that cloud image might save mac address some where . </p>
<p>The post <a rel="nofollow" href="https://richliu.com/2019/09/09/4146/ubuntu18-04changemacaddressonqemuvianetplan/">Ubuntu 18.04 Change Mac Address on QEMU via Netplan</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2019/09/09/4146/ubuntu18-04changemacaddressonqemuvianetplan/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>QEMU Run x86_64/AMD64 VM on ARM64/AARCH64</title>
		<link>https://richliu.com/2019/08/02/4045/qemu-run-x86_64-on-arm64-server-command/</link>
					<comments>https://richliu.com/2019/08/02/4045/qemu-run-x86_64-on-arm64-server-command/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 02 Aug 2019 03:33:23 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[18.04]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[amd64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[ovfm]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[uefi]]></category>
		<category><![CDATA[x86_64]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=4045</guid>

					<description><![CDATA[<p>This is a work note for run x86_64/AM64 on ARM64/AARCH6 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2019/08/02/4045/qemu-run-x86_64-on-arm64-server-command/">QEMU Run x86_64/AMD64 VM on ARM64/AARCH64</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This is a work note for run x86_64/AM64 on ARM64/AARCH64 server .<br />Because they are different archeticture, so, run x86_64 on ARM server would be very slow. <br /><br />and some functions might be different when run on different platform </p>



<span id="more-4045"></span>



<h2 class="wp-block-heading">Ubuntu</h2>



<p>It can refer to those three articles to create a new cloud image from Ubuntu server image, remember to change ARM64 image to x86_64 image . <br /><br /><a href="https://richliu.com/2018/08/25/2318/change-ubuntu-cloud-image-size">Change Ubuntu Cloud Image Size</a> (if you choice ubuntu 16.04 as your image)<br /><a href="https://richliu.com/2017/08/31/2165/change-ubuntu-cloud-image-password">Change Ubuntu Cloud Image Password</a><br /><a href="https://richliu.com/2017/10/17/2187/ubuntu-cloud-image-taiwan-mirror-site">Ubuntu Cloud Image Taiwan Mirror Site</a><br /></p>



<p>Install Qemu and setup bridge devices </p>



<pre class="wp-block-code"><code>apt install -y ovmf qemu bridge-utils
mkdir -p /etc/qemu
echo "allow br0" &gt; /etc/qemu/bridge.conf
echo "allow virbr0" &gt;&gt; /etc/qemu/bridge.conf</code></pre>



<p>Write this script to a file and run it. </p>



<pre class="wp-block-code"><code>SERVERFILE=xenial-server-cloudimg-amd64-uefi1.img
VERSION=`uname -r`

sudo qemu-system-x86_64 -name vm1 \
        -machine pc-i440fx-xenial,usb=off \
        -cpu qemu64 -m 8192 \
        -smp 12,sockets=1,cores=12,threads=1 \
        -nographic -nodefaults \
        -bios /usr/share/ovmf/OVMF.fd \
        -virtfs local,path=/home/work,mount_tag=host0,security_model=passthrough,id=host0 \
        -drive file=$SERVERFILE  \
        -net nic,macaddr=$macaddr \
        -net tap,ifname=tap0 \
        -serial telnet::9001,server,nowait &gt; guest1_log.txt 2&gt;&amp;1 &amp;

sleep 5

brctl addif br0 tap0</code></pre>



<p>it can use command <br />qemu-system-x86_64 &#8211;machine help<br />and<br /> qemu-system-x86_64 &#8211;cpu help<br />to get all machine and cpu options. <br /><br />it can change cpu and machine type here. <br /><br />network would be bridge on tap0<br /><br />below is good option to share folder between host and VM, below command will share /home/work with vm. </p>



<pre class="wp-block-code"><code>option 
--virtfs local,path=/home/work,mount_tag=host0,security_model=passthrough,id=host0 </code></pre>



<p>it can put this line to /etc/fstab to mount host&#8217;s folder to somewhere, in this case, just put the same directory like host does. <br /></p>



<pre class="wp-block-code"><code>host0   /home/work   9p      trans=virtio,version=9p2000.L,user,umask=000   0 0</code></pre>



<h2 class="wp-block-heading">CentOS</h2>



<p>CentOS document was written on 2021, but Ubuntu document on 2019, there is some difference between it. but that&#8217;s ok, I believe both ways are works. </p>



<h3 class="wp-block-heading">Compile QEMU</h3>



<p>CentOS default application doesn&#8217;t support run x86_64 code on ARM64 server, it needs to compile manually. <br /><br />Please download qemu and compile it. </p>



<pre class="wp-block-code"><code># Install CentOS Packages
yum config-manager --set-enabled powertools
yum install -y xorg-x11-xauth python3 ninja-build
yum install -y glib2-devel libmount-devel
yum install -y git glib2-devel libfdt-devel pixman-devel zlib-devel

# Download QEMU Source Code
wget https://download.qemu.org/qemu-5.2.0.tar.xz
# Decompress it
tar xvf qemu-5.2.0.tar.xz
# 
cd qemu-5.2.0
./configure --target-list="x86_64-softmmu aarch64-softmmu aarch64-linux-user x86_64-linux-user"
make -j `nproc`
make install 
</code></pre>



<p>Then, qemu will be installed on /usr/local/bin</p>



<h3 class="wp-block-heading">Download UEFI Image</h3>



<p>It needs UEFI Image for x86_64 image boot up. It needs <a rel="noreferrer noopener" href="https://github.com/tianocore/tianocore.github.io/wiki/OVMF" data-type="URL" data-id="https://github.com/tianocore/tianocore.github.io/wiki/OVMF" target="_blank">OVMF&#8217;s tianocore</a> (Open Source UEFI BIOS) to boot up. And we  can download <a href="https://www.kraxel.org" data-type="URL" data-id="https://www.kraxel.org" target="_blank" rel="noreferrer noopener">kraxel </a>as prebuild images. </p>



<pre class="wp-block-code"><code># Install Kraxel into CentOS repos
cd /etc/yum.repos.d/
wget https://www.kraxel.org/repos/firmware.repo
yum install edk2.git-aarch64 edk2.git-ovmf-x64
cd &lt;your vm directory&gt;
cp /usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd .
cp /usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd .

</code></pre>



<h3 class="wp-block-heading">Prepare Bridge Devices</h3>



<p>It needs bridge devices to connect to internet, default qemu bridge device name is virbr0 , due to CentOS doesn&#8217;t support brctl, follow this document(<a rel="noreferrer noopener" href="https://www.tecmint.com/create-network-bridge-in-rhel-centos-8/" data-type="URL" data-id="https://www.tecmint.com/create-network-bridge-in-rhel-centos-8/" target="_blank">3 Ways to Create a Network Bridge in RHEL/CentOS 8</a>) to create a CentOS bridge devices. Below is my experiment script to create bridge device, this setting will keep in system, reboot will not be reset. </p>



<pre class="wp-block-code"><code>nmcli conn add type bridge con-name virbr0 ifname virbr0

killall dhclient
ip addr flush enP7p2s0
nmcli conn modify virbr0 ipv4.addresses '192.168.3.191/16'
nmcli conn modify br0 ipv4.gateway '192.168.1.1'
nmcli conn modify br0 ipv4.dns '8.8.8.8'
nmcli conn modify br0 ipv4.method manual
nmcli conn add type ethernet slave-type bridge con-name bridge-br0 ifname enP7p2s0 master virbr0
nmcli conn up virbr0
nmcli conn up bridge-br0

nmcli conn show  --active

# Allow QEMU to access virbr0
mkdir -p /etc/qemu
echo "allow virbr0" &gt;&gt; /etc/qemu/bridge.conf

</code></pre>



<h2 class="wp-block-heading">Run Qemu</h2>



<p>It can refer above to prepare cloud image, I prefer to use ubuntu cloud image, but have not try CentOS image. </p>



<p>Remember Ubuntu 18.04 image won&#8217;t auto increase image size, please follow this <a href="https://richliu.com/2018/08/25/2318/change-ubuntu-cloud-image-size/" data-type="post" data-id="2318">Change Ubuntu Cloud Image Size</a> to modify image size<br /></p>



<pre class="wp-block-code"><code>
qemu-system-x86_64 -m 8192 -smp 16 -nographic \
        -drive if=pflash,format=raw,unit=0,file=OVMF_CODE-pure-efi.fd,readonly=on \
        -drive if=pflash,format=raw,unit=1,file=OVMF_VARS-pure-efi.fd \

        -hdc bionic-server-cloudimg-amd64.img \
        -netdev bridge,br=virbr0,id=net0 \
        -device virtio-net,netdev=net0,mac=00:11:22:33:44:55 \
        -serial telnet::9001,server,nowait &gt; vmlog.txt 2&gt;&gt; vmlog.txt &amp;
</code></pre>



<h3 class="wp-block-heading">x86_64 application</h3>



<p>Sometimes we don&#8217;t need to run whole VM to run some application just for x86_64, it can run user mode application directly. I am a lazy guy, so just reuse cloud image as x86_64 Linux library. </p>



<pre class="wp-block-code"><code>mkdir -p /home/amd64
qemu-img convert  bionic-server-cloudimg-amd64.img bionic-server-cloudimg-amd64.raw
losetup /dev/loop0 bionic-server-cloudimg-amd64.raw
kpartx -a /dev/loop0
mount /dev/mapper/loop0p1 /home/amd64
</code></pre>



<p>Umount Image</p>



<pre class="wp-block-code"><code>umount /home/amd64
losetup -d /dev/loop0</code></pre>



<p>Run x86_64 only application </p>



<pre class="wp-block-code"><code>qemu-x86_64 -L /home/amd64/ bootutil64e
qemu-x86_64 -L /home/amd64/ nvmupdate64e -l</code></pre>



<h2 class="wp-block-heading">Unsolved Problem</h2>



<h3 class="wp-block-heading">Cannot find way to update INTEL NIC&#8217;s NVM</h3>



<p>Tried vfio and application mode, vfio cannot pass iommu to host, it will fail. <br /><br />User space application will cause mmap fail. <br /><br />If you know how to update Intel NIC&#8217;s NVM, welcome to leave a message for me. </p>



<h3 class="wp-block-heading">QEMU &#8211;static problem</h3>



<p>Add &#8211;static parameter will cause some problem, cannot solve it right now. </p>



<p><br />./configure &#8211;target-list=&#8221;x86_64-softmmu aarch64-softmmu aarch64-linux-user x86_64-linux-user&#8221; &#8211;static<br />===</p>



<p>ERROR: sizeof(size_t) doesn&#8217;t match GLIB_SIZEOF_SIZE_T.</p>



<p>&nbsp;&nbsp;&nbsp; You probably need to set PKG_CONFIG_LIBDIR</p>



<p>&nbsp;&nbsp;&nbsp; to point to the right pkg-config files for your&nbsp;&nbsp;&nbsp; build target</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2019/08/02/4045/qemu-run-x86_64-on-arm64-server-command/">QEMU Run x86_64/AMD64 VM on ARM64/AARCH64</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2019/08/02/4045/qemu-run-x86_64-on-arm64-server-command/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Kdump in ubuntu 18.04 ARM64</title>
		<link>https://richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/</link>
					<comments>https://richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Tue, 16 Jul 2019 03:55:16 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[Kdump]]></category>
		<category><![CDATA[qemu]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=4024</guid>

					<description><![CDATA[<p>kdump is very good tool to debug complex system like cl [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/">Kdump in ubuntu 18.04 ARM64</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><br /> kdump is very good tool to debug complex system like cloud data center, it can easy to save kernel status when crash.  <br />Running kdump in ARM64 just like running in x86, but I met a strange problem on ARM64 platform.<br /><br />The kernel version is HWE kernel, current version is 4.18.0-25, mihbt be encounter those problems </p>



<span id="more-4024"></span>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>$ crash /usr/lib/debug/boot/vmlinux-4.18.0-25-generic 201907111618/dump.201907111618</p><p>crash: cannot determine page size</p></blockquote>



<p>or (after add pagesize parameter )</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>$ crash /usr/lib/debug/boot/vmlinux-4.18.0-25-generic 201907111618/dump.201907111618 -p 65536</p><p>please wait… (gathering module symbol data)<br /> WARNING: cannot access vmalloc&#8217;d module memory<br /> please wait… (gathering task table data)<br /> WARNING: duplicate idle tasks?<br /> please wait… (determining panic task)<br /> crash: invalid kernel virtual address: ffff0000100d0000  type: &#8220;64-bit KVADDR&#8221;</p></blockquote>



<p>If you have problem like this, please update your Ubuntu crash version. <br />In my opinion, Ubuntu 18.04&#8217;s kdump crash only for kernel 4.15, not for HWE kernel or above. <br /><br />In here, suggest to use HWE kernel or later for more hardware compatibility <br /><br />download latest crash and compile it</p>



<pre class="wp-block-preformatted">vim /etc/apt/source.list
# removed all "#" before # deb-src
apt update
apt-get build-dep linux-crashdump
git clone https://github.com/crash-utility/crash.git
cd crash
make</pre>



<p>and it can assign absolutely path to run new version crash, ex: </p>



<pre class="wp-block-preformatted">/root/crash/crash /usr/lib/debug/boot/vmlinux-5.0.0-20-generic 201907171611/dump.201907171611</pre>



<h2 class="wp-block-heading">Prepare QEMU Image and Run It</h2>



<p>Use ubuntu cloud image as a QEMU Image would be fast and easy, it can download Ubuntu 18.04 cloud image first</p>



<pre class="wp-block-preformatted">wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-arm64.img</pre>



<p>It also can download from local mirror site, like Taiwan mirror server</p>



<pre class="wp-block-preformatted">wget http://ftp.yzu.edu.tw/Linux/ubuntu-cloud-images/bionic/current/bionic-server-cloudimg-arm64.img</pre>



<p>After finished download job, it needs to change cloud image default password for login. <br />please refer another article <a rel="noreferrer noopener" aria-label="Change Ubuntu Cloud Image Password (opens in a new tab)" href="https://richliu.com/2017/08/31/2165/change-ubuntu-cloud-image-password" target="_blank">Change Ubuntu Cloud Image Password</a>. to change it. <br /></p>



<h3 class="wp-block-heading">Run QEMU With Cloud Image</h3>



<p>Before run QEMU command, it needs to install necessary packages </p>



<pre class="wp-block-preformatted">sudo apt install -y qemu-efi qemu bridge-utils</pre>



<p>Write bridge devices into qemu</p>



<pre class="wp-block-preformatted">mkdir -p /etc/qemu
echo "allow br0" &gt; /etc/qemu/bridge.conf
echo "allow virbr0" &gt;&gt; /etc/qemu/bridge.conf</pre>



<p>Create UEFI Bios image and flush for QEMU</p>



<pre class="wp-block-preformatted">dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
dd if=/dev/zero of=flash1.img bs=1M count=64</pre>



<p>Configure you major LAN as bridge device, it can modify setup below to fit current network environment </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>ORIGNIC=enP6p1s0<br /> ip addr flush $ORIGNIC <br /> brctl addbr br0<br /> brctl addif br0  $ORIGNIC  <br /> ifconfig br0 up<br /> ifconfig br0 192.168.1.100 netmask 255.255.255.0<br /> route add default gw 192.168.1.1<br /> echo nameserver 8.8.8.8 &gt;&gt; /etc/resolv.conf</p><cite><br /></cite></blockquote>



<p>Save text below into a  shell file and run it. </p>



<pre class="wp-block-preformatted">  
SERVERFILE=bionic-server-cloudimg-arm64.img

 sudo qemu-system-aarch64 -name kdump-vm \
         -machine virt,gic_version=3,accel=kvm,usb=off \
         -cpu host -m 8192 \
         -smp 8,sockets=1,cores=8,threads=1 \
         -nographic -nodefaults \
         -drive if=pflash,format=raw,readonly,file=flash0.img \
         -drive if=pflash,format=raw,file=flash1.img \
         -drive file=$SERVERFILE,if=none,id=disk1  \
         -device virtio-blk-device,scsi=off,drive=disk1,id=virtio-disk1,bootindex=1 \
         -netdev tap,id=net0,ifname=tap0 \
         -device virtio-net-device,netdev=net0 \
         -serial telnet::9001,server,nowait > vm_log.txt 2>&amp;1 &amp;
 sleep 5
 brctl addif br0 tap0 </pre>



<p>it can use command &#8220;telnet localhost 9001&#8221; to login qemu image . <br />if failed, please check vm_log.txt for reason. <br /><br />if there is blank screen on VM, please check whether copy right qemu-efi into flash0.img. </p>



<h2 class="wp-block-heading">Running Kdump in VM</h2>



<p>It can install openssh-server in VM, thus, it would be more easy to run command remotely. especially, if used telnet, vim usually cannot reflect right terminal window size and cannot wrap word correctly. <br /><br /> Install kdump (only for ARM64 QEMU, if used HEW kernel, it needs to download latest version linux-crashdump)</p>



<pre class="wp-block-preformatted">sudo apt install linux-crashdump</pre>



<p>More information about install kdump, please refer to this article <a rel="noreferrer noopener" aria-label="Kernel Crash Dump (opens in a new tab)" href="https://help.ubuntu.com/lts/serverguide/kernel-crash-dump.html" target="_blank">Kernel Crash Dump</a><br /><br />I would suggest to increase kdump ramdisk size to 512M, not used ubuntu linux-crashdump default size. edit /etc/default/grub.d/kdump-tools.cfg and find your RAM size, change following parameter to 512M, ex: my VM memory size is 8GB, so, I modify 4G-32G paramete to 4G-32G:512M<br /></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>GRUB_CMDLINE_LINUX_DEFAULT=&#8221;$GRUB_CMDLINE_LINUX_DEFAULT crashkernel=2G-4G:320M,4G-32G:512M,32G-64G:1024M,64G-128G:2048M,128G-:4096M&#8221;</p></blockquote>



<p>After update kernel parameter, update grub to make sure it will get new parameter on boot</p>



<pre class="wp-block-preformatted">update-grub2</pre>



<h3 class="wp-block-heading">Install Kernel Debug Symbol</h3>



<p>Install GPG Key</p>



<pre class="wp-block-preformatted">sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8CAB6595FDFF622</pre>



<p>Add repository config</p>



<pre class="wp-block-preformatted">codename=$(lsb_release -c | awk  '{print $2}')
sudo tee /etc/apt/sources.list.d/ddebs.list < < EOF
deb http://ddebs.ubuntu.com/ ${codename}      main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-updates  main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-proposed main restricted universe multiverse
EOF</pre>



<p>Update packages and install symbol. (ref <a href="https://hadibrais.wordpress.com/2017/03/13/installing-ubuntu-kernel-debugging-symbols/" target="_blank" rel="noreferrer noopener" aria-label="Installing Ubuntu Kernel Debugging&nbsp;Symbols (opens in a new tab)">Installing Ubuntu Kernel Debugging&nbsp;Symbols</a>)</p>



</pre><pre class="wp-block-preformatted">sudo apt-get update
sudo apt-get install linux-image-$(uname -r)-dbgsym</pre>



<h2 class="wp-block-heading">Trigger Kdump</h2>



<p>it can used command </p>



<pre class="wp-block-preformatted">kdump-config show </pre>



<p>to check current kdump status. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>$ kdump-config show<br /> DUMP_MODE:        kdump<br /> USE_KDUMP:        1<br /> KDUMP_SYSCTL:     kernel.panic_on_oops=1<br /> KDUMP_COREDIR:    /var/crash<br /> crashkernel addr: 0xdfe00000<br />    /var/lib/kdump/vmlinuz: symbolic link to /boot/vmlinuz-4.15.0-54-generic<br /> kdump initrd:<br />    /var/lib/kdump/initrd.img: symbolic link to /var/lib/kdump/initrd.img-4.15.0-54-generic<br /><strong> current state:    ready to kdump</strong><br /> kexec command:<br />   /sbin/kexec -p &#8211;command-line=&#8221;BOOT_IMAGE=/boot/vmlinuz-4.15.0-54-generic root=UUID=6242429e-2876-4d52-a590-99654a6a91ac ro quiet splash vt.handoff=1 nr_cpus=1 systemd.unit=kdump-tools-dump.service&#8221; &#8211;initrd=/var/lib/kdump/initrd.img /var/lib/kdump/vmlinuz</p></blockquote>



<p>if evenything is ok, it should have state: ready to kdump .<br /><br /></p>



<h3 class="wp-block-heading">Trigger Kdump</h3>



<p>it can easy to trigger Kdump via sysrq. I will suggest to trigger sysrq on telnet. it will show dump message and reboot message.  more easy to know it get right result. </p>



<pre class="wp-block-preformatted">echo 1 &gt; /proc/sys/kernel/sysrq
echo c &gt; /proc/sysrq-trigger</pre>



<p>First command to configure sysrq to accept all trigger. <br />Second command is to trigger kernel crash </p>



<p>$ echo c &gt; /proc/sysrq-trigger<br /> [   31.855103] sysrq: SysRq : Trigger a crash<br /> [   31.861713] Internal error: Accessing user space memory outside uaccess.h routines: 96000044 [#1] SMP<br /> [   31.869136] Modules linked in: nls_iso8859_1 sch_fq_codel ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 btrfs zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear aes_ce_blk aes_ce_cipher crc32_ce<br /> crct10dif_ce ghash_ce sha2_ce sha256_arm64 sha1_ce virtio_net virtio_blk aes_neon_bs aes_neon_blk crypto_simd cryptd aes_arm64<br /> [   31.879776] CPU: 1 PID: 1385 Comm: bash Not tainted 4.15.0-54-generic #58-Ubuntu<br /> [   31.882430] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015<br /> [   31.884892] pstate: 00400005 (nzcv daif +PAN -UAO)<br /> [   31.886641] pc : sysrq_handle_crash+0x24/0x30<br /> [   31.888198] lr : __handle_sysrq+0xbc/0x1c0<br /> [   31.889627] sp : ffff00000e513d50<br /> [   31.890835] x29: ffff00000e513d50 x28: ffff8001f2e93c00<br /> [   31.892723] x27: ffff000008b32000 x26: 0000000000000040<br /> [   31.894639] x25: 0000000000000124 x24: ffff0000095ee000<br /> [   31.896524] x23: 0000000000000004 x22: 0000000000000002<br /> [   31.898433] x21: 0000000000000063 x20: ffff000009550000<br /> [   31.900309] x19: ffff0000095ee4e0 x18: ffffffffffffffff<br /> [   31.902229] x17: 0000000000000000 x16: 0000000000000000<br /> [   31.904127] x15: ffff000009528c08 x14: ffff0000896d687f<br /> [   31.906046] x13: ffff0000096d688d x12: ffff00000954f000<br /> [   31.907954] x11: ffff000009529660 x10: ffff000008708540<br /> [   31.909848] x9 : 00000000ffffffd0 x8 : 0000000000000017<br /> [   31.911801] x7 : 6767697254203a20 x6 : ffff8001ffdc82e8<br /> [   31.913655] x5 : ffff8001ffdc82e8 x4 : 0000000000000000<br /> [   31.915569] x3 : ffff8001ffdd06c8 x2 : 068be67f3165eb00<br /> [   31.917430] x1 : 0000000000000000 x0 : 0000000000000001<br /> [   31.919312] Process bash (pid: 1385, stack limit = 0x        (ptrval))<br /> [   31.921599] Call trace:<br /> [   31.922506]  sysrq_handle_crash+0x24/0x30<br /> [   31.923964]  __handle_sysrq+0xbc/0x1c0<br /> [   31.925311]  write_sysrq_trigger+0xd8/0x120<br /> [   31.926851]  proc_reg_write+0x80/0xc0<br /> [   31.928178]  __vfs_write+0x48/0x80<br /> [   31.929399]  vfs_write+0xac/0x1b0<br /> [   31.930618]  SyS_write+0x6c/0xd8<br /> [   31.931777]  el0_svc_naked+0x30/0x34<br /> [   31.933062] Code: 52800020 b90ca020 d5033e9f d2800001 (39000020)<br /> [   31.935269] SMP: stopping secondary CPUs<br /> [   31.937745] Starting crashdump kernel…<br /> [   31.939108] Bye!</p>



<p>After kdump save current status and reboot , it will save crash log on /var/crash, run crash command below, it can see some output </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>$ crash &#8211;mod /usr/lib/debug/lib/modules/4.15.0-54-generic/ /usr/lib/debug/boot/vmlinux-4.15.0-<br /> 54-generic 201907150556/dump.201907150556<br /> crash 7.2.1<br /> Copyright (C) 2002-2017  Red Hat, Inc.<br /> Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation<br /> Copyright (C) 1999-2006  Hewlett-Packard Co<br /> Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited<br /> Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.<br /> Copyright (C) 2005, 2011  NEC Corporation<br /> Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.<br /> Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.<br /> This program is free software, covered by the GNU General Public License,<br /> and you are welcome to change it and/or distribute copies of it under<br /> certain conditions.  Enter &#8220;help copying&#8221; to see the conditions.<br /> This program has absolutely no warranty.  Enter &#8220;help warranty&#8221; for details.<br /> GNU gdb (GDB) 7.6<br /> Copyright (C) 2013 Free Software Foundation, Inc.<br /> License GPLv3+: GNU GPL version 3 or later <a href="http://gnu.org/licenses/gpl.html" target="_blank" rel="noopener">http://gnu.org/licenses/gpl.html</a><br /> This is free software: you are free to change and redistribute it.<br /> There is NO WARRANTY, to the extent permitted by law.  Type &#8220;show copying&#8221;<br /> and &#8220;show warranty&#8221; for details.<br /> This GDB was configured as &#8220;aarch64-unknown-linux-gnu&#8221;…<br /> <code>  KERNEL: /usr/lib/debug/boot/vmlinux-4.15.0-54-generic DUMPFILE: 201907150556/dump.201907150556  [PARTIAL DUMP]     CPUS: 12     DATE: Mon Jul 15 05:56:07 2019   UPTIME: 2135039823346 days, 00:15:35</code><br /> LOAD AVERAGE: 0.41, 0.32, 0.13<br />        TASKS: 202<br />     NODENAME: ubuntu<br />      RELEASE: 4.15.0-54-generic<br />      VERSION: #58-Ubuntu SMP Mon Jun 24 10:56:40 UTC 2019<br />      MACHINE: aarch64  (unknown Mhz)<br />       MEMORY: 8 GB<br />        PANIC: &#8220;sysrq: SysRq : Trigger a crash&#8221;<br />          PID: 1444<br />      COMMAND: &#8220;bash&#8221;<br />         TASK: ffff8001f019ad00  [THREAD_INFO: ffff8001f019ad00]<br />          CPU: 1<br />        STATE: TASK_RUNNING (SYSRQ)</p></blockquote>



<p>Next step, more how to use crash information, please refer to article <a href="https://www.dedoimedo.com/computers/crash-analyze.html" target="_blank" rel="noreferrer noopener" aria-label="Analyzing Linux kernel crash dumps with crash - The one tutorial that has it all (opens in a new tab)">Analyzing Linux kernel crash dumps with crash &#8211; The one tutorial that has it all</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/">Kdump in ubuntu 18.04 ARM64</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2019/07/16/4024/kdump-in-ubuntu-18-04-arm64/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>QEMU change default nat address configure file</title>
		<link>https://richliu.com/2018/04/26/2272/qemu-change-default-nat-address-configure-file/</link>
					<comments>https://richliu.com/2018/04/26/2272/qemu-change-default-nat-address-configure-file/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 26 Apr 2018 11:54:26 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[libvirt]]></category>
		<category><![CDATA[qemu]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=2272</guid>

					<description><![CDATA[<p>In ubuntu, if install libvirt, it will bring up bridge  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2018/04/26/2272/qemu-change-default-nat-address-configure-file/">QEMU change default nat address configure file</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In ubuntu, if install libvirt, it will bring up bridge interface virbr0 and configure the ip address 192.168.122.1</p>
<p>modify /etc/libvirt/qemu/networks/default.xml can change that</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2018/04/26/2272/qemu-change-default-nat-address-configure-file/">QEMU change default nat address configure file</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2018/04/26/2272/qemu-change-default-nat-address-configure-file/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>QEMU Share Directory with Host Without Networking</title>
		<link>https://richliu.com/2017/09/25/2173/qemu-share-directory-with-host-without-networking/</link>
					<comments>https://richliu.com/2017/09/25/2173/qemu-share-directory-with-host-without-networking/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 25 Sep 2017 12:33:41 +0000</pubDate>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[9p]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[share]]></category>
		<category><![CDATA[virtio]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=2173</guid>

					<description><![CDATA[<p>If Guest Support 9P and virtio. Add this line to QEMU c [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2017/09/25/2173/qemu-share-directory-with-host-without-networking/">QEMU Share Directory with Host Without Networking</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If Guest Support 9P and virtio. </p>
<p>Add this line to QEMU command</p>
<pre lang="text">
-virtfs local,path=/path/to/share,mount_tag=host0,security_model=passthrough,id=host0
</pre>
<p>and in guest os, edit /etc/fstab and add</p>
<pre lang="text">
host0   /wherever    9p      trans=virtio,version=9p2000.L   0 0
</pre>
<p>ref.<br />
https://superuser.com/questions/628169/how-to-share-a-directory-with-the-host-without-networking-in-qemu</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2017/09/25/2173/qemu-share-directory-with-host-without-networking/">QEMU Share Directory with Host Without Networking</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2017/09/25/2173/qemu-share-directory-with-host-without-networking/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>aarch64/ARM64 virt-install 啟動方法</title>
		<link>https://richliu.com/2017/01/05/2064/aarch64arm64-virt-install-%e5%95%9f%e5%8b%95%e6%96%b9%e6%b3%95/</link>
					<comments>https://richliu.com/2017/01/05/2064/aarch64arm64-virt-install-%e5%95%9f%e5%8b%95%e6%96%b9%e6%b3%95/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 05 Jan 2017 15:19:34 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[virt-install]]></category>
		<category><![CDATA[virt-manager]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=2064</guid>

					<description><![CDATA[<p>雖然 ubuntu 有好用的 uvttool-libvirt 可以管理 cloud image , 但是似乎在 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2017/01/05/2064/aarch64arm64-virt-install-%e5%95%9f%e5%8b%95%e6%96%b9%e6%b3%95/">aarch64/ARM64 virt-install 啟動方法</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>雖然 ubuntu 有好用的 uvttool-libvirt 可以管理 cloud image , 但是似乎在 aarch64/ARM64 的平台上會有問題,<br />
參數傳進去的時候似乎都會叫起來 VGA (cirrus), 但是 QEMU aarch64 上不支援 VGA (至少我用的不支援)<br />
替代方案就是用 Virt Manager<br />
<span id="more-2064"></span></p>
<p>安裝</p>
<pre lang="bash">
$ sudo apt install virt-manager
</pre>
<p>跑一個簡單的 aarch64 image </p>
<pre lang="bash">
$ sudo virt-install --name ubuntu-aarch64 --ram 2048 --arch aarch64 --boot uefi \
--disk /home/test/ubuntu.img,device=disk,bus=virtio \
--boot machine=virt,kernel=trusty-kernel,kernel_args="console=ttyAMA0 root=/dev/vda1 rw kgdboc=ttyAMA0,115200" \
--network bridge:virbr0 \
--os-type=linux \
--nographics \
--noautoconsole
</pre>
<p>ubuntu.img 是預先準備好的 <a href="https://cloud-images.ubuntu.com/" target="_blank" rel="noopener">ubuntu cloud image</a>, 16.04 才可以支援比較多的 ARM64 平台.<br />
14.04 支援的就少很多. </p>
<p>以上的參數比較重要的是 &#8211;noautoconsole, 這樣執行時就不會等在那邊, 會自動啟動. </p>
<p>&#8211;noautoconsole will install vm to libvirt without connect to console </p>
<p>&#8212;- 2017/03/10 &#8212;-<br />
也可以用 virt-install + netboot install</p>
<p>先建立 image </p>
<pre lang="bash">$ qemu-img create -f qcow2 ./name.qcow2 30G </pre>
<p>再執行 virt-install , 目前測過 14.04 和 16.04 , 只有 16.04 成功, 猜想是 ports 那邊少了什麼東西</p>
<pre lang="bash">
$ sudo virt-install --name ubuntu-aarch64 --ram 4096 --vcpus 4 --arch aarch64 \
        --boot uefi \
        --disk /home/richliu/disk.qcow2,device=disk,bus=virtio \
        --network bridge:virbr0 \
        --os-type=linux \
        --nographics \
        --location 'http://ports.ubuntu.com/dists/xenial/main/installer-arm64/'
</pre>
<p>這個參數可以順利安裝完, 然後再啟動系統就好</p>
<p>&#8212;- 2017/04/26 &#8212;-<br />
如果是要裝 ARM64 Trusty-Update 的 Netboot kernel . 要動一下小技巧<br />
1) 先在 host VM 上安裝 apache2<br />
2) 到 /var/www/html 上 mirror http://ports.ubuntu.com/dists/trusty-updates/main/installer-arm64/current/images/ 下的<br />
* MANIFEST<br />
* MANIFEST.udebs<br />
* xenial-generic/netboot => </p>
<p>目錄要照著放, 所以會是</p>
<pre lang="bash">
$ cd /var/www/html
$ mkdir -p dists/trusty-updates/main/installer-arm64/current/images/
$ cd dists/trusty-updates/main/installer-arm64/current/images/
$ lftp http://ports.ubuntu.com/dists/trusty-updates/main/installer-arm64/current/images/
[download blah blah]
$ mv xenial-generic/netboot .
</pre>
<p>然後 &#8211;location 指到 http://[ARM64 Server IP] 這樣就可以了, ex:</p>
<pre lang="bash">
virt-install --name ubuntu-aarch64 --ram 8192 --vcpus 4 --arch aarch64 \
--boot uefi \
--disk /root/disk.qcow2,device=disk,bus=virtio \
--network bridge:virbr0,model=virtio \
--os-type=linux \
--nographics \
--location http://10.102.81.16/dists/trusty-updates/main/installer-arm64
</pre>
<p>對了, 這邊的 model=virtio 是強迫 network interface 不要用 vhost, 而是用 virtio</p>
<pre lang="bash">
$ virsh start ubuntu-aarch64
$ virsh connect ubuntu-aarch64
</pre>
<p>ref.<br />
<a href="http://opennodecloud.com/opennode-os/2013/01/01/howto-kvm-guest-install.html" target="_blank" rel="noopener">KVM Guest virt-install examples with virtio drivers</a><br />
<a href="https://raymii.org/s/articles/virt-install_introduction_and_copy_paste_distro_install_commands.html" target="_blank" rel="noopener">Installing Virtual Machines with virt-install, plus copy pastable distro install one-liners</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2017/01/05/2064/aarch64arm64-virt-install-%e5%95%9f%e5%8b%95%e6%96%b9%e6%b3%95/">aarch64/ARM64 virt-install 啟動方法</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2017/01/05/2064/aarch64arm64-virt-install-%e5%95%9f%e5%8b%95%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
