{"componentChunkName":"component---src-templates-post-template-js","path":"/note-raspi4-connects-wifi-en","result":{"data":{"markdownRemark":{"id":"a9aa16af-e66d-5c6b-998b-5d76de6aeed0","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/note-raspi4-connects-wifi\">original page</a>.</p>\n</blockquote>\n<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p>Hello.<br>\nIt has been about half a year since my last update.</p>\n<p>I bought this Raspberry Pi 4 during Amazon’s Cyber Monday sale last week.</p>\n<p><a href=\"https://www.amazon.co.jp/gp/product/B082VVJCPT/ref=as_li_ss_tl?ie=UTF8&#x26;psc=1&#x26;linkCode=sl1&#x26;tag=kashiwabayu0c-22&#x26;linkId=2f544675d0042c47ccf524f3898b81c6&#x26;language=ja_JP\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Amazon.co.jp: LABISTS Raspberry Pi 4 4GB Kit (with technical conformity mark)</a></p>\n<p>This Raspberry Pi 4 has <strong>4GB of RAM</strong> and <strong>can connect to Wi-Fi and even run Ubuntu Desktop</strong>, so I was excitedly setting it up when I ran into <strong>a problem where <code class=\"language-text\">netplan apply</code> failed</strong>.<br>\nAs it turned out, <strong>the cause was a bug in <code class=\"language-text\">netplan.io</code> included in the Ubuntu Server 20.04.1 ISO downloaded from the official site, and the problem was resolved by connecting with wired networking once and performing an update.</strong></p>\n<p>In this article, I will summarize <strong>the steps to install Ubuntu Server 20.04.1 on a Raspberry Pi 4 and connect it to Wi-Fi, including the troubleshooting above</strong> as a note.</p>\n<h2 id=\"download-the-os-image-and-image-writer-for-the-raspberry-pi-4\" style=\"position:relative;\"><a href=\"#download-the-os-image-and-image-writer-for-the-raspberry-pi-4\" aria-label=\"download the os image and image writer for the raspberry pi 4 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Download the OS image and image writer for the Raspberry Pi 4</h2>\n<p>I downloaded the OS image for the Raspberry Pi 4 from the official page below.<br>\nAt the time of writing, the recommended version was Ubuntu Server 20.04.1 LTS, so I downloaded that.</p>\n<p><a href=\"https://ubuntu.com/download/raspberry-pi\" target=\"_blank\" rel=\"noopener noreferrer\">Install Ubuntu on a Raspberry Pi 2, 3 or 4 | Ubuntu</a></p>\n<p>By the way, choose the OS bitness according to the Raspberry Pi you are installing it on.<br>\nThe product I bought is a Raspberry Pi 4 Model B, and it seems to use a CPU called “BCM2711.”</p>\n<p><a href=\"https://www.amazon.co.jp/gp/product/B082VVJCPT/ref=as_li_ss_tl?ie=UTF8&#x26;psc=1&#x26;linkCode=sl1&#x26;tag=kashiwabayu0c-22&#x26;linkId=2f544675d0042c47ccf524f3898b81c6&#x26;language=ja_JP\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Amazon.co.jp: LABISTS Raspberry Pi 4 4GB Kit (with technical conformity mark)</a></p>\n<p>Details about “BCM2711” are also described in the following document.<br>\n<a href=\"https://github.com/raspberrypi/documentation/tree/master/hardware/raspberrypi/bcm2711\" target=\"_blank\" rel=\"noopener noreferrer\">documentation/hardware/raspberrypi/bcm2711 at master · raspberrypi/documentation</a></p>\n<p>From the explanation there, you can see that it is a 64-bit CPU with ARM cores.<br>\nBecause of that, I think the 32-bit version would probably work too, but this time I decided to install the 64-bit version.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">The ARM cores can run at up to 1.5GHz, making the Pi4 about 50% faster than the Raspberry Pi 3B+.\nThe new VideoCoreVI3D unit can now run at up to 500MHz.\nThe ARM cores are 64-bit, and although the VideoCore is 32-bit, there is a new memory management unit.\nThis means it can access more memory than previous versions.</code></pre></div>\n<p>Reference: <a href=\"https://github.com/raspberrypi/documentation/tree/master/hardware/raspberrypi/bcm2711\" target=\"_blank\" rel=\"noopener noreferrer\">documentation/hardware/raspberrypi/bcm2711 at master · raspberrypi/documentation</a></p>\n<h2 id=\"install-the-official-raspberry-pi-image-writer\" style=\"position:relative;\"><a href=\"#install-the-official-raspberry-pi-image-writer\" aria-label=\"install the official raspberry pi image writer permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Install the official Raspberry Pi image writer</h2>\n<p>Next, install an image writer to write the downloaded OS onto a bootable SD card.</p>\n<p><strong>The image writer provided by the Raspberry Pi Foundation is simple and lightweight, so I recommend it.</strong><br>\nPrograms for Linux/Mac OS/Windows/Chrome OS can be downloaded from the link below.</p>\n<p><a href=\"https://www.raspberrypi.org/documentation/installation/installing-images/\" target=\"_blank\" rel=\"noopener noreferrer\">Installing operating system images - Raspberry Pi Documentation</a></p>\n<p>Once the installation completes successfully, you will see a screen like this, where you can specify the write destination and the OS image you downloaded earlier.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/87e13dc5cd936edc0bad1f5234f68be7/0b533/image.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.66666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAARlAAAEZQAGA43XUAAACbElEQVQ4y3WQS0wTURSGZ6kxIWp88GgpSExcSHSNxoAIpaVNiNGFbk1cQowmJqJh4w6jG23ckLiQxKglaETKSOlrpmKMWqAtltKilo20htLY10zD77kzLU5svcmX89//nnvuOZf7mUgglUohnU7jF8VsNgtJliFJUhkZytqGxvtLsVjcIZfPgyuVSpCpQAVtskzFcoUcJj4+h2Npquq8Fpz2BS15ek2mx1LJDVxtP44Raz/yknpWKBSquqvA/W+MyspsbeFBuwVjpisosbnZ9NvbSk7tDum1f5EoORQMIr4aw/r6OkSPF4uBAJIbSYSDIazF4yjRdxTz1Xc59uUVSuXI+nB6PXhmf4kn408xbn+ByekpvOEdcPsFLIRDSo5cAy4dWsVWOAYW00tRlVAM+dUEctEfyCzH8Xt5DdnIN0XnoglkV76r+aFYFZzQYoXncC98FOdPXML8ycvwNVvgJs/TYITnYA/EYxcgHB2A+8A5xRMMFogG6w5CGR/5nKvuDGJ3x5ChzlL8PFKzHxS9MmxDdOQxNsUFJB1+JKdFbL5fxNdr9/G67hReNXbDXt+JifouTBJ8Qw98jSZwrIPAxZuI3LYhPDSK8OAoVu7Y8HngOr6cv4HIrYeqP3QPkeFH+GQeBH+oGzM6IxxNvQozxJyuDz6dGZxXb4Zrbyecuzrg3HNahbRrX5eCc3cH5shjMO3efxaCvh8CXdbCinl11KHYZIZfb4Gf/sDfXIZp8kQdQXuRaZbDtI6K0WgqZk1UNfe2uRdTDL0G2k8baJQWI/gjfeBb+/CO4kyrkTzSbSbam+jMpGi+rGfbzPgDhlIiPjGCCkgAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/87e13dc5cd936edc0bad1f5234f68be7/8ac56/image.webp 240w,\n/static/87e13dc5cd936edc0bad1f5234f68be7/d3be9/image.webp 480w,\n/static/87e13dc5cd936edc0bad1f5234f68be7/b0a15/image.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/87e13dc5cd936edc0bad1f5234f68be7/8ff5a/image.png 240w,\n/static/87e13dc5cd936edc0bad1f5234f68be7/e85cb/image.png 480w,\n/static/87e13dc5cd936edc0bad1f5234f68be7/0b533/image.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/87e13dc5cd936edc0bad1f5234f68be7/0b533/image.png\"\n            alt=\"img\"\n            title=\"img\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>That completes the creation of the boot media.</p>\n<h2 id=\"boot-ubuntu\" style=\"position:relative;\"><a href=\"#boot-ubuntu\" aria-label=\"boot ubuntu permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Boot Ubuntu</h2>\n<p>Insert the SD card you prepared earlier into the Raspberry Pi 4, then plug power into the USB-C port and boot it up.<br>\nNote that you need to connect an external display and keyboard at this stage.</p>\n<p>The external display connector used the Micro HDMI standard. (It was my first time seeing one.)</p>\n<p>Once the OS boots, you will be prompted to log in.<br>\n<strong>The default username and password are both <code class=\"language-text\">ubuntu</code>.</strong></p>\n<p>After logging in and setting any password you like, startup is complete.<br>\nCongratulations.</p>\n<h2 id=\"configure-networking-on-ubuntu\" style=\"position:relative;\"><a href=\"#configure-networking-on-ubuntu\" aria-label=\"configure networking on ubuntu permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configure networking on Ubuntu</h2>\n<p>From here on, it is the same as ordinary Linux setup, so there may not be anything particularly troublesome.<br>\nTo keep it simple, I will proceed by logging in as root with <code class=\"language-text\">sudo su</code>.</p>\n<p>First, copy <code class=\"language-text\">50-cloud-init.yaml</code> and create <code class=\"language-text\">99-cloud-init.yaml</code>, then edit that file.</p>\n<p>For an explanation of what <code class=\"language-text\">50-cloud-init.yaml</code> is and why you should create <code class=\"language-text\">99-cloud-init.yaml</code>, the following article is helpful: <a href=\"https://qiita.com/yas-nyan/items/9033fb1d1037dcf9dba5\" target=\"_blank\" rel=\"noopener noreferrer\">[Ubuntu] Stop editing /etc/netplan/50-cloud-init.yaml - Qiita</a></p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">cp</span> /etc/netplan/50-cloud-init.yaml /etc/netplan/99-cloud-init.yaml\n<span class=\"token function\">vi</span> /etc/netplan/99-cloud-init.yaml</code></pre></div>\n<p>Next, edit that file as follows.<br>\nThe network interface name is probably <code class=\"language-text\">wlan0</code> by default, but just to be safe, you may want to confirm it with <code class=\"language-text\">/sbin/ifconfig</code>.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">network:\n    version: 2\n    ethernets:\n        eth0:\n            dhcp4: true\n            optional: true\n    wifis:\n        wlan0:\n            access-points:\n                \"&lt;Your SSID>\":\n                    password: \"&lt;Password>\"\n\n            dhcp4: false\n            addresses: [&lt;Static IP>/24]\n            gateway4: &lt;Default gateway>\n            nameservers:\n                addresses: [&lt;DNS server address>]</code></pre></div>\n<p>Now, when you run <code class=\"language-text\">netplan apply</code> with this configuration, you get an error.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">Warning: The unit file, source configuration file or drop-ins of netplan-wpa-wlan0.service ch\nanged on disk. Run 'systemctl daemon-reload' to reload units.\nWarning: The unit file, source configuration file or drop-ins of netplan-wpa-wlan0.service ch\nanged on disk. Run 'systemctl daemon-reload' to reload units.</code></pre></div>\n<p>As noted at the beginning, this error is caused by a bug in <code class=\"language-text\">netplan.io</code>, so <code class=\"language-text\">systemctl daemon-reload</code> does not fix it.  </p>\n<p><a href=\"https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/1874494\" target=\"_blank\" rel=\"noopener noreferrer\">Bug #1874494 “netplan apply does not remove systemd service for …” : Bugs : netplan.io package : Ubuntu</a></p>\n<p>To resolve it, you need to connect to the Internet over wired networking once and perform an upgrade.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">sudo</span> <span class=\"token function\">apt</span> update <span class=\"token operator\">&amp;&amp;</span> <span class=\"token function\">sudo</span> <span class=\"token function\">apt</span> upgrade -y</code></pre></div>\n<p>If you check the upgrade above, you can confirm that the <code class=\"language-text\">netplan.io</code> module was updated.<br>\nRun the following command once again.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">netplan apply</code></pre></div>\n<p>This applies the settings, and I was able to connect the Raspberry Pi 4 to Wi-Fi.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>Even though the Raspberry Pi 4 costs only a few thousand yen, the specs are quite impressive.<br>\nLately I have been writing stock price analysis scripts, so I am thinking about using it as a server to run them.</p>\n<h2 id=\"references\" style=\"position:relative;\"><a href=\"#references\" aria-label=\"references permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>References</h2>\n<ul>\n<li><a href=\"https://ubuntu.com/download/raspberry-pi\" target=\"_blank\" rel=\"noopener noreferrer\">Install Ubuntu on a Raspberry Pi 2, 3 or 4 | Ubuntu</a>  </li>\n<li><a href=\"https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/1874494\" target=\"_blank\" rel=\"noopener noreferrer\">Bug #1874494 “netplan apply does not remove systemd service for …” : Bugs : netplan.io package : Ubuntu</a>  </li>\n<li><a href=\"https://www.yokoweb.net/2018/05/09/ubuntu18-network-fix-ip-address/\" target=\"_blank\" rel=\"noopener noreferrer\">[Ubuntu 20.04/18.04 LTS Server] Change network settings to a static IP | The modern stone age.</a>  </li>\n<li><a href=\"https://askubuntu.com/questions/1291424/failed-to-start-netplan-wpa-wlan0-sevice-unit-netplan-wpa-wlan0-service-not-fou\" target=\"_blank\" rel=\"noopener noreferrer\">networking - Failed to start netplan-wpa-wlan0.sevice: Unit netplan-wpa-wlan0.service not found - Ask Ubuntu</a>  </li>\n<li><a href=\"https://qiita.com/quailDegu/items/63114ba1e14416df8040\" target=\"_blank\" rel=\"noopener noreferrer\">Installing Ubuntu Server on Raspberry Pi 4 and completing the initial setup [with simple security] - Qiita</a></li>\n</ul>","fields":{"slug":"/note-raspi4-connects-wifi-en","tagSlugs":["/tag/notes/","/tag/linux/","/tag/english/"]},"frontmatter":{"date":"2020-12-02","description":"This article summarizes how to install Ubuntu Server 20.04.1 on Raspberry Pi 4 Model B and connect it to Wi-Fi using netplan.","tags":["Notes","Linux","English"],"title":"Install Ubuntu Server 20.04.1 on Raspberry Pi 4 Model B and Connect to Wi-Fi with netplan","socialImage":{"publicURL":"/static/dc4d8b7f8795f3c3d3489d9957d155f2/no-image.png"}}}},"pageContext":{"slug":"/note-raspi4-connects-wifi-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}