{"id":14706,"date":"2021-10-11T13:16:48","date_gmt":"2021-10-11T19:16:48","guid":{"rendered":"https:\/\/macblaze.ca\/?p=14706"},"modified":"2021-10-20T09:36:12","modified_gmt":"2021-10-20T15:36:12","slug":"pi-update","status":"publish","type":"post","link":"https:\/\/macblaze.ca\/?p=14706","title":{"rendered":"Pi update"},"content":{"rendered":"<h3>&#8230;Because I know you care \ud83d\ude42<\/h3>\n<p><a href=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/piboard.jpg\"><img loading=\"lazy\" class=\"alignleft size-thumbnail wp-image-14721\" src=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/piboard-150x97.jpg\" alt=\"\" width=\"150\" height=\"97\" srcset=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/piboard-150x97.jpg 150w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/piboard-400x257.jpg 400w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/piboard-1024x659.jpg 1024w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/piboard-768x494.jpg 768w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/piboard-1536x988.jpg 1536w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/piboard.jpg 1708w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a> When <a href=\"https:\/\/macblaze.ca\/?p=14615\">last we left our intrepid Pi<\/a> I had listed the\u00a0 software I had running on it. Here&#8217;s a quick recap of what that install was with a few of the missed out bits:<\/p>\n<p style=\"padding-left: 40px;\"><strong>Pi 4 Model B<\/strong> with 8 gb of ram<br \/>\n5oo gb external<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li class=\"p1\"><span class=\"s1\">Ubuntu 21.04<\/span><\/li>\n<li>Shairpoint-sync music server<\/li>\n<li>Nginx Proxy Manager<\/li>\n<li>Webhost Apache\/php<\/li>\n<li>MySql server<\/li>\n<li>Pi-Hole<\/li>\n<li>Nextcloud server<\/li>\n<li>Samba File Server<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>But after watching a few videos (<a href=\"https:\/\/www.youtube.com\/watch?v=cO2-gQ09Jj0\">Novaspirit tech&#8217;s Pi series<\/a>) and playing around with Docker a bunch more I basically redid the whole thing from scratch. So that makes the above info completely redundant \ud83d\ude09<\/p>\n<h2>SD backups<\/h2>\n<p>A word about installs and backups. One of the things I am especially happy about with the move to a Pi is the ability to image SD cards. It took me a while to get my methodology straightened out but here it is<\/p>\n<h3>Step 1: Install base operating system<\/h3>\n<p>I currently have two base installs:<\/p>\n<ul>\n<li><span class=\"s1\">Ubuntu 21.04 \u2014 this is a GUI-less (command line only) install of the Ubuntu linux distro. It has become my main system.<\/span><\/li>\n<li><span class=\"s1\">Ubuntu 20.04 Mate \u2014 this is the Ubuntu install with the MATE desktop and apps suite. I have pretty much abandoned this.<\/span><\/li>\n<\/ul>\n<p>Set up server (this is for the headless Ubuntu):<\/p>\n<ul>\n<li>change host name<\/li>\n<li>add user<\/li>\n<li>set static IP<\/li>\n<li>install and set up Samba<\/li>\n<li>install and set up Docker &amp; Docker Compose<\/li>\n<\/ul>\n<h3>Step 2: Create an image<\/h3>\n<p>After I had everything installed and set up, it&#8217;s time to make an image of the SD card. Shutdown the computer and and pop the SD card into the MacBook SD slot.<\/p>\n<p>Open Terminal and use <code>dd<\/code> to make an image:<\/p>\n<p style=\"padding-left: 40px;\"><code>sudo dd bs=1m if=\/dev\/rdisk2 of=\/Users\/admin\/Desktop\/pi-server.img<\/code><\/p>\n<p style=\"padding-left: 40px;\">To parse this, it is basically saying: using root permission (sudo), make an image (dd) using 1 megabyte blocks (bs=1m) of the disk labeled <em>disk2<\/em> to a file on the desktop named <em>pi-server.img<\/em><\/p>\n<p>This can take a <em>long<\/em> time depending on the size of the disks. With a lot of trial and error I settled on using my 32 gb SD card to make these images from and it takes around 400 seconds (6.7 minutes). When I tried with both the 64 gb card or even worse the 500 gb hard drive the time sometimes was in the hours. Which was ridiculous because most of that copy time was copying blank space.<\/p>\n<p>What this means is I have to make all my changes to the install on the 32 GB card, which may mean redoing them since I generally make them first on the hard drive install. But it works for me as it forces me to a) document the changes I am making and b) do them several times which\u00a0 helps me ingrain them in my memory.<\/p>\n<p>This leaves me with 32gb disk image on my\u00a0 laptop that I then re-image back to the 500GB hard drive \u2014 which is a pretty quick process.<\/p>\n<p>I repeat this process whenever I make a major change to my setup so I can revert back anytime I screw something up (which thankfully is happening less and less).<\/p>\n<h2>The new install<\/h2>\n<p>This time I started with the base install described above (Ubuntu, Samba for file sharing and Docker to host containers), made an image and then moved on.<\/p>\n<h3>Docker<\/h3>\n<p>As I said in my <a href=\"https:\/\/macblaze.ca\/?p=14604\">Drop Dropbox?<\/a> post, Docker is is a sort of virtual containerizing system. Rather than a true virtual machine (which acts as a completely different physical machine complete with OS and hardware configs), a container\u00a0 is an isolated &#8220;box&#8221; into which you install your applications and whatever settings they need. The Docker host\u00a0 manages the network interfaces and whatever other\u00a0 i\/o you need. The beauty of this is you can install all sorts of\u00a0 support programs or drivers without affecting \u2014 or in my case, screwing up \u2014 the rest of the\u00a0 system. If you don&#8217;t like it or make a mistake, you just shutdown the container and delete it and poof, it and all its resources are gone.<\/p>\n<h3>Portainer<\/h3>\n<p><img loading=\"lazy\" class=\"alignleft size-thumbnail wp-image-14710\" src=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainer-150x79.png\" alt=\"\" width=\"150\" height=\"79\" srcset=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainer-150x79.png 150w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainer-400x210.png 400w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainer-1024x538.png 1024w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainer-768x403.png 768w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainer.png 1200w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/> One of the things that made me switch to an almost completely Docker-based setup was the discovery of Portainer, which is a web-based GUI that allows you to manage all your Docker containers without having to understand the often complex and arcane Terminal commands used to invoke and manage them.<\/p>\n<p>Oddly enough Portainer itself is a Docker container so that mean you have to do thing the hard way at least once. Create a docker volume (<code>docker volume create portainer_data<\/code> to store the app data on) and then run:<\/p>\n<pre><code><br \/>docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v \/var\/run\/docker.sock:\/var\/run\/docker.sock -v portainer_data:\/data portainer\/portainer-ce\n\n<\/code><\/pre>\n<p>And you are done. Sign into the system by typing http:\/\/&lt;insert IP address&gt;:9000 and you should be good to go. Here&#8217;s a screen shot of all my containers at the moment:<\/p>\n<p><a href=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainerimage.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-14711\" src=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainerimage-1024x580.jpg\" alt=\"\" width=\"1024\" height=\"580\" srcset=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainerimage-1024x580.jpg 1024w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainerimage-400x227.jpg 400w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainerimage-150x85.jpg 150w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainerimage-768x435.jpg 768w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/portainerimage.jpg 1308w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h3>NGINX Proxy Manager<\/h3>\n<p>Next up was a reinstall of NGINX Proxy Manager to manage SSL and routing.\u00a0 You can read about it in the\u00a0<a href=\"https:\/\/macblaze.ca\/?p=14445\">NGINX Proxy Manager<\/a> post.<\/p>\n<p>One difference\u00a0 in this install was I used Portainer to install it as a Stack (a group of associated programs). This meant the\u00a0 NGNIX program and its associated Maria database were installed in separate containers that were linked together so they could be managed as a unit.<\/p>\n<p>Then I reinstalled the Portainer container so it was using the same virtual network as NGINX and they now all talked to each other securely and happily.<\/p>\n<h3>Homer<\/h3>\n<p>An app called Home was recommended by several sources so I decided to give it a go. Home is a lightweight dashboard that allows one to\u00a0 have a convenient starting place for\u00a0 what is rapidly becoming my HomeLab. It runs off a simple yaml (stands for<em> yet another markup language<\/em>) text file.<\/p>\n<p>You just add an entry like<\/p>\n<pre><code><br \/>- name: \"Boat Search\"\nlogo: \"assets\/tools\/swan.png\"\nsubtitle: \"Utility to search Yachtworld\"\ntag: \"pythonapp\"\nurl: \"192.168.1.3:8889\"\ntarget: \"_blank\"\n\n<\/code><\/pre>\n<p>And it adds another item to your dashboard.<\/p>\n<p><a href=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/homerimage.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-14713\" src=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/homerimage.jpg\" alt=\"\" width=\"1010\" height=\"703\" srcset=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/homerimage.jpg 1010w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/homerimage-400x278.jpg 400w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/homerimage-150x104.jpg 150w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/homerimage-768x535.jpg 768w\" sizes=\"(max-width: 1010px) 100vw, 1010px\" \/><\/a><\/p>\n<p>Then I added a Samba entry to allow me to change the config.yml file and drop in additional icons<\/p>\n<p style=\"text-align: center;\">**<strong>MAKE ANOTHER IMAGE<\/strong>**<\/p>\n<h3>LAMP<\/h3>\n<p>With that done I\u00a0 installed my lamp stack again (<em>Linux, <\/em>Apache, Mysql, and php) to redo my test websites. I decided not to do this in a container as I figured it wasn&#8217;t going to change.<\/p>\n<p style=\"text-align: center;\">**<strong>MAKE ANOTHER IMAGE<\/strong>**<\/p>\n<h3>Shairport<\/h3>\n<p>Currently I am having issues with the dockerized version of this. The sound cuts out every once in a while and I can&#8217;t figure out why. I may go back to the direct install from <a href=\"https:\/\/macblaze.ca\/?p=14615\">What&#8217;s your Pi doing?<\/a> and see if that solves the issue. But for now I have it as a Docker container\u2014but disabled.<\/p>\n<h3>NextCloud<\/h3>\n<p><a href=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/08\/Nextcloud.png\"><img loading=\"lazy\" class=\"alignleft size-thumbnail wp-image-14605\" src=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/08\/Nextcloud-150x150.png\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/08\/Nextcloud-150x150.png 150w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/08\/Nextcloud-400x400.png 400w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/08\/Nextcloud.png 500w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>(See <a href=\"https:\/\/macblaze.ca\/?p=14604\">Drop Dropbox?<\/a>) Again this is now purely Docker based and the install was super easy using Stacks. I can turn it off and on as I like and see how much of my Pi&#8217;s resources it is using.<\/p>\n<h3><\/h3>\n<h3><\/h3>\n<h3>YouTube DL<\/h3>\n<p><a href=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/youtubedl.jpg\"><img loading=\"lazy\" class=\"size-medium wp-image-14714 aligncenter\" src=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/youtubedl-400x232.jpg\" alt=\"\" width=\"400\" height=\"232\" srcset=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/youtubedl-400x232.jpg 400w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/youtubedl-1024x594.jpg 1024w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/youtubedl-150x87.jpg 150w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/youtubedl-768x445.jpg 768w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/youtubedl.jpg 1026w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a>This one is new. I had this app installed on my Mac mini as it allowed me to download favourite YouTube videos for offline watching. But now I can use it with a web interface. I haven&#8217;t played with it much, but I expect it will be much more convenient than the command line version. (<strong>Note<\/strong>: I have subsequently had problems with this leading me to discover that YouTube is throttling the app. The first few videos go fine then it drops down to a snail&#8217;s pace rendering it almost unusable.)<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\">**<strong>MAKE ANOTHER IMAGE<\/strong>**<\/p>\n<h3>Python Apps<\/h3>\n<p>I built a python\/flask app to calculate Bus Fares for L and decided to see if I could dockerize it. It worked out pretty good and so I added it to the mix so L could use it.\u00a0 Again the ability to manage it and turn it off and on will be a bit of a godsend as I develop it further.<\/p>\n<p><a href=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/busfare.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-14716\" src=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/busfare-400x231.jpg\" alt=\"\" width=\"400\" height=\"231\" srcset=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/busfare-400x231.jpg 400w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/busfare-150x87.jpg 150w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/busfare-768x443.jpg 768w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/busfare.jpg 1000w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>The apps needed python and a webserver (I tried to use nginx but ended up going back to gunicorn \u2014 I was having trouble with uwisg in the container). It took some fussing as the resulting containers were initially 800 mb but eventually I knocked them down to a sixteenth of that size.<\/p>\n<p>I also decided since that worked so well I would take my boat search app (<a href=\"https:\/\/macblaze.ca\/?p=13668\">If you can&#8217;t boat, dream&#8230;<\/a>) that was hosted on the Google Cloud and move it to the Pi. And in the end I was able to share the python container between the two apps.<\/p>\n<p style=\"text-align: center;\">**<strong>MAKE ANOTHER IMAGE<\/strong>**<\/p>\n<h3>Grafana &amp; Prometheus<\/h3>\n<p>Last but not least I wanted to be able to track some data about usage and load since I was now adding quite a bit onto the poor ~$100 Pi. A bit of research, one last Stack, and I was good to go.<\/p>\n<p><strong>Prometheus<\/strong> is an application that collects data from your machine. It can organize and store a ton of stuff and is so complex I ended up just stealing others&#8217; setups. It uses plugins (I installed cadvisor and node_exporter) to collect specific data. The two I have monitor the docker containers and things like the\u00a0 cpu\/temperature\/network stats from the Pi.<\/p>\n<p><strong>Grafana<\/strong> is a web interface the graphically displays a dashboard with whatever data you managed to\u00a0 collect with Prometheus. Also complex and the config is again &#8220;borrowed.&#8221;<\/p>\n<p><a href=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/grafana.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-14717\" src=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/grafana-1024x636.jpg\" alt=\"\" width=\"1024\" height=\"636\" srcset=\"https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/grafana-1024x636.jpg 1024w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/grafana-400x248.jpg 400w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/grafana-150x93.jpg 150w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/grafana-768x477.jpg 768w, https:\/\/macblaze.ca\/wp-content\/uploads\/2021\/10\/grafana.jpg 1408w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Tr\u00e8s cool.<\/p>\n<p style=\"text-align: center;\">**<strong>MAKE ANOTHER IMAGE<\/strong>**<\/p>\n<h2>So that&#8217;s it for now<\/h2>\n<p>Everything is humming along splendidly now. I still have the issue of Shairport to deal with but that is minor. I can go back to any\u00a0 of the multiple images I have and start over from there or simply delete a container and not have to worry about residual crud interfering with future installs.<\/p>\n<p>I have tested docker containers for things like my <a href=\"https:\/\/macblaze.ca\/?p=13797\">Calibre library<\/a> which I might potentially move off my Mac mini and am looking into OpenVPN and an online FileBrowser. But that&#8217;s all for the future.<\/p>\n<p>I am a happy camper. But I wonder if I should get another Pi&#8230; hmmm&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8230;Because I know you care \ud83d\ude42 When last we left our intrepid Pi I had listed the\u00a0 software I had running on it. Here&#8217;s a quick recap of what that install was with a few of the missed out bits: Pi 4 Model B with 8 gb of ram 5oo gb external Ubuntu 21.04 Shairpoint-sync [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false},"categories":[1,132],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/14706"}],"collection":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14706"}],"version-history":[{"count":15,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/14706\/revisions"}],"predecessor-version":[{"id":14738,"href":"https:\/\/macblaze.ca\/index.php?rest_route=\/wp\/v2\/posts\/14706\/revisions\/14738"}],"wp:attachment":[{"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/macblaze.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}