#UltimateHomeServer: Setting Up Netboot on your Raspberry Pi

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so you've come to learn how to net boot a raspberry pi meaning that you boot a raspberry pi without an sd card or usb memory stick off of the network and maintain the root file system and the boot file system outside of the actual raspberry pi device this is actually really cool you could do a lot of stuff with this that's really awesome one it's super easy to back up and restore your raspberry pi two it's super easy to do a security audit because you can inspect the files on the raspberry pi without the raspberry pi having anything to say about it you know something that's really good compromises your raspberry pi your raspberry pi can just tell you that it's not compromised if its file system comes from the network the device that's hosting its network can give you the ground truth as to what's going on with the file system and with no local storage on the raspberry pi it's going to be hard for you know any malware to persist it's pretty good architecture for something like internet of things it's hard for the malware to persist on the endpoint devices that things are running on that may get compromised it's a it's a security thing but the steps are a little tricky and we're doing a series at level one sort of building the ultimate home server that's kind of a follow up to our you know building a better internet of things series and raspberry pi's oh boy everybody in the audience always ask questions about raspberry pi so i figured it'd be pretty good to show you how to use a raspberry pi in a disclosed kind of way let's dive in [Music] now this being on the linux channel as opposed to our main channel should clue you in this is going to be more steps and step by step if you want to hear more rambles and more about me waxing poetic i did another video on the why so if you're watching this video after watching that video welcome if you haven't seen the other video and you're just coming here welcome just be aware of those check those out the internet of things stuff we got a lot going on we want to turn technology into our brain outside our brain so that we can legitimately claim that hey this is a compendium of all human knowledge and there's not really any restrictions or you know copyright nobody's got their hand out from you know a copyright industry because it's like oh you bought that book in 1983. it's been long enough you need to pay for that book again it's not how dead tree format works and i think about the vcrs you know the vcr was almost illegal in the united states it was a five to four supreme court by the skin of our teeth we almost didn't have a vcr and uh the copyright cartel is keen not to repeat that mistake from their perspective so they're clawing at basically everything in every country to try to prevent people from having fair use rights of the media that they've they've paid for sorry that's not what this video is about this video is about net booting a raspberry pi now i've also outfitted mine with a poe hat so this is a this is like a one-two punch of cool because you can plug in your network cord and this thing actually runs over the network if you have a poe switch meaning an ethernet switch that provides power um the raspberry pi 4 and this this is the first version of the poe hat i don't actually recommend it because if you plug in any usb devices i even tried just using a very modest z-wave usb dongle and that will cause the raspberry pi to lock up and drop out because of insufficient power but how cool is you can sprinkle these around your house you can have a bunch of them you can do central configuration managing that central configuration is going to take some other software like ansible or something like that that's gonna have to be a different video but whole house audio that's probably one of the most popular uses of the raspberry pi because uh you know some of you out there are paying hundreds if not into a couple thousand dollars for a whole house audio system and i've got some bad news for sonos and other companies like that the days of those products being worth that much are numbered the reason apple's a three trillion dollar company is not because their hardware is amazing it's because their software is uh very cohesive people like being able to just hit a button and do stuff we can do that with open source the solutions exist we just have to make it a little easier and a little more accessible for normal people this video is not that but this video is is aimed to get more people clued in so eventually maybe we can package up something into a nice distribution and say okay you know boot up your raspberry pi give us the numbers off the raspberry pi feed some numbers into a spreadsheet somewhere and then magically your raspberry pi will become this function or that function or whatever so whole house audio is just one example the thing that i'm using it for air quality so that's an autopilot uh air quality monitor slash data logger it connects with usb it'll give you the relative humidity the temperature and the co2 level this is really awesome because you know if you get a central air system at your house the ones that tie in environmental controls like co2 level are crazy expensive for no reason if you just need to turn the fan on or off depending on what the co2 level is to circulate some air you could do that with a little bit of home assistant from our internet of things video and a little bit of sensor data but i don't like the administration headache the additional administration headache of having to maintain a bunch of raspberry pies with a bunch of sensors connected to them all over the house now you could you could do this with like an esp you know 8266 or some other embedded system and then just connect it with wireless i mean that's an option but i like the raspberry pi because it's so flexible i could you know put an air quality sensor behind the tv for the raspberry pi that's being the end point for the tv and also being an end point for a stereo system you can use the analog three and a half millimeter jack on the raspberry pi 4b to just connect to your home stereo and then boom you've got bluetooth connection you've got whole house audio because if you've got five or six raspberry pi's they can all synchronize with one another over the network and we can all play the same audio through the raspberry pi there's actually probably a dozen projects that do that and there's threads about that on the level one forum so without further ado let's get started first step plug in your raspberry pi well okay actually i lied first step is you actually are going to need a micro sd card for the initial setup probably um so i've got quite a few raspberry pi's around here one of them worked perfectly out of the box i was getting this video ready it was like great it came from netboot configuration out of the box didn't have to do anything in terms of configuration on the raspberry pi but um some of the other ones that i had didn't so i'm just going to walk you through it i think this is probably going to be easier so for your initial setup you will need a micro sd card but you basically just set a raspberry pi up as per normal through a micro sd card and then you copy the contents of the micro sd card with the raspberry pi booted to your network boot server this is really nice for two reasons one to make sure that your your network boot server the file shares or you're gonna store files is working correctly it can be a little difficult to troubleshoot the second thing that makes that nice is that you get the latest and greatest from a normal raspberry pi image from the raspberry pi foundation you don't have to download things from me you don't have to download things from some other rando you literally get the md5 some verified image for your raspberry pi you extract it to the micro sd card you boot from the micro sd card in the raspberry pi and you're good to go all right with your micro sd card inserted the first time you boot it's going to reboot a couple of times it's going to resize automatically to fill the size of your micro sd card it's going to ask you some questions reboot it's fine when it comes up you should see a login prompt that's kind of like this you just log in and do normal raspberry pi things i'm assuming you're a little bit familiar with this kind of stuff what you're going to want to do is run sudo raspi dash config this this is in the the written guide on the level 1 forum check that out you can follow along with this video as you go through the guide you're going to go to advanced options in an a6 boot order and then you'll pick b3 for network boot do note that it says boot from network if sd card fails so this is always nice you can always slap an sd card in there and even if your network is plugged in it'll boot from the sd card first it'll only try to boot from network if there is no sd card then it'll say okay you're finished would you like to reboot tell it no we're not done all right so you've configured your raspberry pi to boot from the network but how do you actually boot from the network if you read the how to's that are linked in the level one forum if you've read other how to's on network booting with raspberry pi it talks about reconfiguring the eprom we just did that through the gui mostly there's one part that that doesn't do and having to update something and extract some other things mostly in 2022 and we're basically in february of 2022 at this point none of those things are necessary the raspberry pi people have worked out the bugs with that with the eeprom that's on the raspberry pi so it has a little tiny tiny amount of of fungible memory that has a network booting capability and so in the past there have been bugs with that software so depending on what raspberry pi you have you might have to update that and that's going to be like a raspberry pi 3b plus and maybe some of the very early raspberry pi 4s this is a relatively recent one but this is one of the ones that is relatively recent and i also had to change that option in raspi config so i'm not going to get into those specific steps but you may need to update your eprom the other way that you may need to update your eprom is if you can't reconfigure your dhcp server your dhcp server has to have has to pass an extra configuration parameter it basically has to say oh your raspberry pi oh there is a tftp boot server located at this address and that's where the raspberry pi will download the initial image that it uses to bootstrap linux from there it's nfs network file system but you need the the ip address that contains the tftp boot server and your tftp boot server and your nfs server are not necessarily they don't have to be the same machine the same ip address on your network but it makes life a little easier for this video i'm using trunas as the server that's hosting the tftp share where the raspberry pi can download the file it's going to boot from remember it doesn't have local storage it's got a read from somewhere to do this as well as our nfs server trueness is a great platform for doing that there's also a synology nas we've done a lot of videos on synology and nfs shares and all of that highly recommend synology for this as well because it's got a built-in tftp server and a built-in nfs server and it's a point-and-click gui in both of those cases all you got to do on the truenac side from the command line is create the directories that you want to share so to walk you through that on trueness really quickly basically we drop to a command prompt and we go to slash mnt and then we go to our storage pool which i call tank on my system it may be different on yours then i'm creating a directory called nfs and then inside nfs i've created two directories rpi tftp boot and rpi-pxe the tftp boot is going to have one folder for every raspberry pi it's based on the serial number i'll show you more about that in a second the tftp boot folder is going to have one folder for every root file system for every raspberry pi that's going to be on your network and that's whatever you want you can name it whatever you want it's totally fine so you create those through the gui you tell it okay save it and then you're good to go so we come back to our raspberry pi and then we try to actually mount those all right so i've got this kind of long looking example mount command on the level one forum so let's walk through it real quick all right the first part is pretty basic we're going to mount we're going to tell it that it's type nfs port 2049 protocol tcp we want it to be read write for this initially we're going to tell it all squash and we're going to tell it that anonymous maps to user id 1001 which is the default user id on the base raspberry pi image and then we specify the ip address of our nfs server in this case it's your synology or your true nas or whatever hosting your your uh nfs share you can do this from raw linux too but i assume if you're doing this from all linux you know what you're doing so i don't really need to go over this command with you and then on the raspberry pi i'm mounting that at slash nfs slash rpi slash tftp boot and rpi pxc and so i have two nfs mounts on the system one for the boot folder and one for the roof file system and this roughly mirrors slash boot on the raspberry pi which is a v-fat partition it's not even ext and slash which is ext next i'll use the rsync command to rsync slash boot to the special serial number directory for the raspberry pi we need to know our globally unique raspberry pi serial number we actually see that when it tries to move from the network but we haven't tried to move from the network for the first time yet so we need to ask the raspberry pi what its serial number is curiously this is not the mac address if you're familiar with mac addresses you know an ethernet address of the network card it's not that we can use vc gen command to dump the the eeprom of the raspberry pi and ask it what a serial number is that's what that command is on the level 1 form so you can copy paste that in my case it's c494 blah blah blah and so what i will need to do is create a folder under the nfs tftp root that's c494 blah blah that exactly matches my serial number and what happens is the tftp boot program on the raspberry pi when we boot from the network connects to the tftp server and looks for a directory that matches its serial number that's where it pulls its configuration from so you know raspberry pi's have the the command line.txt file on that v-fat partition and sometimes you have to open that and modify it well hey now you can modify it over the network without having to fiddle with the micro sd card and change parameters which is important because we're going to have to tell it that it's it's root file system is not the sd card anymore that it's nfs but we'll get to that all right so with that directory made we just rsync slash boot slash star into nfs slash rpi dash tftp boot slash c494 blah blah and so all the contents of our boot folder are in that folder awesome and then we also use rsync to rsync slash excluding the nfs folder to nfs slash nfs slash rpi uh pxc that's our that's our root file system for pxe booting and we let that complete that'll take a little while not not super long time but it will take a little while then with that done the next thing that we need to do is modify fs tab so if you go to slash nfs you're going to modify the fs tab not on the sd card but the one on the on nfs because we're going to keep the sd card working it's our it's troubleshooting things go wrong pop the sd card back in there boot up and see what's happened so you want to edit slash nfs slash rpi dash pxe slash etc fstab and change that to map to your nfs volumes an example of that is on the level 1 forum so you can use those adjust the ip addresses to match your nfs server and if your nfs mount is working properly with this setup step then you can be pretty confident that it's going to work properly when you reboot so if you reboot and have problems it's probably not the nfs server it's probably something with your tftp boot or something in your configuration files there's one other configuration file you have to change that i alluded to which is the command line the kernel command line you have to tell it that yes root is going to be an nfs file system here is the ip address and this is this is the the kernel command line that i'm using that works with this raspberry pi 4. so you can copy paste that change your ip address and you should be good to go now before we reboot the thing to check is does your dhcp server support option 66 pfsense supports this open wrt supports doing this if that is your dhcp server windows server supports doing this uh if you're using true nas as your dhcp server trueness supports doing this you set option 66 to the ip address of your tftp server and that's all you have to do is just just no quotes or anything like that just your ip address and the next time your dhcp server hands out a dhcp lease you do need to restart your dhcp server or reboot your device the next time you unless you're on pfsense then you don't have to well actually is that true no you still need to restart the service anyway the next dhcp lisa hands out it'll have that extra configuration tag and the raspberry pi looks for that caution caution the there are some how to's on the internet that have you set a bunch more parameters on your dhcp server none of that is really necessary anymore all right with the dhcp server configured to point to our tftp server with our tftp shares and with files copied you can actually browse the network since this is an nfs share you can also export them as a windows share if you're on windows and you know browse the network shares and look for files in those directories and make sure that you see them the way that you should i mean you can do that just as like a a sanity check or use the command line from your your trueness or whatever to make sure that it actually works but you reboot and it actually works your files are there all right we're good to go so we shut down the raspberry pi pop the sd card out and see what happens all right this is a boot up screen that you should get when it's booting from the network notice there's my c494 number right on that line and i saw some stuff down here that's like hey i'm communicating with dhcp server everything's working there's a rainbow screen hey it booted normally and it's showing when i type mount i can see that my root file system and my boot partition are mounted on nfs yes nfs is a little slower than a micro sd card unless you get a crappy micro sd card but look how much more repeatable and auditable this is like oh i need to set up another raspberry pi with another sensor great you know not a problem now where you go from here is it would be nice to have even more automation for managing your fleet of raspberry pi's it's really easy to create a snapshot on the volume where your tftp stuff is stored do some experiments and then roll back that snapshot if you shut down your raspberry pi's and uh you know create a snapshot and then boot your raspberry pi's back up and do something horrible you roll back the snapshot and they're exactly where you left off all of them immediately at once which is really nice you can experiment with one of them and see how one of them goes or snapshot just one of them that's totally fine if we want to automate this even more we need something like ansible or you could use other tools but i think ansible is probably going to be the one that we cover and we'll cover that in other stuff in this series because this is sort of built toward building the ultimate home setup google used to have an example i used in my other videos google used to have an audio puck that everybody loved and it was great and they stopped selling it because there were limited ways to monetize it other than just buying the hardware buying the hardware is not where you make money it is monetizing the use of it after and the analytics data and this is a you know we're slipping into a a really sort of horrifying dystopia with that kind of stuff but you can use open source things and build your own stuff and have all of the awesome amenities of a modern home uh without having it be so brittle you know this doesn't depend on the cloud being up this just depends on your local network stuff this doesn't send data to the cloud it all lives locally and i would argue that this is going to last you know 5 10 20 years it's more likely to than uh the garbage internet of things devices that we have now i mean there was an amazon outage the other day and people's roombas couldn't roomba that's pretty brittle and unacceptably brittle in my opinion nobody should be paying money for that that's crazy anyway this is how you not butcher raspberry pie i'm one of those level one signing out you can find me the level one forums [Music] [Music] you
Info
Channel: Level1Linux
Views: 74,431
Rating: undefined out of 5
Keywords: technology, science, design, ux, computers, linux, software, programming, level1, l1, level one, l1Linux, Level1Linux
Id: PUfWcTXH__E
Channel Id: undefined
Length: 20min 7sec (1207 seconds)
Published: Thu Feb 03 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.