 So I wanted to cover today ZFS and snapshots and I've set up a little demo here I remember there's a lot of questions that people had and I wanted some clarifications So people have a better understanding of how snapshots work in the ZFS Now I like free NAS, which is based on free BST Which also uses ZFS as the file system underneath to manage all the storage and I'm a huge fan of ZFS You've seen maybe seen my video on ZFS torture testing and it's really really a resilient finance system I mean no file system is absolutely bulletproof But I tell you what they've come a long way with this and a lot of it has to do with the way It's a journaled file system in a way that journaling works on this file system So a journal file system that does copy on right I'm not going to get real deeply technical But in short you're keeping almost like a ledger of all changes to the hard drive those ledgers Have a series of checksums before the next piece of data is written. It also very intelligently And this is one of the reasons they asked ZFS is a little bit memory hungry Which creates the concern that people have about ACC memory is it uses a lot of memory to try to manage all the Rights in a very efficient way because it's not caching in the normal sense it's pulling that ledger putting it into memory to Quickly and intelligently distribute the data across the raid rate arrays if when that you have in here And it also minimizes the read and writes But the other advantage of a journal file system is the snapshotting feature Now what you're doing when you're snapshotting is you're creating a snapshot of that journal and saying don't delete these files But the snapshot itself doesn't take up space Which is also really cool because it only is a differential of space between files added or data added Changes to the drive and it's syncing on the delta of the change So if you have a very large file and that file only changes a little bit it doesn't Have to account for the entire file and keep two copies of the file It is the differential change that that file had this also makes it really interesting That's one of the reasons I put a VM on here because VMs are one large file And so let me show you the data we have on here so we can get into the hands-on Which is how I really learned and I think a lot of other people do is I could probably sit and explain this for a long time And not get it, but we're actually going to show you ZFS in action here So Here's my box. I copied some files and move that one out of the way This is the share mount for drives raid my creatively named for drives raid And V box test because there's a V box on there. I called it V box test But there's also some data on here. This is your standard Data set so here's the some data which I threw a video in here and here's the test Which is a windows 7 a clone of my windows 7 machine virtual box machine in a VMDK file So the file itself. Let's see is We got 30 gigs file here And there's some data this is 92 megabytes so there's some data in here about you know 30 gigs roughly Now let's go to look out of a ZFS reports this so here's the free NAS box and we're gonna head and jump over and refresh this again So because ZFS uses compression here's my V box test on the creatively named for drives raid It's using compression. So the actual use size is only 17.3 gigs because by default it has LZ for compression turn on which it really doesn't have much of a loss But because of the way of the VMDK's are it actually is able to go I can store that more efficiently so I only have an actual stored usage of 17 17.3 gigs in this drive and currently there's no snapshots of this So we're gonna go ahead and create one by going down here and hit create snapshot Now you can turn snapshots as an automated task to snapshot in it Increments and we will show that in a minute for now. We're just gonna go ahead and create a manual snapshot All right, and we're gonna do snapshots We're gonna filter it because I have a lot of other snapshots going this is One of my machines that we're using in production. So here we go. It's using zero the refer 17.3 gigs And so there's the use so clone snapshot delete snapshot rollback snapshot. So we'll just do something simple here Let's dump a couple more files here. So we'll paste this over There just dropped a bunch of random thumbnails in here just so it has Something in there. So now we've added to this now if we go here and refresh again That's the only difference it took up now It's only 81 kilobytes of difference is what it says and let's see how big does this this was only four megabytes But because of compression again, it's only Showing the difference on there now if we go here we see the thumbs are in there and we're gonna go back We're just gonna clone this or gonna roll back this. I'm not clone it but roll back it So we're gonna roll back snapshot. Are you sure? All right, and let's go refresh and it's gone Now that snapshot is destroyed that because we rolled it back to the previous state There's nowhere. You can see those files. We've now destroyed them the same thing here Let's go ahead and delete these two things. We're just gonna Hold on a shift delete I believe yep, we're gonna delete these things off the hard drive So I'm gonna go back over here volumes It hasn't refreshed just yet Go back over here. It's still showing usage on there because we have a snapshot So go back over here Now it has 17.3 gigs that it's holding and now that's why you're seeing this in here So we have this and then we can go and dump some more files. Let me find something a little bit bigger All right, we copied over one of our vlog Thursdays, which is about four gigs So let's go ahead and go look at our storage again. And as you can see here the V-box test now has 21 gigs because even though we've deleted that it's being held by the snapshot So we go over here and filter for that particular snapshot And it's still holding at 17.3 gigs I think it does refresh and it'll show that there's another a little bit more But now you can see the volume actually has to keep reserved that much data. So it's showing 21 gigs to have both of it in there so Here this is and this is how it was looking and if we just go the snapshots and we're gonna jump over here and filter again, and let's just go ahead and Roll back that snapshot we hit okay We rolled it back Refresh instantly now. This is one of the advantages not like I have some super incredibly fast machine I mean they are NAS drives. It's a reasonably fast machine But the beauty of the way ZFS works is because you're just looking at the ZFS journal You're just manipulating it very quickly. So it doesn't have a bunch of files to copy the files aren't being moved You're only changing Essentially the journal slash pointers in the file system. You're saying okay put the journal back to where it was So everything points exactly how it did when you took the snapshot. This means that quickly I can roll back data I could have created another snapshot and roll back and forth between them This is one of the beauties of ZFS is your snapshotting a journal Not the actual files in the way that a lot of people think of it like you're making a backup copy of all the files This allows the snapshots to be non disruptive and almost instantaneous even with very very very large data sets It takes very little time So we've actually created clones of like three four terabytes at a time and they just pause for a second done So as long as machines under generally not high load on the on a hard drive and it's not you know completely at weight states Then it snapshots data really really fast, which is Fascinating to me like how well this works. So if you go, oh, no, I need to roll something back You can simply run it and just roll it right back and it's very very quick Now I have here and I'll show you that the replication tasks. I'm sorry the periodic snapshots I have a couple of them with mine. I snapshot my production VMs Once a day and I snapshot my syncing data once a day That's the only real things I have running on here and it works really well and it creates when you go to the snapshots That's why there's so many of them in here auto auto auto and you can see the different ones And you can roll back or clone to the last one on there now when you do a clone Let's go back to our snapshots and filter for test Cloning it's a little bit different. So if we go to clone it actually creates in the storage over here Here's the clone now When it clones it that is a great way to do it and we just had do this for a client the other day the clone They had changed something But we had a snapshot of their entire file system But one person had somehow goofed some things up and we had it set to snapshot a couple times a day And what they'd actually done was delete things at the beat They created some data to be in the day that they deleted before the end of the day Which meant it didn't have a way to back it up So we just ran and found the clones because we clone a couple times a day for this client with their System and they have several terabytes with things but lots of people made file changes. So that's where clones come in and with the clones It's a snapshot in time of that one. So it's kind of like a fork off the file system So what we do is because we don't want to re-change the entirety of that data set the clone creates a separate one Now I have to go in I can't see this a cloning. It doesn't give me any visibility in here to that so I actually have to take the clone and Manually make another share for it So I go to sharing and I create another share on the clone And this is very handy in the circumstance that we had for the client because they will sit We didn't want to change the whole data set We only wanted to change find the file that that person had therefore we created a clone We actually found the person's files They were absolutely in the snapshot and then we copied them back over to the main chair and when you're done you destroy the snapshot So we're gonna go ahead here to the clone and destroy it the data set of the clone Gives you a nice red warning because you're destroying a data set and you cannot come back from destroyed data sets So now that data sets sort and we're left with only this one and when comes the snapshots filter This one's still here now. Let's see how this works in a VM environment So we're gonna go ahead and fire up my windows 7 virtual machine, which is there's the VM DK and it's pointed towards it So let's go ahead and open that up. Oh, and I let this boot in real time to show you I'm running my VM across a gigabit network Not a 10 gig but just a 1 gig network and you can see that running a VM across there actually works really well a Boots up really fast. No problems here. So here's the hard drive for the system Here's some stuff on the desktop and let's go ahead and open up the FreeNAS again, so here's the free NAS control and We're gonna head and I Guess we can destroy this snapshot. We'll create a running snapshot So I'm just gonna get rid of them so we don't not using this one anymore and While the VM is running so windows as you can see is in the background here actually running We're gonna go ahead and create a snapshot of it So we go to storage We go to here Create snapshot manual snapshot, you know, it will even put the word VM running So I know which one this is so mainly create the snapshot Now this is a running open file system right now. It's attached. It's running and You know windows is running in the background This is this is kind of an important because there's also a few concepts here One thing I will tell you and I'm not going to demonstrate it here because it causes my computer to hang But it does work you can restore a live running VM and roll back while it's attached but it will absolutely crash whatever operating system whether it be Linux or Windows you'll end up with a system not running properly because all of a sudden you change the underlying virtual drive so We cloned it while running and let's make some changes. So let's just delete these things off the desktop and We'll open up. I think there's some stuff I can uninstall So let's look for something. Yeah, I don't need team viewer in here anymore So remove it So we're making changes to the system now and let's go back over to ZFS Yeah, we don't care. We don't need to fill out that All right, and we're gonna go over here to snapshots Now here's what's interesting. We only removed a little bit of things So there's only been a little bit of change but this is technically one giant big file in here because it's the It's the VM file itself So even though that this file is a twenty nine point seven gig file Freenas only has to track the little changes made This is kind of an interesting thing because normally if you're backing up files or creating snapshots of them You're thinking of creating a snapshot of file But because Freenas is only looking at the changes made at the file system level It's not a duplicate. You'd normally have another 29 gig file or because compress at 17.3 gigs you'd end up with that This is what's interesting about the way this works. It's referred to as I believe syncing on the delta changes So it actually looks at the differential changes of that file That's what makes CFS super efficient by doing that because it's storing it almost like a database It says I'm only tracking that there was 17 megabytes of changes, which was me removing The team viewer from there. That's the only changes in that So now let's go ahead and shut this VM down. We remove team viewer. We not in there We deleted some stuff off the desktop And we took a snapshot before we did this so while the VM is not running I can roll it back while the VM's running It's gonna crash. I did the test it locks up and then it causes my computer to go a little bit Crazy, so we're gonna head to roll back snapshot. Are you sure you want to roll it back? Yep We're gonna undo that change I'm gonna go back and open up Windows 7 again. Now Windows 7 is gonna give me an error when it comes on Because it realizes it wasn't shut down properly. Yeah, we're gonna head and start Windows normally. I'm not even gonna bother Doing a file system check on it and it still boots up reasonably fast and There's all the icons on a desktop Team viewer still installed And away you go So it actually lets you take snapshots while the VMs are running The only downside is it's the same as when you restore it as if you just pull the plug on it because you grab the file system As it was at that time So when you reboot it up and Linux does the same thing it goes Hey, this file system was not shut down properly because you grabbed it while it was running But nonetheless it works and I can easily roll back to several versions So you can create these snapshots of your VMs while they're running and be able to restore it I mean granted you're gonna have to deal with the corrupted Possibility of file system corruption of when you took the snapshot But that's generally not big deal because most modern operating systems They're they're somewhat fault tolerant to be able to do with this and you're creating multiple snapshots generally so I create one a day and let them keep for a week and That's how you can you know keep nice safe states of not just your files But things like your VMs and the fact that it's so efficient and the reason being because it's only looking at the changes So even though the VM file is one bot, you know big contiguous file It only sees the changes in that file. That's the only thing it's sacrificing on storage now Let's talk about how we automate the snapshots so you can be worry-free in there So if you look at the snapshot tasks and we'll look at the one right here for example on my pbox store for these I Am keeping one week and I say begin at 4 a.m. And air and do once a day so that means it's going to run here But you can actually change this so if I wanted to change the interval to be hourly 30 minutes 15 minutes you could actually have your file system Going through and taking even more snapshots. I also like when you do this in case you can't wrote you change It highlights the last one you had So If I wanted to have hourly snapshots of things Let's say you're running a mission-critical system that you want hourly changes that you want to be able to go back to you Can set this to one hour and you can set it between these hours to do it So that becomes a very interesting way to do it because it gives you a start and end time So during business hours go ahead and run these snapshots because there's not changes happening after business hours And then how long do you want to keep them one week one day now the important part about this? There's limitations to storage as in there's only so much storage you have so you have to do this Consciously with making sure you have enough storage to do it because eventually you could overrun the system and fill it all up Because someone makes a lot of changes on a production system make sure you plan ahead generally you want the ZFS also To eliminate fragmentation by having plenty of space on the drive By doing this CFS gets more leg room to kind of stretch out and spread the rights across So always over plan as best possible. I know it gets a little pricey But if you over plan your capacity You will have a better time because you can keep more snapshots The ZFS can spread the rights across the drive and it's a more intelligent way to do it But that's my introduction and kind of overview to snapshots and how they work. It's Not too complicated other than the cloning because you have to create that And you have to create the different share if you clone something back But on the other side of it if you just have like I have these clones here I can easily just jump backwards in time and go hey Let me go back to this refer or that you know with my VMs with anything else And you can set it to once a day or like with some of our clients We have a very large raid a raid with them running free nas and we set it up a couple times a day That kind of saves them for people who do things like create data and don't have it backed up in time And then they goof things up So you can just roll back You know our release may be good. It's all decisions you can make but it actually lets you do that and you can do this with VMs Now this also works for other ZFS devices. I haven't tried it But as far as I know it works fine with like the ice cuz the interface You can create block devices and still snapshot them. You can snapshot anything really that you have on Here so if you want to get to the more complicated ones definitely works It's also interesting because that's how GF ZFS and free nas handle the jail system when you create the templates it creates a Snapshots for those templates that way they can easily be restored or cloned To create more features. So if you create a jail and you want to duplicate that jail again You just go ahead and Create a snapshot of it clone it and now you can duplicate that state of one of the free nas jails So thanks again for watching if you like the content here like and subscribe If you have more comments questions or something I wasn't clear about in zfs or if you think this needs a part two To do some type of test scenario. Let me know But hopefully this clears up zfs and snapshots and how they work and why I think they're amazing. Thanks for watching