<?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>aarch64 &#8211; richliu&#039;s blog</title>
	<atom:link href="https://blog.richliu.com/tag/aarch64/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Wed, 09 Oct 2024 17:22:14 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>Gentoo ARM64 Altra Compile chromium Issue</title>
		<link>https://blog.richliu.com/2024/10/10/6052/gentoo-arm64-altra-compile-chromium-issue/</link>
					<comments>https://blog.richliu.com/2024/10/10/6052/gentoo-arm64-altra-compile-chromium-issue/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 09 Oct 2024 17:22:12 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[Altra]]></category>
		<category><![CDATA[AltraMax]]></category>
		<category><![CDATA[Ampere]]></category>
		<category><![CDATA[arm64]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=6052</guid>

					<description><![CDATA[<p>When compile the chromium on my Altra platform, it meet [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/10/10/6052/gentoo-arm64-altra-compile-chromium-issue/">Gentoo ARM64 Altra Compile chromium Issue</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When compile the chromium on my Altra platform, it meet compile problem like this</p>



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



<pre class="wp-block-preformatted">no-dangling-assignment-gsl -std=c++20 -Wno-trigraphs -gsimple-template-names -fno-exceptio00:01:51 [472/19443]
nc++ -isystem../../third_party/libc++/src/include -isystem../../third_party/libc++abi/src/include -fvisibility
-inlines-hidden -O2 -pipe -march=armv8.2-a -Wno-unknown-warning-option -c ../../third_party/libyuv/source/comp
are_neon64.cc -o obj/third_party/libyuv/libyuv_neon/compare_neon64.o
../../third_party/libyuv/source/compare_neon64.cc:175:8: error: instruction requires: dotprod
  175 |       "udot        v4.4s, v0.16b, v6.16b         \n"
      |        ^
&lt;inline asm>:14:1: note: instantiated into assembly here
   14 | udot        v4.4s, v0.16b, v6.16b
      | ^
../../third_party/libyuv/source/compare_neon64.cc:176:8: error: instruction requires: dotprod
  176 |       "udot        v5.4s, v1.16b, v6.16b         \n"
      |        ^
&lt;inline asm>:15:1: note: instantiated into assembly here
   15 | udot        v5.4s, v1.16b, v6.16b
      | ^
../../third_party/libyuv/source/compare_neon64.cc:204:8: error: instruction requires: dotprod
  204 |       "udot        v4.4s, v0.16b, v0.16b         \n"
      |        ^
&lt;inline asm>:10:1: note: instantiated into assembly here
   10 | udot        v4.4s, v0.16b, v0.16b
      | ^
../../third_party/libyuv/source/compare_neon64.cc:205:8: error: instruction requires: dotprod
  205 |       "udot        v5.4s, v1.16b, v1.16b         \n"
      |        ^
&lt;inline asm>:11:1: note: instantiated into assembly here
   11 | udot        v5.4s, v1.16b, v1.16b
      | ^
4 errors generated.
[10940/63891] aarch64-unknown-linux-gnu-clang++-18 -MD -MF obj/third_party/libyuv/libyuv_neon/rotate_neon.o.d</pre>



<p>Seems because some -march/-mcpu/-mtune drop &#8216;dotprod&#8217; parameters, it needs to add the extension manuall. &#8216;+dotprod&#8217;.</p>



<p>Edit the file /etc/portage/make.conf, and change the COMMON_FLAGS to </p>



<pre class="wp-block-preformatted">COMMON_FLAGS="-mcpu=neoverse-n1+crc+crypto+ssbs+dotprod -O2 -pipe"</pre>



<p>It can use the following command to get current CPU flag</p>



<pre class="wp-block-preformatted">gcc -v -E -x c /dev/null -o /dev/null -march=native -mcpu=native 2>&amp;1 | grep /cc1</pre>



<p>Thanks Gentoo user zukunf to provide those information. </p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/10/10/6052/gentoo-arm64-altra-compile-chromium-issue/">Gentoo ARM64 Altra Compile chromium Issue</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2024/10/10/6052/gentoo-arm64-altra-compile-chromium-issue/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>LLM Chat WebGUI and Fine-Turning on Ampere Altra ARM64 Platform</title>
		<link>https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/</link>
					<comments>https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sun, 10 Mar 2024 07:30:53 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[Altra]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[Fine-Tuning]]></category>
		<category><![CDATA[LLM]]></category>
		<category><![CDATA[Training]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=5852</guid>

					<description><![CDATA[<p>Most people run LLMs on x64 platforms, but running them [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/">LLM Chat WebGUI and Fine-Turning on Ampere Altra ARM64 Platform</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Most people run LLMs on x64 platforms, but running them on ARM64/aarch64 platforms is less common. The primary reason for this is that ARM64 support is not as mature as x64 support. Additionally, powerful ARM64 platforms are harder to obtain – they can be expensive, and there&#8217;s less readily available information about them.</p>



<p>Qualcomm&#8217;s new desktop SoCs might change this landscape. However, we can still leverage the Ampere Altra platform to run LLMs.</p>



<p>Since this is a personal blog, most articles here are my personal notes. I&#8217;ll keep them updated as my understanding evolves.</p>



<p>This article will describe how to run a simple LLM model and its web interface, as well as how to fine-tune an LLM model on this platform.</p>



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



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#use-current-llm-model-with-gui">Use current LLM model with GUI</a><ul><li><a href="#big-llm">Big LLM </a></li></ul></li><li><a href="#open-webui">Open-Webui</a></li><li><a href="#llm-fine-turning-l-la-ma-factory">LLM Fine-Turning &#8211; LLaMA-Factory </a><ul><li><a href="#pre-training">Pre-Training</a></li><li><a href="#evaluate-predict">Evaluate &amp; Predict </a></li><li><a href="#test-chat-model">Test Chat Model</a></li><li><a href="#export-model">Export model</a></li></ul></li></ul></nav></div>



<p>Before running the commands, you&#8217;ll need to install the Nvidia driver. Refer to this article, &#8220;[<a href="https://blog.richliu.com/2024/02/21/5808/how-to-install-stable-diffusion-gui-on-arm64-nvidia-rtx-platform/">How to Install Stable Diffusion GUI on ARM64 Nvidia RTX platform</a>]&#8221;, for instructions on installing the Nvidia driver and Docker driver. </p>



<p>Ollama and Open-Webui don&#8217;t require a GPU. However, having a GPU is beneficial. Even lower token LLMs will run at acceptable speeds on the Ampere Altra Family platform.</p>



<p>This article&#8217;s hardware setup is as follows:</p>



<ul class="wp-block-list">
<li>CPU : Ampere Altra Family </li>



<li>Board: AsRock ALTRAD8UD </li>



<li>GPU: Nvidia RTX 4080</li>
</ul>



<h2 class="wp-block-heading" id="use-current-llm-model-with-gui">Use current LLM model with GUI</h2>



<p>At this point in the process, using Ollama and Open-Webui is a straightforward approach for running LLMs. Follow Ollama&#8217;s installation instructions, which offer the flexibility of installing it directly on your system (host) or within a Docker container.</p>



<pre class="wp-block-preformatted">curl -fsSL https://ollama.com/install.sh | sh</pre>



<p>By default, the Ollama service listens on localhost (127.0.0.1). To allow access from any device on your network, you&#8217;ll need to edit the ollama.service file.</p>



<p>In the [Service] section, add the following line:</p>



<pre class="wp-block-preformatted">Environment="OLLAMA_HOST=0.0.0.0:11434"</pre>



<p>For Open-Webui, we recommend using Docker for a simpler solution. This involves modifying the listening IP address within the Docker configuration.</p>



<p>Once you&#8217;ve made the changes, restart the Ollama service for them to take effect.</p>



<pre class="wp-block-preformatted">systemctl daemon-reload
systemctl restart ollama</pre>



<p>Run the ollama command and try it</p>



<pre class="wp-block-preformatted"># ollama run llama2
&gt;&gt;&gt; who are you

I'm LLaMA, an AI assistant developed by Meta AI that can understand and respond to human input in a conversational manner.
I'm here to help you with any questions or topics you'd like to discuss! Is there something specific you'd like to talk
about or ask?

&gt;&gt;&gt; </pre>



<p>If doesn&#8217;t work, try to restart ollama and try again. </p>



<h3 class="wp-block-heading" id="big-llm">Big LLM </h3>



<p>If choose some big LLM like LLaMA2-70b or Qwen </p>



<h2 class="wp-block-heading" id="open-webui">Open-Webui</h2>



<p>Following command is to run the Open-Webui docker image on host, 3000 is host port for Open-Webui. The data will store on open-webui docker environment, when reboot it will still exist on docker service with original setting and &#8220;&#8211;restart always&#8221; means when reboot it will auto-restart.</p>



<pre class="wp-block-preformatted">docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main</pre>



<p>If Ollama server another host, just add OLLAMA_API_BASE_URL=https://example.com/api to the docker command, </p>



<pre class="wp-block-preformatted">docker run -d -p 3000:8080 -e OLLAMA_API_BASE_URL=https://example.com/api -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main</pre>



<p>Upon login, you&#8217;ll need to provide an email and password. Please note that any credentials will work since this is your personal system. Once logged in, you can also edit the OLLAMA_API_BASE on the settings page.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1307" height="875" src="https://blog.richliu.com/wp-content/uploads/2024/03/image.png" alt="" class="wp-image-5853" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image.png 1307w, https://blog.richliu.com/wp-content/uploads/2024/03/image-600x402.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-768x514.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-816x546.png 816w" sizes="(max-width: 1307px) 100vw, 1307px" /></figure>



<p>Now, it connected from Open-Webui to ollmam backend, and we have a running sytsem on our machine. <br />Run sample chat here and choice llama2:latest as LLM model. </p>



<figure class="wp-block-image size-full"><img decoding="async" width="2205" height="761" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-1.png" alt="" class="wp-image-5854" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-1.png 2205w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-600x207.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-768x265.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-1536x530.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-2048x707.png 2048w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-816x282.png 816w" sizes="(max-width: 2205px) 100vw, 2205px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="llm-fine-turning-l-la-ma-factory">LLM Fine-Turning &#8211; LLaMA-Factory </h2>



<p>Fine-tuning LLMs ideally requires a GPU card for better performance. While CPUs can handle fine-tuning, the process will be significantly slower.</p>



<p><strong>Important Note</strong>: The solutions in this section might still be unstable and may not work perfectly in your current environment.</p>



<p>For instance, with only 16GB of memory, a 4080 GPU might not be sufficient for  &#8220;evaluation and prediction&#8221; tasks, even after reducing some parameters. This still can lead to CUDA out-of-memory errors.</p>



<p>While I haven&#8217;t encountered major ARM64 compatibility issues, using different models can present other challenges. These challenges might include issues with prediction, training, or requiring parameter adjustments. Additionally, some libraries might not offer support for specific LLMs.</p>



<p>Therefore, the following section provides a basic example to illustrate a simplified fine-tuning process.</p>



<p>For fine-tuning solutions, we&#8217;ve chosen <a href="https://github.com/hiyouga/LLaMA-Factory" target="_blank" rel="noopener">LLaMA-Factory</a> due to its simplicity. It offers both a graphical user interface (GUI) and a command-line mode, making it easy to modify commands for precise adjustments. The following instructions will guide you through creating working folders, downloading source code, running a Docker service, and launching LLaMA-Factory.</p>



<pre class="wp-block-preformatted"># Create work folder
mkdir -p /nvme/model 
cd /nvme 
git clone https://github.com/hiyouga/LLaMA-Factory.git

# Run docker, it will use host GPU and map the folder into docker.
sudo docker run --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -it --rm \
     -v /nvme:/nvme \
     -p 7860:7860 \
     nvcr.io/nvidia/pytorch:24.01-py3

# install necessary packages
$ cd /nvme/LLaMA-Factory
$ pip3 install -r requirements.txt
$ pip3 install tiktoken transformers_stream_generator

# run the LLaMA-Factory
$ CUDA_VISIBLE_DEVICES=0 python src/train_web.py</pre>



<p>Now, it can acces the webgui via http://host IP:7860.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1506" height="857" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-2.png" alt="" class="wp-image-5855" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-2.png 1506w, https://blog.richliu.com/wp-content/uploads/2024/03/image-2-600x341.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-2-768x437.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-2-816x464.png 816w" sizes="(max-width: 1506px) 100vw, 1506px" /></figure>



<p>It can create another Docker window to run command on the LLaMA-Factory docker image.</p>



<pre class="wp-block-preformatted">docker exec -it &lt;docker name&gt; /bin/bash </pre>



<p>for download LLMs, you need to use git download from huggingface, ex: </p>



<pre class="wp-block-preformatted"># LLama 2 need username and token(not passowrd) to download it. 
git clone https://huggingface.co/meta-llama/Llama-2-7b-hf

# Qwen
git clone https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat
git clone https://huggingface.co/Qwen/Qwen1.5-1.8B</pre>



<h3 class="wp-block-heading" id="pre-training">Pre-Training</h3>



<p>Model name, choice the LLMs name , like Qwen1.5-1.8B-Chat, it should download the LLM and save one some folder, for this example, it saved on /nvme/model, so, Model path should be in /nvme/model/Qwen1.5-1.8B-Chat. </p>



<p>First time, I suggest to use small LLM for fine-tuning, Qweb1.5-0.8B might have issue, will suggest from 1.5-1.8B to start. </p>



<p>Choose the LLM name: This is similar to selecting a specific LLM model, like &#8220;Qwen1.5-1.8B-Chat&#8221;. The instructions will indicate your LLM folder. For this example, the model would be saved in /nvme/model/Qwen1.5-1.8B-Chat.</p>



<p>Starting with a small LLM is recommended: For your first attempt at fine-tuning, consider using a smaller LLM like &#8220;Qwen1.5-1.8B&#8221;. It&#8217;s possible that &#8220;Qweb1.5-0.8B&#8221; might cause issues, so we recommend starting with models in the 1.5-1.8B range.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1822" height="1206" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-3.png" alt="" class="wp-image-5856" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-3.png 1822w, https://blog.richliu.com/wp-content/uploads/2024/03/image-3-600x397.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-3-768x508.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-3-1536x1017.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-3-816x540.png 816w" sizes="(max-width: 1822px) 100vw, 1822px" /></figure>



<p>Here are the fine-tuning options you can adjust in LLaMA-Factory:</p>



<p><strong>Dataset</strong>: You can add datasets to this mode. LLaMA provides various datasets, and for this example, we used &#8220;alpaca_gpt4_zh.&#8221;<br /><strong>Gradient accumulation</strong>: This is currently set to 4.<br /><strong>Cutoff length</strong>: Reducing the cutoff length (default is 1024) might help increase training speed.<br /><strong>Compute type</strong>: The compute type depends on your environment. In this case, fp16 works, but bp16 doesn&#8217;t sometimes.<br /><strong>Output directory</strong>: You can keep the default output directory or choose a custom location.<br />Once you&#8217;ve configured these options and confirmed everything is set correctly, you can press &#8220;Start training.&#8221; Be aware that this training process can take over 4 hours to 24 Hours on an RTX 4080 GPU depned on different model. </p>



<h3 class="wp-block-heading" id="evaluate-predict">Evaluate &amp; Predict </h3>



<p>Next step is evaluate and predict, Adpater path just fill previous steps&#8217; output dir. Dataset is the same. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2059" height="1207" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-4.png" alt="" class="wp-image-5857" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-4.png 2059w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-600x352.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-768x450.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-1536x900.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-2048x1201.png 2048w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-816x478.png 816w" sizes="(max-width: 2059px) 100vw, 2059px" /></figure>



<p>When everything is ready, press Start. Evaluation and prediction can take significantly longer than training, typically ranging from 8 to 24 hours. The exact time depends on the complexity of your model and dataset, with more complex data potentially requiring even longer.</p>



<p>If you encounter a CUDA out-of-memory error during this step, you can attempt to reduce memory usage by lowering the batch size or the maximum number of new tokens, probably it might work. [<a href="https://github.com/hiyouga/LLaMA-Factory/issues/1191" target="_blank" rel="noopener">ref</a>]</p>



<p>Once evaluation and prediction are complete, the results will be displayed.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2008" height="304" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-5.png" alt="" class="wp-image-5858" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-5.png 2008w, https://blog.richliu.com/wp-content/uploads/2024/03/image-5-600x91.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-5-768x116.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-5-1536x233.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-5-816x124.png 816w" sizes="(max-width: 2008px) 100vw, 2008px" /></figure>



<h3 class="wp-block-heading" id="test-chat-model">Test Chat Model</h3>



<p>You can test chat result by load module. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2077" height="1043" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-6.png" alt="" class="wp-image-5859" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-6.png 2077w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-600x301.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-768x386.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-1536x771.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-2048x1028.png 2048w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-816x410.png 816w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-400x200.png 400w" sizes="(max-width: 2077px) 100vw, 2077px" /></figure>



<h3 class="wp-block-heading" id="export-model">Export model</h3>



<p>Remember to fill export dir, in here I used &#8220;/nvme/newmodel/Qwen1.5-1.8B-Chat&#8221;</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2077" height="1030" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-7.png" alt="" class="wp-image-5860" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-7.png 2077w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-600x298.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-768x381.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-1536x762.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-2048x1016.png 2048w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-816x405.png 816w" sizes="(max-width: 2077px) 100vw, 2077px" /></figure>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<p>Currently, there is a bug reported when using <code>convert.py</code> to convert the Qwen model to gguf format [<a href="https://github.com/QwenLM/Qwen1.5/issues/57" target="_blank" rel="noopener">ref</a>]</p>



<p>It&#8217;s recommended to use&nbsp;<code>convert-hf-to-gguf.py</code>&nbsp;for model conversion, ex:</p>
</div></div>



<pre class="wp-block-preformatted">cd /nvme/newmodel 
python3 /nvme/llama.cpp/convert-hf-to-gguf.py Qwen1.5-1.8B-Chat --outfile test.gguf

# Use llama.cpp to test this model 
/nvme/llama.cpp/build/bin/main -m test.gguf -p "who are you?"

# Command mode
/nvme/llama.cpp/build/bin/main -m test.gguf -ins
</pre>



<p>Create a file named &#8220;Modelfile&#8221;, and fill this</p>



<pre class="wp-block-preformatted">FROM /nvme/newmodel/test.gguf</pre>



<p>Now, run ollama to include this LLM. </p>



<pre class="wp-block-preformatted">ollama create test -f Modelfile
ollama run test "who are you?"
====
 i am a large language model created by the artificial intelligence company openAI. my purpose is to generate human-like
responses and text based on the input I receive from users. can I help you with anything today? #openai

#chatbot
Sure, I'm here to assist you! How can I help you today? Is there something specific you'd like to talk about or ask me?
#openaiChatBot不断地尝试。 #AI #MachineLearning
</pre>



<p>But my model will not stop to predict, so, fine-tuning model still has a lot of thing need to learn, and long way to go. </p>



<p>To be continue. </p>



<p></p>



<p></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/">LLM Chat WebGUI and Fine-Turning on Ampere Altra ARM64 Platform</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Install Stable Diffusion GUI on ARM64 Nvidia RTX platform</title>
		<link>https://blog.richliu.com/2024/02/21/5808/how-to-install-stable-diffusion-gui-on-arm64-nvidia-rtx-platform/</link>
					<comments>https://blog.richliu.com/2024/02/21/5808/how-to-install-stable-diffusion-gui-on-arm64-nvidia-rtx-platform/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 21 Feb 2024 12:11:49 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Altra]]></category>
		<category><![CDATA[ALTRAD8UD]]></category>
		<category><![CDATA[AltraMax]]></category>
		<category><![CDATA[Ampere]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[Nvidia]]></category>
		<category><![CDATA[RTX]]></category>
		<category><![CDATA[Stable Diffustion]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=5808</guid>

					<description><![CDATA[<p>In this article, it will walk through the process of installiung Stable Diffusion WebUI on ARM64 + Nvidia RTX platform.</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/02/21/5808/how-to-install-stable-diffusion-gui-on-arm64-nvidia-rtx-platform/">How to Install Stable Diffusion GUI on ARM64 Nvidia RTX platform</a> appeared first on <a rel="nofollow" href="https://blog.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="1744" height="1177" src="https://blog.richliu.com/wp-content/uploads/2024/02/image-16.png" alt="" class="wp-image-5809" style="aspect-ratio:1.481733220050977;width:284px;height:auto" srcset="https://blog.richliu.com/wp-content/uploads/2024/02/image-16.png 1744w, https://blog.richliu.com/wp-content/uploads/2024/02/image-16-600x405.png 600w, https://blog.richliu.com/wp-content/uploads/2024/02/image-16-768x518.png 768w, https://blog.richliu.com/wp-content/uploads/2024/02/image-16-1536x1037.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/02/image-16-816x551.png 816w" sizes="(max-width: 1744px) 100vw, 1744px" /></figure></div>


<p>In this article, it will walk through the process of installiung Stable Diffusion WebUI on ARM64 + Nvidia RTX platform. <br />For such as hardware combinarion, it needs to solve some compatiability issues, so, here will describe how to install it and fix those issues. </p>



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



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



<p>CPU: Ampere Altra ARM64 CPU<br />Board: AsRock ALTRAD8UD<br />OS: Ubuntu 22.04 </p>



<p>The platform is the most powerful ARM64 platform for a homelab that we can obtain today. There are some server models available, but they come with high-speed cooling fans that are not suitable for home use.</p>



<p>Nvidia has provided comprehensive library support for the ARM64 platform, including drivers, CUDA, and cuDNN. However, despite these efforts, there are still gaps in support. Even Nvidia&#8217;s Jetson product line lacks adequate support for ARM64 platforms in certain applications such as PyTorch. While there exists an individual PyTorch accelerator package for direct download on x64 platforms, the same cannot be said for ARM64 platforms. Although there is technically one package available, its availability is severely limited, rendering it practically useless.</p>



<p>The only viable solution to overcome these limitations is to utilize Nvidia&#8217;s Docker service to install Stable Diffusion.</p>



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



<p>Install Ubuntu 22.04 without selecting the HWE (Hardware Enablement) support. It appears that the current Nvidia driver version has issues, leading to potential soft-lock bugs. A general kernel version (5.15) is preferable for stability.</p>



<p>Next, install the necessary Ubuntu packages.</p>



<pre class="wp-block-preformatted">sudo apt-get install build-essential</pre>



<p>Download <a href="https://www.nvidia.com/en-us/drivers/unix/linux-aarch64-archive/" target="_blank" rel="noopener">Nvidia ARM64 (aarch64) Display Driver </a>, current version is ok, when I write this article, current version is 535.154.05 </p>



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



<p><br />Install Docker by following the Docker guide  <a href="https://docs.docker.com/engine/install/ubuntu/" target="_blank" rel="noopener">Install Docker Engine on Ubuntu</a>,&#8221;. Also provide the necessary installation steps here. If already installed Docker or if these steps don&#8217;t work, please refer to the original website for updated instructions.</p>



<pre class="wp-block-preformatted"># Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release &amp;&amp; echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list &gt; /dev/null
sudo apt-get update</pre>



<pre class="wp-block-preformatted">sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin</pre>



<h3 class="wp-block-heading">Nvidia Container Toolkit</h3>



<p>Follow the instructions for installing the <a href="https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#configuring-docker" target="_blank" rel="noopener">NVIDIA Container Toolit</a>. It can modify the Docker configuration using this toolkit. Alternatively, modifying the daemon.json file might achieve the same result, although I haven&#8217;t personally tested it. Below are the instructions:</p>



<pre class="wp-block-preformatted">curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
  &amp;&amp; curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

sudo sed -i -e '/experimental/ s/^#//g' /etc/apt/sources.list.d/nvidia-container-toolkit.list

sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit

sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker</pre>



<p>It can check the file /etc/docker/daemon.json file, the configuration should be like this.</p>



<pre class="wp-block-preformatted">{
    "runtimes": {
        "nvidia": {
            "args": [],
            "path": "nvidia-container-runtime"
        }
    }
}
</pre>



<h3 class="wp-block-heading">Run Nvidia pytorch docker image </h3>



<p>Following is example command to run the Nvidia pytorch docker image</p>



<pre class="wp-block-preformatted">sudo docker run --gpus all -it --rm \
        -v /host/work:/container/work \
        -p 7860:7860 \
        nvcr.io/nvidia/pytorch:XX.XX-py3
</pre>



<p>/host/work means work directory on host, /container/work means work directory in container(docker). -p 7860 mean gui default port, it needs to forward to host machine. XX.XX means container versiom please see tags to get container version, or this <a href="https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch/tags" target="_blank" rel="noopener">URL</a> . [<a href="https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch" target="_blank" rel="noopener">NGC Pytorch</a>]. Following is example command. </p>



<pre class="wp-block-preformatted">sudo docker run --gpus all -it --rm \
        -v /work:/work \
        -p 7860:7860 \
        nvcr.io/nvidia/pytorch:24.01-py3
</pre>



<h2 class="wp-block-heading">Stable Diffustion WebUI</h2>



<p>First steps clone Stable Diffustion WebUI source code. </p>



<pre class="wp-block-preformatted">git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git</pre>



<p>Then, it needs to modify the settings file. Edit webui.sh, and adjust the parameters to the following numbers.</p>



<pre class="wp-block-preformatted">use_venv=0
can_run_as_root=1</pre>



<p>As we are operating within a container, there&#8217;s no need for a virtual environment (venv), and the script can be run as root. Modify the file webui-user.sh and add COMMANDLINE_ARGS accordingly.</p>



<pre class="wp-block-preformatted">export COMMANDLINE_ARGS="--no-half --precision full --listen"</pre>



<p>or run it directly </p>



<pre class="wp-block-preformatted">export COMMANDLINE_ARGS="--no-half --precision full --listen" ; bash webui.sh</pre>



<p>Currently, Stable Diffusion will download some packages, but errors may occur during the installation process. We&#8217;ll address and fix these errors in the next few steps.</p>



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



<p>Error message :</p>



<pre class="wp-block-preformatted">    if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
  File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
    py_module = importlib.import_module(module_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.10/dist-packages/cv2/typing/__init__.py", line 168, in &lt;module&gt;
    LayerId = cv2.dnn.DictValue
AttributeError: module 'cv2.dnn' has no attribute 'DictValue'
</pre>



<p>Modify file &#8220;/usr/local/lib/python3.10/dist-packages/cv2/typing/__init__.py&#8221;, comment out line 169 like following.[<a href="https://github.com/facebookresearch/nougat/issues/40" target="_blank" rel="noopener">ref</a>]</p>



<pre class="wp-block-preformatted"># LayerId = cv2.dnn.DictValue</pre>



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



<p>Error message:</p>



<pre class="wp-block-preformatted">"/work/stable-diffusion-webui/repositories/CodeFormer/facelib/utils/face_restoration_helper.py", line 7, in &lt;module&gt;
        from facelib.detection import init_detection_model
      File "/work/stable-diffusion-webui/repositories/CodeFormer/facelib/detection/__init__.py", line 11, in &lt;module&gt;
        from .yolov5face.face_detector import YoloDetector
      File "/work/stable-diffusion-webui/repositories/CodeFormer/facelib/detection/yolov5face/face_detector.py", line 20, in &lt;module&gt;
        IS_HIGH_VERSION = tuple(map(int, torch.__version__.split('+')[0].split('.'))) &gt;= (1, 9, 0)
    ValueError: invalid literal for int() with base 10: '0a0'
</pre>



<p>This issue caused by pytorch.<strong>version</strong>&nbsp;will return illegeal number like 2.2.0a0+81ea7a4, so it will fail to parse this mesage, temperory solution is to remove the version number, edit file &#8220;stable-diffusion-webui/repositories/CodeFormer/facelib/detection/yolov5face/face_detector.py&#8221;. and modify line 20, IS_HIGH_VERSION to following version to following:[<a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13766" target="_blank" rel="noopener">ref</a>]</p>



<pre class="wp-block-preformatted">version_string = torch.version.split('+')[0]
version_string = ''.join(filter(str.isdigit, version_string))
IS_HIGH_VERSION = tuple(map(int, version_string.split('.'))) &gt;= (1, 9, 0)</pre>



<p>Now, the Stable Diffusion GUI should be working as well as expected</p>



<p></p>



<p></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/02/21/5808/how-to-install-stable-diffusion-gui-on-arm64-nvidia-rtx-platform/">How to Install Stable Diffusion GUI on ARM64 Nvidia RTX platform</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2024/02/21/5808/how-to-install-stable-diffusion-gui-on-arm64-nvidia-rtx-platform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ARM64 Kubernetes Qemu Metallb Linkerd Numa</title>
		<link>https://blog.richliu.com/2023/09/17/5329/arm64-kubernetes-qemu-metallb-linkerd-numa/</link>
					<comments>https://blog.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://blog.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://blog.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://blog.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://blog.richliu.com/wp-content/uploads/2023/09/image-1.png" alt="" class="wp-image-5330" srcset="https://blog.richliu.com/wp-content/uploads/2023/09/image-1.png 2125w, https://blog.richliu.com/wp-content/uploads/2023/09/image-1-600x333.png 600w, https://blog.richliu.com/wp-content/uploads/2023/09/image-1-768x426.png 768w, https://blog.richliu.com/wp-content/uploads/2023/09/image-1-1536x852.png 1536w, https://blog.richliu.com/wp-content/uploads/2023/09/image-1-2048x1136.png 2048w" sizes="(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://blog.richliu.com/wp-content/uploads/2023/09/image-2.png" alt="" class="wp-image-5338" srcset="https://blog.richliu.com/wp-content/uploads/2023/09/image-2.png 1982w, https://blog.richliu.com/wp-content/uploads/2023/09/image-2-600x259.png 600w, https://blog.richliu.com/wp-content/uploads/2023/09/image-2-768x332.png 768w, https://blog.richliu.com/wp-content/uploads/2023/09/image-2-1536x664.png 1536w" sizes="(max-width: 1982px) 100vw, 1982px" /><figcaption class="wp-element-caption">ref.<br /><a href="https://blog.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://blog.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://blog.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://blog.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://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2023/09/17/5329/arm64-kubernetes-qemu-metallb-linkerd-numa/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux Kernel Install Fail Because Broadcom NetXtreme 100G DKMS Driver Build Failed.</title>
		<link>https://blog.richliu.com/2022/09/27/4830/linux-kernel-install-fail-because-broadcom-netxtreme-100g-dkms-driver-build-failed/</link>
					<comments>https://blog.richliu.com/2022/09/27/4830/linux-kernel-install-fail-because-broadcom-netxtreme-100g-dkms-driver-build-failed/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Tue, 27 Sep 2022 08:14:23 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[broadcom]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Driver]]></category>
		<category><![CDATA[kernel]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4830</guid>

					<description><![CDATA[<p>Environment is CentOS 8, broadcom 100G NetXtreme-E seri [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2022/09/27/4830/linux-kernel-install-fail-because-broadcom-netxtreme-100g-dkms-driver-build-failed/">Linux Kernel Install Fail Because Broadcom NetXtreme 100G DKMS Driver Build Failed.</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Environment is CentOS 8, broadcom 100G NetXtreme-E series driver . <br />Host : Ampere Altra Platform <br /><br />if rebuild the CentOS kernel and there was previous Broadcom nic driver alredy installed, it will trigger dkms to rebuild the driver on current kernel. <br /><br />make install error as following</p>



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



<pre class="wp-block-preformatted">[root@localhost linux-4.18.0-80.11.2.el8_0]# make install                                            [55/2101]
/bin/sh ./arch/arm64/boot/install.sh 4.18.0 \
arch/arm64/boot/Image System.map "/boot"
dkms: running auto installation service for kernel 4.18.0
Deprecated feature: REMAKE_INITRD
Deprecated feature: REMAKE_INITRD
Deprecated feature: REMAKE_INITRD
Sign command: /lib/modules/4.18.0/build/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub                                                               Deprecated feature: REMAKE_INITRD                                                                             
Building module:
Cleaning build area...(bad exit status: 2)
make -j160 KERNELRELEASE=4.18.0 -C /lib/modules/4.18.0/build M=/var/lib/dkms/bnxt_en/1.10.2.221.0.114.0/build
KVER=4.18.0...(bad exit status: 2)
Error! Bad return status for module build on kernel: 4.18.0 (aarch64)
Consult /var/lib/dkms/bnxt_en/1.10.2.221.0.114.0/build/make.log for more information.
Sign command: /lib/modules/4.18.0/build/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub
Deprecated feature: REMAKE_INITRD

Building module:
Cleaning build area...(bad exit status: 2)
make -j160 KERNELRELEASE=4.18.0 -C /lib/modules/4.18.0/build M=/var/lib/dkms/bnxt_re/221.0.114.0/build KVER=4$
18.0 BNXT_EN_INC=/var/lib/dkms/bnxt_re/221.0.114.0/source BNXT_QPLIB_INC=/var/lib/dkms/bnxt_re/221.0.114.0/so$
rce...(bad exit status: 2)
Error! Bad return status for module build on kernel: 4.18.0 (aarch64)
Consult /var/lib/dkms/bnxt_re/221.0.114.0/build/make.log for more information.
 Done.
</pre>



<p>And check the log file &#8220;/var/lib/dkms/bnxt_re/221.0.114.0/build/make.log&#8221;<br /><br />It shows </p>



<pre class="wp-block-preformatted">DKMS make.log for bnxt_en-1.10.2.221.0.114.0 for kernel 4.18.0 (aarch64)
Tue Sep 27 15:41:04 CST 2022
Makefile:603: arch/aarch64/Makefile: No such file or directory
make[2]: *** No rule to make target 'arch/aarch64/Makefile'.  Stop.
</pre>



<p>Seems cannot find the Makefile, that because the drvier cannot locate right Makefile, because the include architecture is arm64, not aarch64 in Linux kernel . <br /><br />By the way, basicly arm64 and aarch64 are the same thing, I don&#8217;t know why it shows aarch64 on kernel architecture and use arm64 as fold name. probably some traditional history. <br /><br />solution is easy, go to the include folder and link arm64 to aarch, DONE! ex:</p>



<pre class="wp-block-preformatted">cd /lib/modules/4.18.0/build/arch
ln -sf arm64 aarch64
</pre>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2022/09/27/4830/linux-kernel-install-fail-because-broadcom-netxtreme-100g-dkms-driver-build-failed/">Linux Kernel Install Fail Because Broadcom NetXtreme 100G DKMS Driver Build Failed.</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2022/09/27/4830/linux-kernel-install-fail-because-broadcom-netxtreme-100g-dkms-driver-build-failed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Build Ampere CentOS Kernel</title>
		<link>https://blog.richliu.com/2022/03/17/4555/build-ampere-centos-kernel/</link>
					<comments>https://blog.richliu.com/2022/03/17/4555/build-ampere-centos-kernel/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 17 Mar 2022 07:44:25 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[kernel]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4555</guid>

					<description><![CDATA[<p>Personal Note Install Necessary Packages Install packag [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2022/03/17/4555/build-ampere-centos-kernel/">Build Ampere CentOS Kernel</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Personal Note</p>



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



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



<p>Install packages, it should have to install other packages like openssl-dev.<br /><br />get  package <a href="https://www.gitdetail.com/repositories/AmpereComputing/developer/646825" target="_blank" rel="noreferrer noopener">ampere-8.3.0-20191025-dynamic-nosysroot-nativetools.tar.xz</a> from Ampere customer connect or <a href="https://www.gitdetail.com/repositories/AmpereComputing/developer/646825" target="_blank" rel="noreferrer noopener">ampere development source web</a>. </p>



<pre class="wp-block-code"><code>yum groupinstall "Development Tools"

yum -y install ncurses-devel
yum -y install hmaccalc zlib-devel binutils-devel elfutils-devel libelf-devel newt-devel python-devel
yum -y install audit-libs-devel numactl-devel pciutils-devel openssl-devel
yum -y install bc bison perl-ExtUtils-Embed.noarch xmlto asciidoc
rpm –ivh kernel-4.18.0-80.11.2.el8.&lt;version>.src.rpm


mkdir -p /opt/amp
tar -xf ampere-8.3.0-20191025-dynamic-nosysroot-nativetools.tar.xz -C /opt/amp
export PATH=/opt/amp/ampere-8.3.0-20191025-dynamic-nosysroot/bin:$PATH;
which gcc
/opt/amp/ampere-8.3.0-20191025/bin/gcc
</code></pre>



<p>if gcc is not in /opt/amp, please check your directory in /opt/amy </p>



<h2 class="wp-block-heading">Build Kernel</h2>



<p>command to build kernel</p>



<pre class="wp-block-preformatted">cd /root/rpmbuild/SOURCES/
tar xvf linux-4.18.0-80.11.2.el8_0.tar.xz
cd linux-4.18.0-80.11.2.el8_0
cp ../kernel-aarch64-emag.config .config
make olddefconfig</pre>



<p>Try build once and make sure everything is ok</p>



<pre class="wp-block-preformatted">make -j `nproc`</pre>



<p>If buiild OK, generate RPM files. </p>



<pre class="wp-block-preformatted">make -j `nproc` rpm-pkg</pre>



<p>if everything is ok, the RPM files will be on /root/rpmbuild/RPMS/aarch64/</p>



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



<pre class="wp-block-preformatted">/root/rpmbuild/RPMS/aarch64
yum localinstall kernel-4.18.0-1.aarch64.rpm kernel-headers-4.18.0-1.aarch64.rpm</pre>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2022/03/17/4555/build-ampere-centos-kernel/">Build Ampere CentOS Kernel</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2022/03/17/4555/build-ampere-centos-kernel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ARM64 Linux Performance Tuning</title>
		<link>https://blog.richliu.com/2021/05/19/4477/arm64-linux-performance-tuning/</link>
					<comments>https://blog.richliu.com/2021/05/19/4477/arm64-linux-performance-tuning/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 19 May 2021 01:54:33 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[performance]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4477</guid>

					<description><![CDATA[<p>This is personal notebook for ARM64 performance tuning. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2021/05/19/4477/arm64-linux-performance-tuning/">ARM64 Linux Performance Tuning</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This is personal notebook for ARM64 performance tuning.</p>



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



<h2 class="wp-block-heading">NVME 4K Write Performance</h2>



<p>Situation: <br />Run fio 4K write on 24 NVME drivers, but some drivers might not get higher IOPS performance</p>



<p>Solution:<br />It should be caused by enable SMMU, so, if doesn&#8217;t use VM, just disable iommu to get better performance<br />Add iommu.passthrough=1</p>



<h2 class="wp-block-heading">General IO performance Tuning </h2>



<p>For high bandwidth card, most time it needs to disable irq_balancing <br />$ systemctl stop irqbalance.service</p>



<h2 class="wp-block-heading">Some Performance Tuning Parameters</h2>



<pre class="wp-block-preformatted">ulimit -s unlimited 
ulimit -l 2097152 
echo 8 | sudo tee /proc/sys/vm/dirty_ratio 
echo 1 | sudo tee /proc/sys/vm/swappiness 
echo 1 | sudo tee /proc/sys/vm/zone_reclaim_mode 
echo 3 | sudo tee /proc/sys/vm/drop_caches 
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space 
echo 0 | sudo tee /proc/sys/kernel/numa_balancing 
echo never > /sys/kernel/mm/transparent_hugepage/enabled 
cpupower frequency-set -g performance 
export MALLOC_CONF=thp:always
 
</pre>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2021/05/19/4477/arm64-linux-performance-tuning/">ARM64 Linux Performance Tuning</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2021/05/19/4477/arm64-linux-performance-tuning/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CentOS8 ARM64/AARCH64 Install Docker</title>
		<link>https://blog.richliu.com/2020/05/18/4273/centos8-arm64-aarch64-install-docker/</link>
					<comments>https://blog.richliu.com/2020/05/18/4273/centos8-arm64-aarch64-install-docker/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 18 May 2020 15:11:17 +0000</pubDate>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[centos8]]></category>
		<category><![CDATA[docker]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4273</guid>

					<description><![CDATA[<p>It&#8217;s not complex to install docker on ARM64 platf [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2020/05/18/4273/centos8-arm64-aarch64-install-docker/">CentOS8 ARM64/AARCH64 Install Docker</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>It&#8217;s not complex to install docker on ARM64 platform and make it work, but it needs a trick</p>



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



<h2 class="wp-block-heading">Remove Packages </h2>



<p>$  sudo yum remove docker-ce docker-ce-cli containerd.io </p>



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



<p>This is most important step, without this, docker&#8217;s install script will fail. </p>



<p>$ sudo dnf install <a href="https://download.docker.com/linux/centos/7/aarch64/stable/Packages/containerd.io-1.2.6-3.3.el7.aarch64.rpm" target="_blank" rel="noopener">https://download.docker.com/linux/centos/7/aarch64/stable/Packages/containerd.io-1.2.6-3.3.el7.aarch64.rpm</a></p>



<h2 class="wp-block-heading">Docker Script</h2>



<p>Get docker script and run it <br />$ curl -fsSL https://get.docker.com -o get-docker.sh <br />$ sudo sh get-docker.sh <br />Add your current username to docker group if not run on root account. <br />$ sudo usermod -aG docker your-user </p>



<h2 class="wp-block-heading">Restart Docker And Enable Firewall </h2>



<p>$  sudo systemctl start docker <br />$  firewall-cmd &#8211;zone=public &#8211;add-masquerade &#8211;permanent <br />$  firewall-cmd &#8211;reload </p>



<p>ref. <br />[1]  https://linuxconfig.org/how-to-install-docker-in-rhel-8 <br />[2]  https://docs.docker.com/engine/install/centos/ <br />[3]  https://serverfault.com/questions/987686/no-network-connectivity-to-from-docker-ce-container-on-centos-8 </p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2020/05/18/4273/centos8-arm64-aarch64-install-docker/">CentOS8 ARM64/AARCH64 Install Docker</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2020/05/18/4273/centos8-arm64-aarch64-install-docker/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ARM64 Centos8/Ubuntu PXE Boot Install on Ubuntu Server</title>
		<link>https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/</link>
					<comments>https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 08 Apr 2020 08:21:38 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[centos8]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[pxe]]></category>
		<category><![CDATA[pxeboot]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4263</guid>

					<description><![CDATA[<p>This document will introduce how to setup a centos PXE  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/">ARM64 Centos8/Ubuntu PXE Boot Install on Ubuntu Server</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This document will introduce how to setup a centos PXE boot environment on ubuntu 18.04 for install centos8 to your ARM64 machine. <br /><br />In this document, it uses CentOS 8 version is 8.1.1911, it might also work on later version if you change file name accordingly .&nbsp;<br /><br />all command in this document we assume you already run with root permission.&nbsp;<br /></p>



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



<h2 class="wp-block-heading">Hardware topology&nbsp;</h2>



<p>[ARM64 CLIENT] &lt;&#8212;&#8212;-&gt; [Server]&nbsp; &lt;&#8212;&#8212;-&gt; Internet&nbsp;</p>



<p>SERVER ethernet ip is 10.0.0.1 , another interface connect to internet.&nbsp;</p>



<p></p>



<h2 class="wp-block-heading">Install necessary packages&nbsp;<br /></h2>



<p>Install TFTP, HTTP and DHCPD Server and rpm2cpio&nbsp;<br /></p>



<p>$ apt install tftpd-hpa apache2 isc-dhcp-server rpm2cpio<br /></p>



<h2 class="wp-block-heading">Modify dhcpd server configuration&nbsp;<br /></h2>



<p>$ vim /etc/dhcp/dhcpd.conf<br /></p>



<p>following is example configuration,it can be changed to fit your environment&nbsp;</p>



<pre class="wp-block-verse">authoritative;
default-lease-time&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 259200;
max-lease-time&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 518400;
option routers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10.0.0.1;
option subnet-mask&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 255.255.255.0;
option domain-name-servers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 168.95.1.1,8.8.8.8;
ddns-update-style &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; interim;
ignore client-updates;
allow booting;
allow bootp;
allow unknown-clients;
server-name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pxis;

subnet 10.0.0.0 netmask 255.255.255.0 {
&nbsp;&nbsp;&nbsp;&nbsp;range 10.0.0.100 10.0.0.200;
&nbsp;&nbsp;&nbsp;&nbsp;option ip-forwarding off;
&nbsp;&nbsp;&nbsp;&nbsp;option subnet-mask&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 255.255.255.0;
&nbsp;&nbsp;&nbsp;&nbsp;next-server 10.0.0.1;
&nbsp;&nbsp;&nbsp;&nbsp;filename "shim.efi";

}</pre>



<h2 class="wp-block-heading">Modify tftpd setting&nbsp;<br /></h2>



<p>$ vim /etc/default/tftpd-hpa<br /></p>



<p>Add &#8211;create to TFTP_OPTIONS and change tftp directory to /tftpboot&nbsp;<br /></p>



<p>following is example configuration file&nbsp;</p>



<pre class="wp-block-preformatted">TFTP_USERNAME="tftp"<br />TFTP_DIRECTORY="/tftpboot"<br />TFTP_ADDRESS=":69"<br />TFTP_OPTIONS="--secure&nbsp; --create"</pre>



<h2 class="wp-block-heading">Restart Service&nbsp;<br /></h2>



<pre class="wp-block-preformatted">mkdir /tftpboot&nbsp;
/etc/init.d/tftpd-hpa restart
/etc/init.d/apache2 restart
/etc/init.d/isc-dhcp-server restart
</pre>



<h2 class="wp-block-heading">Get ARM64 pxeboot file&nbsp;</h2>



<p>some times the shim and grub2-efi would be erase, just visit mirror.centos.org and find new one than download it. </p>



<pre class="wp-block-preformatted">cd /tftpboot&nbsp;
wget http://mirror.centos.org/centos/8-stream/BaseOS/aarch64/os/Packages/shim-aa64-15-15.el8_2.aarch64.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/aarch64/os/Packages/grub2-efi-aa64-2.02-106.el8.aarch64.rpm
rpm2cpio shim-aa64-15-15.el8_2.aarch64.rpm | cpio -dimv
rpm2cpio grub2-efi-aa64-2.02-106.el8.aarch64.rpm | cpio -dimv
cp ./boot/efi/EFI/centos/shim.efi .
cp ./boot/efi/EFI/centos/grubaa64.efi .
chmod +rx *.efi</pre>



<h2 class="wp-block-heading">Configure grub.conf&nbsp;<br /></h2>



<p>$ vim /tftpboot/grub.cfg<br /></p>



<p>Following is grub.conf example&nbsp;</p>



<pre class="wp-block-verse">set timeout=60<br />menuentry 'CentOS' {<br /> &nbsp;linux images/pxeboot/vmlinuz ip=dhcp inst.repo=http://10.0.0.1/centos8/<br />&nbsp;&nbsp;initrd images/pxeboot/initrd.img<br />}</pre>



<p>If your system support secure boot and you want to do it, please replace linux with linuxefi and replace initrd with initrdefi.&nbsp;</p>



<h2 class="wp-block-heading">Get CentOS 8 stream image and copy it to web server&nbsp;</h2>



<pre class="wp-block-preformatted">cd /var/www/html&nbsp;
wget <a href="https://mirror01.idc.hinet.net/centos/8-stream/isos/aarch64/CentOS-Stream-8-aarch64-20211202-dvd1.iso" target="_blank" rel="noopener">http://ftp.twaren.net/Linux/CentOS/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-20220215-dvd1.iso</a>
mkdir disk&nbsp;
mount -o loop CentOS-Stream-8-x86_64-20220215-dvd1.iso disk
cp -a disk centos8&nbsp;
umount disk&nbsp;
rmdir disk

# copy boot file into tftp directory </pre>



<p>cd /tftpboot<br />cp /var/www/html/centos8/images/ . -a<br /></p>



<p>After copy all file into http file directory, it can visit via browser on server with URL <a href="http://10.0.0.1/centos8/">http://10.0.0.1/centos8/</a> to check whether file exist or not.&nbsp;<br /></p>



<h2 class="wp-block-heading">NAT<br /></h2>



<p>Server should support NAT function to forward packet.&nbsp;<br /><br />assume interface connect to internet is wls3 <br />Following is a sample command to enable Linux NAT function which can make client to access internet or intranet .&nbsp;</p>



<p>$ echo 1 &gt; /proc/sys/net/ipv4/ip_forward ==&gt; enable it immediately&nbsp;<br />$ iptables -t nat -A POSTROUTING -o wls3 -j MASQUERADE</p>



<p></p>



<p>Now, you can choose pxeboot on your ARM64 machine. if everything successful, you can see CentOS on your console if everything is ok .&nbsp;<br /></p>



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



<h3 class="wp-block-heading">Stdin: Invalid argument</h3>



<p>My system cannot boot into the Ubuntu install program for an unknown reason. After checking the system, it seems that the issue may be caused by an inability to access internet resources for some reason, even though the DNS and network appear to be fine. An alternative solution is to put the ISO on a website and assign the argument to the parameter. Here is an example using Ubuntu 22.04.</p>



<pre class="wp-block-preformatted">menuentry 'Ubuntu22.04 Net Install' {<br />linux ubuntu2204/vmlinuz ip=dhcp url=http://10.0.0.1/ubuntu-22.04.1-live-server-arm64.iso only-ubiquity<br />initrd ubuntu2204/initrd<br />}</pre>



<h2 class="wp-block-heading">Debug&nbsp;<br /></h2>



<p>Wireshark is your good friend, use it.&nbsp;<br /></p>



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



<p>It can download Ubuntu Netboot images from this url. <br /> <a href="http://cdimage.ubuntu.com/netboot/" target="_blank" rel="noopener">http://cdimage.ubuntu.com/netboot/</a> <br /><br />Choice what you want, for example, url below is Ubuntu 18.04 for ARM64 image<br /> <a href="http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/installer-arm64/current/images/netboot/" target="_blank" rel="noopener">http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/installer-arm64/current/images/netboot/</a> <br />Ubuntu 20.04 Netboot file <br />http://ports.ubuntu.com/ubuntu-ports/dists/focal-updates/main/installer-arm64/current/legacy-images/netboot/netboot.tar.gz</p>



<p><br />Download netboot image to tftp directory, I prefer to put different version to different directory. </p>



<pre class="wp-block-code"><code>$ cd /tftpboot
$ wget http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/installer-arm64/current/images/netboot/netboot.tar.gz
$ mkdir ubuntu1804
$ cd ubuntu1804
$ tar xvf ../netboot.tar.gz</code></pre>



<p>Modify grub.cfg and add Ubuntu option to grub.cfg, save it, now, this server can also provide ubuntu net install</p>



<pre class="wp-block-code"><code>set timeout=60
menuentry 'CentOS8 Install' {
  linux images/pxeboot/vmlinuz ip=dhcp inst.repo=http://10.0.0.1/centos8/
  initrd images/pxeboot/initrd.img
}
menuentry 'Ubuntu18.04 Install' {
  linux ubuntu1804/ubuntu-installer/arm64/linux ip=dhcp
  initrd ubuntu1804/ubuntu-installer/arm64/initrd.gz
}
</code></pre>



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



<p>It can download iso file and use the iso file as install media. <br /><br />in Linux, download Ubuntu 20.04 ARM64 iso file</p>



<pre class="wp-block-preformatted">$ wget https://cdimage.ubuntu.com/releases/20.04/release/ubuntu-20.04.3-live-server-arm64.iso
$ mount -o loop ubuntu-20.04.3-live-server-arm64.iso disk
$ mkdir ubuntu2004
$ cp disk/casper ubuntu2004/ -a 
$ umount disk</pre>



<p>Modify grub.cfg as below (not test)</p>



<pre class="wp-block-preformatted">set timeout=60
menuentry 'CentOS8 Install' {
  linux images/pxeboot/vmlinuz ip=dhcp inst.repo=http://10.0.0.1/centos8/
  initrd images/pxeboot/initrd.img
}
menuentry 'Ubuntu20.04 Install' {
  linux ubuntu2004/casper/vmlinuz ip=dhcp
  initrd ubuntu2004/casper/initrd
}
</pre>



<p>It also can use HWE kernel </p>



<pre class="wp-block-preformatted">menuentry 'Ubuntu20.04 Install' {
  linux ubuntu2004/casper/hwe-vmlinux ip=dhcp
  initrd ubuntu2004/casper/hwe-initrd
}

</pre>



<h2 class="wp-block-heading">Note for GRUB Install Command</h2>



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



<pre class="wp-block-preformatted">svr=10.0.0.1; root=boot/centos8/images/pxeboot
linux (http,$svr)/$root/vmlinuz inst.stage2=http://$svr/boot/centos8 text
initrd (http,$svr)/$root/initrd.img
</pre>



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



<pre class="wp-block-preformatted">svr=192.168.110.254; root=boot/ubuntu2004/casper
iso=ubuntu-20.04.3-live-server-arm64.iso
linux (http,$svr)/$root/vmlinuz url=http://192.168.110.254/boot/$iso only-ubiquity ip=dhcp ---
initrd (http,$svr)/$root/initrd

linux (http,$svr)/$root/hwe-vmlinuz url=http://192.168.110.254/boot/$iso only-ubiquity ip=dhcp ---
initrd (http,$svr)/$root/hwe-initrd

</pre>



<h2 class="wp-block-heading">Fedora 36</h2>



<p>Fedora&#8217;s setting is more closed to CentOS, due to CentOS might be dropped recently, so, moved to Fedora environment is necessary. </p>



<h3 class="wp-block-heading">Get initrd/vmlinux image</h3>



<p>Other parts like CentOS, <br />Download the PXE initrd and vmlinuz image, free.nchc.org.tw is Taiwan local Fedora server, you can replace it with local server. </p>



<pre class="wp-block-preformatted">mkdir -p /tftpboot/f36

cd /tftpboot/f36
wget http://free.nchc.org.tw/fedora/linux/releases/36/Server/aarch64/os/images/pxeboot/initrd.img
wget http://free.nchc.org.tw/fedora/linux/releases/36/Server/aarch64/os/images/pxeboot/vmlinuz

cd /var/www/html
wget http://free.nchc.org.tw/fedora/linux/releases/36/Server/aarch64/iso/Fedora-Server-dvd-aarch64-36-1.5.iso
mkdir disk 
mount -o loop Fedora-Server-dvd-aarch64-36-1.5.iso disk
cp -a disk f36
umount disk</pre>



<h3 class="wp-block-heading">Grub Fedora Setting</h3>



<p>Add following grub entry text into /tftpboot/grub.cfg, thus, it can insert a &#8220;Fedora36&#8221; menu on pxe boot.</p>



<pre class="wp-block-preformatted">menuentry 'Fedora36' {
  linux f36/vmlinuz ip=dhcp inst.repo=http://10.0.0.1/f36/
  initrd f36/initrd.img
}
</pre>



<p>Ref.&nbsp;</p>



<p><a href="https://docs.centos.org/en-US/centos/install-guide/pxe-server/#sect-network-boot-setup-uefi" target="_blank" rel="noopener">https://docs.centos.org/en-US/centos/install-guide/pxe-server/#sect-network-boot-setup-uefi</a><br /><a href="https://docs.centos.org/en-US/8-docs/advanced-install/assembly_preparing-for-a-network-install/" target="_blank" rel="noopener">https://docs.centos.org/en-US/8-docs/advanced-install/assembly_preparing-for-a-network-install/</a><br /><a href="https://forums.opensuse.org/showthread.php/501075-error-cannot-find-commands-linuxefi-or-initrdefi" target="_blank" rel="noopener">https://forums.opensuse.org/showthread.php/501075-error-cannot-find-commands-linuxefi-or-initrdefi</a></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/">ARM64 Centos8/Ubuntu PXE Boot Install on Ubuntu Server</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ARM64 mfpu=neon-fp-armv8 and unrecognized command line option</title>
		<link>https://blog.richliu.com/2020/03/20/4260/arm64-mfpuneon-fp-armv8-and-unrecognized-command-line-option/</link>
					<comments>https://blog.richliu.com/2020/03/20/4260/arm64-mfpuneon-fp-armv8-and-unrecognized-command-line-option/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 20 Mar 2020 09:44:54 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[GCC]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4260</guid>

					<description><![CDATA[<p>又學到一個小知識 原因是因為 -mfpu=neon-fp-armv8 是 arm32 compiler opt [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2020/03/20/4260/arm64-mfpuneon-fp-armv8-and-unrecognized-command-line-option/">ARM64 mfpu=neon-fp-armv8 and unrecognized command line option</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>又學到一個小知識<br /><br />原因是因為 -mfpu=neon-fp-armv8 是 arm32 compiler option ARM64 使用 Linux  ABI 那邊就規範要支援 Floatpoint 和 ASIMD(也就是 neon 的 64bit 版 )</p>



<p>不要用 -mfpu 指令就可以了</p>



<p>ref. <br /><a href="https://lists.linaro.org/pipermail/linaro-toolchain/2016-July/005815.html" target="_blank" rel="noopener">-mfpu=neon-fp-armv8 and unrecognized command line option</a></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2020/03/20/4260/arm64-mfpuneon-fp-armv8-and-unrecognized-command-line-option/">ARM64 mfpu=neon-fp-armv8 and unrecognized command line option</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2020/03/20/4260/arm64-mfpuneon-fp-armv8-and-unrecognized-command-line-option/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Install Kubernetes on ARM64 Ubuntu 18.04 (with QEMU)</title>
		<link>https://blog.richliu.com/2019/09/25/4160/install-kubernetes-on-arm64-ubuntu-18-04/</link>
					<comments>https://blog.richliu.com/2019/09/25/4160/install-kubernetes-on-arm64-ubuntu-18-04/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 25 Sep 2019 03:39:36 +0000</pubDate>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[18.04]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[flannel. qemu]]></category>
		<category><![CDATA[k8s]]></category>
		<category><![CDATA[kubernetes]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[weave]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4160</guid>

					<description><![CDATA[<p>Install Kubernetes on Ubuntu 18.04 is very easy now, bu [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2019/09/25/4160/install-kubernetes-on-arm64-ubuntu-18-04/">Install Kubernetes on ARM64 Ubuntu 18.04 (with QEMU)</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Install Kubernetes on Ubuntu 18.04 is very easy now, but only for x86 platform. If on ARM64 environment, it might have some other problem. <br />Some old article mentioned a lot of information but software version is too old for deploy a new version software. <br /><br />After a lot of time to have research, here is instruction for how to install Kubernetes on ARM64 Ubuntu 18.04</p>



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



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



<p>Hardware : Ampere eMag Server with 128G RAM and 1T storage<br />Kubernetes master and nodes are running in QEMU image, so, we prepared three QEMU  ARM64 ubuntu 18.04 images for kubernetes running. It also can use two VM to run this demo. </p>



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



<p>It can download Ubuntu bionic cloud image from Taiwan mirror site</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>or international mirror site </p>



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



<h4 class="wp-block-heading">Install Necessary Package  </h4>



<p>Run following command to install necessary packages . </p>



<pre class="wp-block-preformatted">apt install -y qemu-system-arm bridge-utils cloud-image-utils git qemu-efi</pre>



<h4 class="wp-block-heading">Increase QEMU image size</h4>



<pre class="wp-block-preformatted">qemu-img resize bionic-server-cloudimg-arm64.img +200G</pre>



<p>Create UEFI bios and nvram for qemu image boot. </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>Copy Image to three spare images </p>



<pre class="wp-block-preformatted">cp flash0.img flash0-1.img
cp flash0.img flash0-2.img 
cp flash0.img flash0-3.img 
cp flash1.img flash1-1.img
cp flash1.img flash1-2.img
cp flash1.img flash1-3.img
cp  bionic-server-cloudimg-arm64.img   bionic-server-cloudimg-arm64-1.img 
cp  bionic-server-cloudimg-arm64.img   bionic-server-cloudimg-arm64-2.img 
cp  bionic-server-cloudimg-arm64.img   bionic-server-cloudimg-arm64-3.img </pre>



<h2 class="wp-block-heading"> Set up bridge and network devices </h2>



<p>

We already install bridge-utils before, now, it should configure bridge devices.

</p>



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



<p> Because there is only one network interface on machine, we should use this interface as bridge device, save text below (name nic-br.sh or what you like) and modify it to fit your environment. <br /></p>



<pre class="wp-block-preformatted">ORIGNIC=enP6p1s0
ip addr flush $ORIGINIC
brctl addbr br0
brctl addif br0 $ORIGINIC
ifconfig br0 up
ifconfig br0 192.168.110.1 netmask 255.255.0.0
route add default gw 192.168.1.1
echo nameserver 8.8.8.8 &gt;&gt; /etc/resolv.conf </pre>



<h2 class="wp-block-heading">Configure Hugepage On Host Site (Option)</h2>



<p>Due to previous research on dpdk runs on ARM64 server, so, configure hugepages here. But not necessary for run k8s environment. <br />You can ignore this part </p>



<h4 class="wp-block-heading"> Configure Line Kernel boot command </h4>



<p> It needs to reserve hugepages memory space for Linux kernel, it reserves 32 pages and each pages 1GB, total 32GB. Please modify /etc/default/grub , and add hugepagesz=1GB hugepages=32 to GRUB_CMDLINE_LINUX, ex: </p>



<pre class="wp-block-preformatted">GRUB_CMDLINE_LINUX="console=tty0 hugepagesz=1GB hugepages=32"</pre>



<p> then run foloowing command to update grub.cfg </p>



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



<h4 class="wp-block-heading"> Mount hugetlbfs by default </h4>



<p>

If wants to use hugepage, it needs to mount hugetlbfs somewhere, we can create a directory, ex: /mnt/hugepages and mount hugetblsfs there by default.

</p>



<pre class="wp-block-preformatted">mkdir -p /mnt/hugepages 
echo "nodev   /mnt/hugepages                  hugetlbfs       defaults,pagesize=1G    0 0 none" &gt;&gt; /etc/fstab </pre>



<p>Now, please reboot to make huagpage works. </p>



<h2 class="wp-block-heading">Running QEMU</h2>



<p>Following is QEMU script, save it (ex: named run-qemu.sh). It can be more simplification, but this script would be more understand what different. </p>



<pre class="wp-block-preformatted">IMAGE1=bionic-server-cloudimg-arm64-1.img
sudo qemu-system-aarch64 -name vm1 \
         -machine virt,gic_version=3,accel=kvm,usb=off \
         -cpu host -m 8192 \
         -uuid d0000000-1111-1111-1111-11111aaaaaaa \
         -smp 12,sockets=1,cores=12,threads=1 \
         -nographic -nodefaults \
         -pflash flash0-1.img -pflash flash1-1.img \
         -drive file=$IMAGE1,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,mac=52:54:00:11:11:11 \
         -mem-path /mnt/hugepages \
         -serial telnet::9001,server,nowait &gt; guest_log-1.txt 2&gt;&gt; guest_log-1.txt &amp;
IMAGE2=bionic-server-cloudimg-arm64-2.img
sudo qemu-system-aarch64 -name vm2 \
         -machine virt,gic_version=3,accel=kvm,usb=off \
         -cpu host -m 8192 \
         -uuid d0000000-2222-2222-2222-22222bbbbbbb \
         -smp 12,sockets=1,cores=12,threads=1 \
         -nographic -nodefaults \
         -pflash flash0-2.img -pflash flash1-2.img \
         -drive file=$IMAGE2,if=none,id=disk2 \
         -device virtio-blk-device,scsi=off,drive=disk2,id=virtio-disk1,bootindex=1 \
         -netdev tap,id=net2,ifname=tap1 \
         -device virtio-net-device,netdev=net2,mac=52:54:00:22:22:22 \
         -mem-path /mnt/hugepages \
         -serial telnet::9002,server,nowait &gt; guest_log-2.txt 2&gt;&gt; guest_log-2.txt &amp;
IMAGE3=bionic-server-cloudimg-arm64-3.img
sudo qemu-system-aarch64 -name vm3 \
         -machine virt,gic_version=3,accel=kvm,usb=off \
         -cpu host -m 8192 \
         -uuid d0000000-3333-3333-3333-33333ccccccc \
         -smp 12,sockets=1,cores=12,threads=1 \
         -nographic -nodefaults \
         -pflash flash0-3.img -pflash flash1-3.img \
         -drive file=$IMAGE3,if=none,id=disk3 \
         -device virtio-blk-device,scsi=off,drive=disk3,id=virtio-disk1,bootindex=1 \
         -netdev tap,id=net3,ifname=tap2 \
         -device virtio-net-device,netdev=net3,mac=52:54:00:33:33:33 \
         -mem-path /mnt/hugepages \
         -serial telnet::9003,server,nowait &gt; guest_log-3.txt 2&gt;&gt; guest_log-3.txt &amp;
sleep 5
brctl addif br0 tap0
brctl addif br0 tap1
brctl addif br0 tap2</pre>



<p>There are some parameters need to understand in QEMU script. <br /><br />-uuid d0000000-1111-1111-1111-11111aaaaaaa \<br /><br />this will assign a unique uuid for each VM, k8s needs different VM run with different uuid and MAC address. <br />It also can use command &#8220;uuidgen&#8221; to generate different uuid for each VM, but here just for debug so assign a &#8220;easy to read&#8221; uuid. <br /><br />-device virtio-net-device,netdev=net3,mac=52:54:00:33:33:33 \<br /><br />Assign a special mac address for VM, because for k8s internal communication, use the same mac address will cause problem, please configure different address before run qemu script. It not easy to modify it after first boot (with cloud image)<br /><br />* Notice, first number for mac address cannot be odd , it would cause problem. <br /><br />-mem-path /mnt/hugepages \<br /><br />Tell VM to use hugepage, if were not configure host with hugepage, please remove this line. </p>



<p>Now,  please run scripts </p>



<pre class="wp-block-preformatted">bash nic-br.sh
bash run-qemu.sh </pre>



<p>Now, it can use telnet to connect each VM&#8217;s console </p>



<pre class="wp-block-preformatted">telnet localhost 9001<br /># or <br />telnet localhost 9002<br /># or <br />telnet localhost 9003</pre>



<p>After system booted/initialed, if you cannot login, please &#8220;killall qemu-system-aarch64&#8221; and follow this article <a href="https://blog.richliu.com/2017/08/31/2165/change-ubuntu-cloud-image-password">Change Ubuntu Cloud Image Password</a> to change all images&#8217;s password.  <br /><br />Somehow, for recent cloud image, it cannot modify password before run qemu script.</p>



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



<p>There are a lot of article to talk about how to install on Ubuntu, I choice one for reference : <a href="https://vitux.com/install-and-deploy-kubernetes-on-ubuntu/" target="_blank" rel="noopener">Install and Deploy Kubernetes on Ubuntu 18.04 LTS</a><br /><br />Below will shortly note install command here. </p>



<h4 class="wp-block-heading">Install Docker and Kubeadm on every node </h4>



<pre class="wp-block-preformatted">sudo apt update 
sudo apt -y upgrade 

# install and enable docker
sudo apt -y install docker.io 
sudo systemctl enable docker 
sudo systemctl start docker 

# 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 install kubeadm -y</pre>



<h4 class="wp-block-heading">Configure Network IP address (Optional)</h4>



<p> Update to you network environment, here we used fix ip address.<br /><br /> Add new record to /etc/hosts   </p>



<pre class="wp-block-preformatted">192.168.110.50     k8s-master
192.168.110.60     k8s-worker-node1
192.168.110.70     k8s-worker-node2</pre>



<p>Please modify /etc/netplan/50-cloud-init.yam, remove dhcp and add fix address. remember, each node has different IP.  Following is only for k8s-master. </p>



<pre class="wp-block-preformatted">network:
     ethernets:
         eth0:
<strong>             addresses: [192.168.110.50/16,]
             gateway4: 192.168.1.1
             nameservers:
                 addresses: [8.8.8.8,8.8.4.4]</strong>
             match:
                 macaddress: '52:54:00:11:11:11'
             set-name: eth0
     version: 2</pre>



<h4 class="wp-block-heading">Configure Host name </h4>



<p>Run following command on master node </p>



<pre class="wp-block-preformatted">sudo hostnamectl set-hostname  k8s-master</pre>



<p> Run following command on other nodes</p>



<pre class="wp-block-preformatted">sudo hostnamectl set-hostname   k8s-worker-node1 
sudo hostnamectl set-hostname   k8s-worker-node2</pre>



<h4 class="wp-block-heading">Disable swap (Option)</h4>



<p>if image is not from cloud image, default Linux enabled swap function, k8s doesn&#8217;t support it, please disable it manually on all nodes and remove swap mount in /etc/fstab. </p>



<pre class="wp-block-preformatted"> sudo swapoff -a </pre>



<h2 class="wp-block-heading">Configure Kubernetes</h2>



<p>Now, we can initial Kubernetes. Run following command</p>



<pre class="wp-block-preformatted"> sudo kubeadm init --pod-network-cidr=10.244.0.0/16 </pre>



<p>wait for few minutes, it will show some result like this </p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="749" src="https://blog.richliu.com/wp-content/uploads/2019/09/image-1024x749.png" alt="" class="wp-image-4172" srcset="https://blog.richliu.com/wp-content/uploads/2019/09/image-1024x749.png 1024w, https://blog.richliu.com/wp-content/uploads/2019/09/image-300x220.png 300w, https://blog.richliu.com/wp-content/uploads/2019/09/image-768x562.png 768w, https://blog.richliu.com/wp-content/uploads/2019/09/image.png 1398w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Run following command to assign current account has right to access k8s. </p>



<pre class="wp-block-preformatted">mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config</pre>



<p>Run this command on another node(k8s-worker-node1 and k8s-worker-node2).</p>



<pre class="wp-block-preformatted">sudo kubeadm join 192.168.110.50:6443 --token 46c1oj.i00vyfyn027pgew9 \
     --discovery-token-ca-cert-hash sha256:ed05198cc603ae009a862477bacef329a9e9a2bedc4a040bc4731e6d5cf4f48e</pre>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="737" src="https://blog.richliu.com/wp-content/uploads/2019/09/image-1-1024x737.png" alt="" class="wp-image-4174" srcset="https://blog.richliu.com/wp-content/uploads/2019/09/image-1-1024x737.png 1024w, https://blog.richliu.com/wp-content/uploads/2019/09/image-1-300x216.png 300w, https://blog.richliu.com/wp-content/uploads/2019/09/image-1-768x552.png 768w, https://blog.richliu.com/wp-content/uploads/2019/09/image-1.png 1204w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Run get nodes command, it will show current status, the master node status is NotReady, but don&#8217;t worry, it will become Ready after add pod and CNI (container networking interface) plugin. </p>



<pre class="wp-block-preformatted">ubuntu@k8s-master:~$ kubectl get nodes
 NAME         STATUS     ROLES    AGE     VERSION
 k8s-master   NotReady   master   3m42s   v1.16.0</pre>



<p>This action is very import on ARM64 k8s platform, in other document, they told you use flannel or some other document told you used old flannel. all of them not work for me. Please instead flannel with weave net. <br />(Ref <a rel="noreferrer noopener" aria-label="Weave Net for NetworkPolicy (opens in a new tab)" href="https://kubernetes.io/docs/tasks/administer-cluster/network-policy-provider/weave-network-policy/" target="_blank">Weave Net for NetworkPolicy</a> and <a rel="noreferrer noopener" aria-label="CoreDNS is not starting on Ubuntu 18.04.Bionic Beaver #980 (opens in a new tab)" href="https://github.com/kubernetes/kubeadm/issues/980" target="_blank">CoreDNS is not starting on Ubuntu 18.04.Bionic Beaver #980</a>)<br />Run following command to install weave net </p>



<pre class="wp-block-preformatted">kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"</pre>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="232" src="https://blog.richliu.com/wp-content/uploads/2019/09/image-2-1024x232.png" alt="" class="wp-image-4175" srcset="https://blog.richliu.com/wp-content/uploads/2019/09/image-2-1024x232.png 1024w, https://blog.richliu.com/wp-content/uploads/2019/09/image-2-300x68.png 300w, https://blog.richliu.com/wp-content/uploads/2019/09/image-2-768x174.png 768w, https://blog.richliu.com/wp-content/uploads/2019/09/image-2.png 1397w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p> Use the following command to view the status of the network:</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="330" src="https://blog.richliu.com/wp-content/uploads/2019/09/image-3-1024x330.png" alt="" class="wp-image-4176" srcset="https://blog.richliu.com/wp-content/uploads/2019/09/image-3-1024x330.png 1024w, https://blog.richliu.com/wp-content/uploads/2019/09/image-3-300x97.png 300w, https://blog.richliu.com/wp-content/uploads/2019/09/image-3-768x248.png 768w, https://blog.richliu.com/wp-content/uploads/2019/09/image-3-620x200.png 620w, https://blog.richliu.com/wp-content/uploads/2019/09/image-3.png 1398w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p> Get nodes again. </p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="142" src="https://blog.richliu.com/wp-content/uploads/2019/09/image-4-1024x142.png" alt="" class="wp-image-4177" srcset="https://blog.richliu.com/wp-content/uploads/2019/09/image-4-1024x142.png 1024w, https://blog.richliu.com/wp-content/uploads/2019/09/image-4-300x42.png 300w, https://blog.richliu.com/wp-content/uploads/2019/09/image-4-768x107.png 768w, https://blog.richliu.com/wp-content/uploads/2019/09/image-4.png 1395w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Great!! it works. </p>



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



<p>If you think steps above are too complex and you would like to only run k8s on one machine, microk8s is a good friend for you, can run on ARM64 and very easy to use, just run command </p>



<p>sudo snap install microk8s</p>



<p>And just add a prefix &#8220;microk8s.&#8221; before k8s command, ex:</p>



<pre class="wp-block-preformatted">microk8s.kubectl get nodes</pre>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="854" height="133" src="https://blog.richliu.com/wp-content/uploads/2019/09/image-5.png" alt="" class="wp-image-4178" srcset="https://blog.richliu.com/wp-content/uploads/2019/09/image-5.png 854w, https://blog.richliu.com/wp-content/uploads/2019/09/image-5-300x47.png 300w, https://blog.richliu.com/wp-content/uploads/2019/09/image-5-768x120.png 768w" sizes="(max-width: 854px) 100vw, 854px" /></figure>



<p>See, it&#8217;s very easy to use. right?</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2019/09/25/4160/install-kubernetes-on-arm64-ubuntu-18-04/">Install Kubernetes on ARM64 Ubuntu 18.04 (with QEMU)</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2019/09/25/4160/install-kubernetes-on-arm64-ubuntu-18-04/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntu 18.04 ARM64 DPDK in VM (QEMU)</title>
		<link>https://blog.richliu.com/2019/08/19/4057/ubuntu-18-04-arm64-dpdk-in-vm-qemu/</link>
					<comments>https://blog.richliu.com/2019/08/19/4057/ubuntu-18-04-arm64-dpdk-in-vm-qemu/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 19 Aug 2019 08:17:56 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[18.04]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[dpdk]]></category>
		<category><![CDATA[hugepages]]></category>
		<category><![CDATA[l3fwd]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4057</guid>

					<description><![CDATA[<p>DPDK is a very popular infrastructure in high speed pac [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2019/08/19/4057/ubuntu-18-04-arm64-dpdk-in-vm-qemu/">Ubuntu 18.04 ARM64 DPDK in VM (QEMU)</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>DPDK is a very popular infrastructure in high speed packet process domain, some applications will used the same architecture to process packet, like EPC. <br /><br />For Ubuntu 18.04, it used dpdk 17.11, it not good for some other application like dpdk pktgen, but enough for testpmd and l3fwd test. here is some personal note for setup whole environment. </p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://blog.richliu.com/wp-content/uploads/2019/08/image-3.png" alt="" class="wp-image-4076" width="363" height="257" srcset="https://blog.richliu.com/wp-content/uploads/2019/08/image-3.png 634w, https://blog.richliu.com/wp-content/uploads/2019/08/image-3-300x213.png 300w" sizes="(max-width: 363px) 100vw, 363px" /><figcaption>DPDK in QEMU archeticture</figcaption></figure>



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



<p>Hardware : Ampere eMag Server with 128GB Memory <br />                      Network Card: Intel i210 Gigabit NIC Card * 2 <br /><br />HOST means commands and instructions on host machines <br />VM means commands and instructions inside VM</p>



<h2 class="wp-block-heading">Prepare Environment</h2>



<h4 class="wp-block-heading">Apt source</h4>



<p>First, please add deb-src to your database, edit file /etc/apt/source.list and removed all &#8220;#&#8221; before deb-src, then, run follow commands to update apt database (suppose all commands run with sudo or root in this article)</p>



<pre class="wp-block-preformatted">sed -i 's/# deb-src/deb-src/g' sources.list
apt update</pre>



<h4 class="wp-block-heading">Install Packages</h4>



<p>It needs to install relative packages in host </p>



<pre class="wp-block-preformatted">sudo apt install -y dpdk dpdk-dev dpdk-doc </pre>



<p>Only needs to install on HOST.</p>



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



<p>It will install all necessary dpdk packages in host.</p>



<h4 class="wp-block-heading">Preload Module</h4>



<p>It needs to preload vfio-pci modules by default, run following command</p>



<pre class="wp-block-preformatted">echo "vfio-pci" &gt;&gt; /etc/modules</pre>



<h4 class="wp-block-heading">Configure Line Kernel boot command</h4>



<p>It needs to reserve hugepages memory space for Linux kernel, it reserves 32 pages and each pages 1GB, total 32GB. Please modify  /etc/default/grub , and  add hugepagesz=1GB hugepages=32 to GRUB_CMDLINE_LINUX, ex:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>GRUB_CMDLINE_LINUX=&#8221;console=tty0 hugepagesz=1GB hugepages=32&#8243;</p></blockquote>



<p>then run foloowing command to update grub.cfg</p>



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



<p>Mount hugetlbfs by default</p>



<p>If wants to use hugepage, it needs to mount hugetlbfs somewhere, we can create a directory, ex: /mnt/hugepages and mount hugetblsfs there by default. </p>



<pre class="wp-block-preformatted">mkdir -p /mnt/hugepages
echo "nodev   /mnt/hugepages                  hugetlbfs       defaults,pagesize=1G    0 0 none" &gt;&gt; /etc/fstab</pre>



<h2 class="wp-block-heading">Bind Network Card for DPDK</h2>



<p>It wants to let DPDK use current network card, it needs to bind the network card with dpdk. dpdk-devbind command is a useful command. <br />List current command </p>



<pre class="wp-block-preformatted"> $ dpdk-devbind --status
 Network devices using kernel driver
 0001:01:00.0 'I210 Gigabit Network Connection 1533' if=enP1p1s0 drv=igb unused=vfio-pci
 0002:01:00.0 'I210 Gigabit Network Connection 1533' if=enP2p1s0 drv=igb unused=vfio-pci
 0006:01:00.0 'I210 Gigabit Network Connection 1533' if=enP6p1s0 drv=igb unused=vfio-pci <em>Active</em> </pre>



<p>There are three network card in the machine, we would like to bind 1:1:0.0 and 2:1:0.0 to vfio-pci driver. please used following command to bind those network cards. </p>



<pre class="wp-block-preformatted">dpdk-devbind -b vfio-pci 0001:01:00.0 0002:01:00.0</pre>



<p>and check status again</p>



<pre class="wp-block-preformatted"> $ dpdk-devbind --status

Network devices using DPDK-compatible driver
============================================
0001:01:00.0 'I210 Gigabit Network Connection 1533' drv=vfio-pci unused=igb
0002:01:00.0 'I210 Gigabit Network Connection 1533' drv=vfio-pci unused=igb

Network devices using kernel driver
============================================
0006:01:00.0 'I210 Gigabit Network Connection 1533' if=enP6p1s0 drv=igb unused=vfio-pci <em>Active</em> </pre>



<p>Both network cards would be under  Network devices using DPDK-compatible driver  . </p>



<h2 class="wp-block-heading">Prepare QEMU environment </h2>



<h4 class="wp-block-heading">Set up bridge devices  </h4>



<p>We already install bridge-utils before, now, it should configure bridge devices. </p>



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



<p>Because there is only one network interface on machine, we should use this interface as bridge device, save text below and modify it to fit your environment. </p>



<pre class="wp-block-preformatted"> ORIGNIC=enP6p1s0

 ip addr flush enP6p1s0


 brctl addbr br0
 brctl addif br0 enP6p1s0
 ifconfig br0 up
 ifconfig br0 192.168.110.1 netmask 255.255.0.0
 route add default gw 192.168.1.1


 echo nameserver 8.8.8.8 >> /etc/resolv.conf </pre>



<p>Run script, command brctl show will show how whether it configure property or not. </p>



<h2 class="wp-block-heading">Prepare QEMU image</h2>



<p>Ubuntu 18.04 cloud image is here</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>and please refer this article to change cloud image&#8217;s password <br />Change Ubuntu Cloud Image Password, before use it, don&#8217;t forget to increase cloud image size. 20G is enough for test.</p>



<pre class="wp-block-preformatted">qemu-img resize bionic-server-cloudimg-arm64.img +20G</pre>



<p>Next step is to create bios and nvram for qemu image boot. </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>



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



<p>Here is qemu command, save text below and run it </p>



<pre class="wp-block-preformatted"> IMAGE=bionic-server-cloudimg-arm64.img
 sudo qemu-system-aarch64 -name vm1 \
         -machine virt,gic_version=3,accel=kvm,usb=off \
         -cpu host -m 8192 \
         -smp 12,sockets=1,cores=12,threads=1 \
         -nographic -nodefaults \
         -pflash flash0.img -pflash flash1.img \
         -device vfio-pci,host=0001:01:00.0 \
         -device vfio-pci,host=0002:01:00.0 \
         -drive file=$IMAGE,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 \
         -mem-path /mnt/hugepages \
         -serial telnet::9001,server,nowait > guest1_log.txt 2>> guest1_log.txt &amp;
 sleep 5
 brctl addif br0 tap0 </pre>



<p>-m 8192 : use 8G RAM for VM<br />&#8211;mem-path will use /mnt/hugepages for VM memory<br /><br />it will create a network device tap0 for bridge device interface between VM and host.  and create a telnet server on port 9001, it can use &#8220;telnet 9001&#8221; to get console, I would like to suggest to use ssh if it can access console. </p>



<h2 class="wp-block-heading">Remove cloudinit service</h2>



<p>it needs to remove cloud-initramfs-copymods, it will copy modules from ramdisk to harddriver, and cloud-init, it&#8217;s for some cloud service like aws(?)<br /><br />removed them would help system runs better. </p>



<pre class="wp-block-preformatted">apt remove cloud-initramfs-copymods cloud-init </pre>



<h2 class="wp-block-heading">Disable Services</h2>



<p>After boot, it needs to disable some default service to improve speed, here is some services can be disabled. (needs run those command with root)</p>



<pre class="wp-block-preformatted">systemctl disable ufw
systemctl disable lxcfs
systemctl disable atd
systemctl disable cron
systemctl disable irqbalance
systemctl disable apparmor
systemctl disable apport
systemctl disable ebtables
systemctl disable grub-common
systemctl disable unattended-upgrades
systemctl disable iscsid</pre>



<p>Most import service is irqbalance, without disable it, performance will be drop down. <br /><br />Now, it can reboot VM now. </p>



<h2 class="wp-block-heading">Prepare QEMU environment </h2>



<p>Prepare QEMU environment and prepare host almost the same, only differences are</p>



<ol class="wp-block-list"><li>in QEMU, apt install doesn&#8217;t needs to install qemu-efi and bridge-utils</li><li>in QEMU, before call dpdk-devbind command, it needs to configure enable_unsafe_noiommu_mode for ARM64 platform </li><li>Hugepage size is different , in HOST it uses 32G, in VM we uses 4G</li></ol>



<p>Enable unsafe noiommu </p>



<pre class="wp-block-preformatted">echo 1 &gt; /sys/module/vfio/parameters/enable_unsafe_*</pre>



<p> To permanently enable the no-IOMMU mode, add it to modprobe.d: (<a href="https://dpdk-guide.gitlab.io/dpdk-guide/setup/binding.html" target="_blank" rel="noopener">ref</a>) </p>



<pre class="wp-block-preformatted">echo "options vfio enable_unsafe_noiommu_mode=1" &gt; /etc/modprobe.d/vfio-noiommu.conf</pre>



<p>It also needs to reserve hugepages memory space for Linux kernel for VM, it reserves 4 pages and each pages 1GB, total 4GB. Please modify  /etc/default/grub , and  add hugepagesz=1GB hugepages=4 to GRUB_CMDLINE_LINUX, ex:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>GRUB_CMDLINE_LINUX=&#8221;console=tty0 hugepagesz=1GB hugepages=4&#8243;</p></blockquote>



<p>then run foloowing command to update grub.cfg</p>



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



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



<p>Before run l3fwd, we need to recompile it. </p>



<pre class="wp-block-preformatted">. /usr/share/dpdk/dpdk-sdk-env.sh
make -C /usr/share/dpdk/examples/l3fwd</pre>



<p>Bind network interface</p>



<pre class="wp-block-preformatted">dpdk-devbind -b vfio-pci  enp0s1
dpdk-devbind -b vfio-pci  enp0s2</pre>



<p>Run l3fwd example</p>



<pre class="wp-block-preformatted">cd /usr/share/dpdk/examples/l3fwd/build
./l3fwd -c 1 -- -p 0x3 --config="(0,0,0),(1,0,0)"</pre>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="639" src="https://blog.richliu.com/wp-content/uploads/2019/08/image-1024x639.png" alt="" class="wp-image-4072" srcset="https://blog.richliu.com/wp-content/uploads/2019/08/image-1024x639.png 1024w, https://blog.richliu.com/wp-content/uploads/2019/08/image-300x187.png 300w, https://blog.richliu.com/wp-content/uploads/2019/08/image-768x479.png 768w, https://blog.richliu.com/wp-content/uploads/2019/08/image.png 1440w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Multi Queue example</p>



<pre class="wp-block-preformatted">./l3fwd -l 1,2,3,4 -n 4 -- -p 0x3 --config="(0,0,1),(1,0,2),(0,1,3),(1,1,4)"</pre>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="715" src="https://blog.richliu.com/wp-content/uploads/2019/08/image-1-1024x715.png" alt="" class="wp-image-4073" srcset="https://blog.richliu.com/wp-content/uploads/2019/08/image-1-1024x715.png 1024w, https://blog.richliu.com/wp-content/uploads/2019/08/image-1-300x209.png 300w, https://blog.richliu.com/wp-content/uploads/2019/08/image-1-768x536.png 768w, https://blog.richliu.com/wp-content/uploads/2019/08/image-1.png 1438w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



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



<p>There is good tool to get hugepage information </p>



<pre class="wp-block-preformatted">apt install hugepages
hugeadm --pool-list</pre>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="865" height="130" src="https://blog.richliu.com/wp-content/uploads/2019/08/image-2.png" alt="" class="wp-image-4074" srcset="https://blog.richliu.com/wp-content/uploads/2019/08/image-2.png 865w, https://blog.richliu.com/wp-content/uploads/2019/08/image-2-300x45.png 300w, https://blog.richliu.com/wp-content/uploads/2019/08/image-2-768x115.png 768w" sizes="(max-width: 865px) 100vw, 865px" /></figure>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2019/08/19/4057/ubuntu-18-04-arm64-dpdk-in-vm-qemu/">Ubuntu 18.04 ARM64 DPDK in VM (QEMU)</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2019/08/19/4057/ubuntu-18-04-arm64-dpdk-in-vm-qemu/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>QEMU Run x86_64/AMD64 VM on ARM64/AARCH64</title>
		<link>https://blog.richliu.com/2019/08/02/4045/qemu-run-x86_64-on-arm64-server-command/</link>
					<comments>https://blog.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://blog.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://blog.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://blog.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://blog.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://blog.richliu.com/2017/08/31/2165/change-ubuntu-cloud-image-password">Change Ubuntu Cloud Image Password</a><br /><a href="https://blog.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://blog.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://blog.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://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.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>unsupported configuration: CPU mode &#8216;host-model&#8217; for aarch64 kvm domain on aarch64 host is not supported by hypervisor</title>
		<link>https://blog.richliu.com/2017/10/18/2189/unsupported-configuration-cpu-mode-host-model-for-aarch64-kvm-domain-on-aarch64-host-is-not-supported-by-hypervisor/</link>
					<comments>https://blog.richliu.com/2017/10/18/2189/unsupported-configuration-cpu-mode-host-model-for-aarch64-kvm-domain-on-aarch64-host-is-not-supported-by-hypervisor/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 18 Oct 2017 02:33:36 +0000</pubDate>
				<category><![CDATA[OpenStack]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[host-model]]></category>
		<category><![CDATA[ocata]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=2189</guid>

					<description><![CDATA[<p>應該改 nova.conf 將 [libvirt] 內的 cpu_mode 改成 host-passthrou [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2017/10/18/2189/unsupported-configuration-cpu-mode-host-model-for-aarch64-kvm-domain-on-aarch64-host-is-not-supported-by-hypervisor/">unsupported configuration: CPU mode &#8216;host-model&#8217; for aarch64 kvm domain on aarch64 host is not supported by hypervisor</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>應該改 nova.conf<br />
將 [libvirt] 內的<br />
cpu_mode 改成 host-passthrough</p>
<p>應該只有影響 ocata </p>
<p>Ref.<br />
<a href="https://docs.openstack.org/juno/config-reference/content/kvm.html" rel="noopener" target="_blank">OpenStack KVM</a></p>
<p><a href="https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1673467" rel="noopener" target="_blank">[ocata] unsupported configuration: CPU mode &#8216;host-model&#8217; for aarch64 kvm domain on aarch64 host is not supported by hypervisor</a></p>
<p>程式解法<br />
<a href="https://git.openstack.org/cgit/openstack/charm-nova-compute/commit/?id=b5d9b18c0afd06b721d78bced96b4c6c19f77834" rel="noopener" target="_blank">aarch64: set default cpu_mode to host-passthrough</a></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2017/10/18/2189/unsupported-configuration-cpu-mode-host-model-for-aarch64-kvm-domain-on-aarch64-host-is-not-supported-by-hypervisor/">unsupported configuration: CPU mode &#8216;host-model&#8217; for aarch64 kvm domain on aarch64 host is not supported by hypervisor</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2017/10/18/2189/unsupported-configuration-cpu-mode-host-model-for-aarch64-kvm-domain-on-aarch64-host-is-not-supported-by-hypervisor/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>No valid host was found. There are not enough hosts available</title>
		<link>https://blog.richliu.com/2017/08/03/2157/no-valid-host-was-found-there-are-not-enough-hosts-available/</link>
					<comments>https://blog.richliu.com/2017/08/03/2157/no-valid-host-was-found-there-are-not-enough-hosts-available/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 03 Aug 2017 00:33:55 +0000</pubDate>
				<category><![CDATA[OpenStack]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[libvirt]]></category>
		<category><![CDATA[openstack]]></category>
		<category><![CDATA[uefi]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=2157</guid>

					<description><![CDATA[<p>OpenStack Horization error message no valid host was fo [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2017/08/03/2157/no-valid-host-was-found-there-are-not-enough-hosts-available/">No valid host was found. There are not enough hosts available</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>OpenStack Horization error message<br />
<span id="more-2157"></span></p>
<pre lang="text">
no valid host was found. There are not enough hosts available.
Code
500
Details
File "/usr/lib/python2.7/dist-packages/nova/conductor/manager.py", 
line 526, in build_instances context, request_spec, filter_properties) File "/usr/lib/python2.7/dist-packages/nova/conductor/manager.py", 
line 597, in _schedule_instances hosts = self.scheduler_client.select_destinations(context, spec_obj) File "/usr/lib/python2.7/dist-packages/nova/scheduler/utils.py", 
line 371, in wrapped return func(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/nova/scheduler/client/__init__.py", 
line 51, in select_destinations return self.queryclient.select_destinations(context, spec_obj) File "/usr/lib/python2.7/dist-packages/nova/scheduler/client/__init__.py", 
line 37, in __run_method return getattr(self.instance, __name)(*args, **kwargs) 
File "/usr/lib/python2.7/dist-packages/nova/scheduler/client/query.py", 
line 32, in select_destinations return self.scheduler_rpcapi.select_destinations(context, spec_obj) 
File "/usr/lib/python2.7/dist-packages/nova/scheduler/rpcapi.py", 
line 129, in select_destinations return cctxt.call(ctxt, 'select_destinations', **msg_args) 
File "/usr/lib/python2.7/dist-packages/oslo_messaging/rpc/client.py", 
line 169, in call retry=self.retry) 
File "/usr/lib/python2.7/dist-packages/oslo_messaging/transport.py", 
line 97, in _send timeout=timeout, retry=retry) 
File "/usr/lib/python2.7/dist-packages/oslo_messaging/_drivers/amqpdriver.py", 
line 458, in send retry=retry) File "/usr/lib/python2.7/dist-packages/oslo_messaging/_drivers/amqpdriver.py", 
line 449, in _send raise result
</pre>
<p>Possible reason</p>
<p>* if using cloud uefi image, it needs to install qemu-efi package in computer node, don&#8217;t know why it won&#8217;t install it automatically .<br />
   $ apt install qemu-efi<br />
* when add new UEFI image, it needs to add new meta data parameter in Horization<br />
   hw_firmware_type=uefi</p>
<p>if see </p>
<pre lang="text">
2017-08-01 14:02:13.612 2409 ERROR nova.compute.manager [instance: b334f0b3-ca9a-4f9a-b488-532dce00265a] libvirtError: unsupported configuration: logfile not supported in this QEMU binary
2017-08-01 14:02:13.612 2409 ERROR nova.compute.manager [instance: b334f0b3-ca9a-4f9a-b488-532dce00265a]
# Use the "logd" backend for handling stdout/stderr from QEMU processes.
</pre>
<p>Reason<br />
* Libvirt later version support new function, logd, it&#8217;s a new console log function, but ARM64 doesn&#8217;t support it. workaround solution is to disable it</p>
<p>Edit file /usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py, find </p>
<pre lang="text">
MIN_LIBVIRT_VIRTLOGD = (1, 3, 3)
MIN_QEMU_VIRTLOGD = (2, 7, 0)
</pre>
<p>Replaced it with</p>
<pre lang="text">
MIN_LIBVIRT_VIRTLOGD = (9, 9, 9)
MIN_QEMU_VIRTLOGD = (9, 9, 9)
</pre>
<p>it can avoid to call libvirt logd function. </p>
<p>rm -f /usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.pyc, make sure it will call .py<br />
then, reboot service (or system)</p>
<p>Ref.<br />
http://dozencloud.org/ </p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2017/08/03/2157/no-valid-host-was-found-there-are-not-enough-hosts-available/">No valid host was found. There are not enough hosts available</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2017/08/03/2157/no-valid-host-was-found-there-are-not-enough-hosts-available/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>aarch64/ARM64 virt-install 啟動方法</title>
		<link>https://blog.richliu.com/2017/01/05/2064/aarch64arm64-virt-install-%e5%95%9f%e5%8b%95%e6%96%b9%e6%b3%95/</link>
					<comments>https://blog.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://blog.richliu.com/?p=2064</guid>

					<description><![CDATA[<p>雖然 ubuntu 有好用的 uvttool-libvirt 可以管理 cloud image , 但是似乎在 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.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://blog.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://blog.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://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.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>
