{"id":191,"date":"2021-01-23T23:11:36","date_gmt":"2021-01-24T07:11:36","guid":{"rendered":"http:\/\/junsun.net\/wordpress\/?p=191"},"modified":"2021-01-31T11:30:49","modified_gmt":"2021-01-31T19:30:49","slug":"set-up-ubuntu-xfce4-on-headless-raspberry-pi-4-via-vnc","status":"publish","type":"post","link":"https:\/\/junsun.net\/wordpress\/2021\/01\/set-up-ubuntu-xfce4-on-headless-raspberry-pi-4-via-vnc\/","title":{"rendered":"Set Up Ubuntu\/XFCE4 on Headless Raspberry Pi 4 via VNC"},"content":{"rendered":"<h2>Background<\/h2>\n<p>The<a href=\"https:\/\/www.raspberrypi.org\/blog\/8gb-raspberry-pi-4-on-sale-now-at-75\/\"> new Raspberry Pi 4 with 8GB RAM<\/a> is a little attractive\u00a0 beast that is suitable for\u00a0 home server.\u00a0 You can set it up basically fan-less.\u00a0 I was intrigued and I wanted to set it up headless, running Bitcoin full node, ElectrumX server plus Lightning Network (see <a href=\"http:\/\/junsun.net\/wordpress\/2021\/01\/setup-bitcoin-electrum-lightning-network-on-raspberry-pi-4\/\">my next post<\/a>).<\/p>\n<p>However, while there are many tutorials around Internet, I just can&#8217;t find the ideal one that suit me:<\/p>\n<ul>\n<li>It must be 64bit.\u00a0 Come on!\u00a0 We are in 2021 already.\n<ul>\n<li>That rules out 32bit Raspberry Pi OS.<\/li>\n<li>The 64bit Raspberry Pi OS (beta) runs fine on the board, but it lacks some basic Linux\/UNIX features (e.g., middle mouse button pasting).\u00a0 The desktop settings keep getting lost.\u00a0 It is just frustrating.<\/li>\n<\/ul>\n<\/li>\n<li>That leaves 64bit Ubuntu, which should be a decent base OS.<\/li>\n<li>I want to boot from USB without slow SD card.<\/li>\n<li>I want to run headless with remote graphic UI\u00a0<\/li>\n<\/ul>\n<h2>The hardware<\/h2>\n<p>Below are the components I purchased.\u00a0 The total cost is $270.\u00a0 Not exactly dirty cheap, but that is pretty meaty piece.\u00a0<\/p>\n<ul>\n<li><a href=\"https:\/\/www.canakit.com\/raspberry-pi-4-8gb.html\">Raspberry Pi 4 with 8GB RAM<\/a> &#8211; $75<\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Argon-Raspberry-Support-B-Key-Compatible\/dp\/B08MJ3CSW7\">Argon 1 M.2 Case<\/a> &#8211; $45<\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Samsung-860-SATA-Internal-MZ-N6E1T0BW\/dp\/B07822Z77M\">Samsung EVO SSD M.2 1TB<\/a> &#8211; $150<\/li>\n<\/ul>\n<p>Putting it together is simper than setting up a toaster machine. See a couple of pictures below as well.<\/p>\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"773\" src=\"http:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_202837-1-1024x773.jpg\" alt=\"\" class=\"wp-image-196\" srcset=\"https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_202837-1-1024x773.jpg 1024w, https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_202837-1-300x227.jpg 300w, https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_202837-1-768x580.jpg 768w, https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_202837-1-1536x1160.jpg 1536w, https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_202837-1-2048x1547.jpg 2048w\" sizes=\"(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"799\" src=\"http:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_203003-1-1024x799.jpg\" alt=\"\" class=\"wp-image-197\" srcset=\"https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_203003-1-1024x799.jpg 1024w, https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_203003-1-300x234.jpg 300w, https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_203003-1-768x599.jpg 768w, https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_203003-1-1536x1198.jpg 1536w, https:\/\/junsun.net\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_20210123_203003-1-2048x1598.jpg 2048w\" sizes=\"(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<h3>Step 1 &#8211; Prepare SSD drive and USB boot<\/h3>\n\n\n\n<ul><li>Download and install <a href=\"https:\/\/www.raspberrypi.org\/blog\/raspberry-pi-imager-imaging-utility\/\">rpi-imager<\/a> on your host PC (Linux, Windows, etc)<\/li><li>Flush raspberry pi OS into SD card (I used 64bit RPIOS beta, but I think 32bit one should work).  This will be a throw-away stepping stone. <\/li><li>Insert the SD card to RPI4 and boot from SD card.<ul><li>Insert USB keyboard\/mouse into black USB slot (USB2)<\/li><li>Connect a HDMI cable to a monitor<\/li><li>Use USB type-C power supply, ideally &gt; 2.4A<\/li><\/ul><\/li><li>Install (if not already installed) and run rpi-imager on RPI4 booted from SD card.<\/li><li>(IMPORTANT)  Choose &#8220;Ubuntu 20.10 64bit Server&#8221; OS image and flush onto the 1TB Samsung SSD drive.<ul><li>I found Ubuntu 20.04LTS don&#8217;t work!<\/li><\/ul><\/li><li>Follow <a href=\"https:\/\/www.jeffgeerling.com\/blog\/2019\/upgrade-raspberry-pi-4s-firmware-bootloader-better-thermals\">this link<\/a> to update EEPROM firmware<\/li><li>Follow <a href=\"https:\/\/www.raspberrypi.org\/documentation\/hardware\/raspberrypi\/bcm2711_bootloader_config.md\">this link<\/a> to boot from USB (i.e., SSD driver) first instead of SD card.<\/li><li>Remove SD card, and now you should be able to boot from SSD drive.<\/li><\/ul>\n\n\n\n<h3>Step 2 &#8211; Fix up the board<\/h3>\n\n\n\n<ul><li>Connect an Ethernet cable to enable Internet<\/li><li>Fix sluggish USB mouse<ul><li>Add &#8220;usbhid.mousepoll=0&#8221; to \/boot\/firmware\/cmdline.txt; Reboot<\/li><\/ul><\/li><li>Install argon 1 fan control<ul><li><code>curl https:\/\/download.argon40.com\/argon1.sh | bash<\/code><\/li><\/ul><\/li><\/ul>\n\n\n\n<h3>Step 3 &#8211; Install XFCE desktop<\/h3>\n\n\n\n<p>Note choose &#8220;lightdm&#8221; when install xfce4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt dist-upgrade\napt install xfce4 xfce4-goodies\napt install tigervnc-standalone-server novnc firefox<\/code><\/pre>\n\n\n\n<p>Create \/etc\/lightdm\/lightdm.conf file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Seat:*]\nallow-guest=false\nautologin-user=ubuntu\nuser-session=xfce\n#greeter-session=unity-greeter\nxserver-command=\/etc\/X11\/xinit\/xserverrc<\/code><\/pre>\n\n\n\n<p>After this you should be able to log into graphic XFCE desktop.<\/p>\n\n\n\n<h3>Step 4 &#8211; Set up VNC and headless<\/h3>\n\n\n\n<ul><li>Configure wifi assuming that is what you want to run RPI4<\/li><li>Set up VNC password<ul><li><code>sudo vncpasswd \/etc\/vncpasswd<\/code><\/li><\/ul><\/li><li>Modify \/etc\/X11\/xinit\/xserverrc file<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/sh\n\nARG=`echo $@ | sed -e \"s#vt. -novtswitch##\"`\nGEOMETRY=\"1600x1000\"\nDEPTH=\"24\"\n# single client mode; VNC password auth; TLS encryption optional;\nexec Xvnc -desktop ubuntu -SecurityTypes \"VncAuth,TLSVnc\" -NeverShared -DisconnectClients -geometry $GEOMETRY -depth $DEPTH -rfbauth \/etc\/vncpasswd $ARG<\/code><\/pre>\n\n\n\n<ul><li>Make sure WiFi is connected before user logs in so that you can connect via VNC<ul><li>To do this, launch NetworkManager, select &#8220;Applications&#8221;\/&#8221;Settings&#8221;\/&#8221;Advanced Network Configuration&#8221;<\/li><li>Then select the wifi network you are connecting to, and then click on button at the bottom to edit the connection<\/li><li>Under &#8220;General&#8221; tab, check &#8220;All users may connect to this network&#8221;<\/li><\/ul><\/li><\/ul>\n\n\n\n<p>After this setup, if you reboot RPI4, you will get text console on display.<\/p>\n\n\n\n<p>Meanwhile you should be able to access RPI4 over VNC remotely<\/p>\n\n\n\n<ul><li>On your PC, install VNC viewer (e.g., <a href=\"http:\/\/tigervnc.bphinz.com\/nightly\/\">tigerVNC viewer<\/a>)<\/li><li>Launch the viewer, enter the IP address and port 5900<\/li><li>Enter the VNC password<\/li><li>You should see XFCE desktop<\/li><\/ul>\n\n\n\n<h3>Step 5 &#8211; Optional noVNC to enable web browser access<\/h3>\n\n\n\n<ul><li>Install noVNC package<ul><li>sudo apt install novnc net-tools<\/li><\/ul><\/li><li>Run \/usr\/share\/novnc\/utils\/launch.sh<\/li><li>On PC, open a browser and point at &#8220;http:\/\/&lt;RPI4 IP address&gt;:6080\/vnc_auto.html&#8221;<\/li><li>Enter VNC password and you will be connected to the desktop<\/li><\/ul>\n\n\n\n<p>You can automate this process by adding this to \/etc\/rc.local or create a small systemd service file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Background The new Raspberry Pi 4 with 8GB RAM is a little attractive\u00a0 beast that is suitable for\u00a0 home server.\u00a0 You can set it up basically fan-less.\u00a0 I was intrigued and I wanted to set it up headless, running Bitcoin full node, ElectrumX server plus Lightning Network (see my next post). However, while there are &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/junsun.net\/wordpress\/2021\/01\/set-up-ubuntu-xfce4-on-headless-raspberry-pi-4-via-vnc\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Set Up Ubuntu\/XFCE4 on Headless Raspberry Pi 4 via VNC&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3],"tags":[51,16,53,52],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/posts\/191"}],"collection":[{"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/comments?post=191"}],"version-history":[{"count":9,"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":233,"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/posts\/191\/revisions\/233"}],"wp:attachment":[{"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/media?parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/categories?post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/junsun.net\/wordpress\/wp-json\/wp\/v2\/tags?post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}