PLAY GAME NOW

30.04.2024 Let's take a look into ZFS and zpools on FreeBSD


� � 
LIVE � �  � � 


30.04.2024

So this is one that i've been wanting to. make for quite some time. zfs. is one of my favorite features on. freebsd the flexibility that it gives. you for managing big data is just. it's unrivaled if you ask me the only. thing that comes. remotely close is probably seth. but i've not really looked at steph and. i don't intend to just yet. i will do at some point. so zfs what is it well it's a file. manager. and it's a file system. all in one and it's just. takes a lot of the headaches out of. managing file systems and data sets and. it just. it's really good. the only issue you have with zfs is that. you need quite a decent amount of memory. to. to use it. so. let's get on with it shall we. so everything i'm going to do i'm going. to be logged in as root. this is a completely fresh. machine complete fresh install. and we're going to have a quick look at.

What we've got on there at the moment. so let's list our zed pools. just the one. should we list our disks. no because we don't need to. but i'll just have a quick look at what. there is. so as you can see i've got my ada 0. which is the. boot disk. and that's set up as a zroute. and i've got ada1 and ada2 so the things. that we're going to look at. are going to be things like encryption. ddupe. and snapshots. okay so let's have a quick look at. what we can do with it shall we so the. first obvious. step is to actually create. a zed pool. and for this one we'll just do a simple. striped. single disk. from zed pool. create. and we're going to call it test. and it'll be dev. ada1. so there we go that's that's created our. first zed pool so if we now do a zed. pool. list. you should see it there so the test. these are 500 gig spinning disks.

Not very good just old laptop things. so we should be able to see that if we. do a df which will list the file systems. there is test. and it's just mounted it. in the root directory. there you go. so. what about. compression. compression seems to be. a big thing these days to get the most. out of your disk space. even though disks aren't exactly. expensive money is still an issue. so. let's go zfs we're going to change from. zpool to zfs different tool and this is. going to create a file system. right it's going to create a. data set. and let's set the properties. because my stomach's rumbling. there we go. so compression is now on for that data. set. and there you can see. the. two data sets so you've got the the root. data set of test. and you've got the compressed one. so that's good so let's go into our. compressed. data set.

Let's copy an iso over that we can use. to test this. so if i go back one. so we should see it's just under a gig. so if we move into compressed. it's the same size. but. so there we go that that just shows. there is a bit of compression going on. because the file itself. is just. 994 meg. yeah it's listed on the disk as 979.. now that may not seem like a lot. but when you start working with big data. sets. you start to see. and depending on which compression level. you use and we've used gzip with this. um you you might see more compression. okay so let's um cd and let's list our. zed pools. okay we want to get rid of our zed pool. now so let's go zed pull. destroy. nsf. test. so there we go that's now gone so if i. do a df now. completely gone. so we can now use as. said raids. so we'll set up a z raid. now there are two things that we could.

Do here because we've got two disks we. could set up a mirror. which we'll do first so that would be. zed pull. create. give it a name we'll call it test again. what type it is. ada1. and. ada2. so there we go so if we now list the zed. pools. there we go there is azad. our test and again it's the same size as. it was before. but if we do a zedpool. status. this will give us a bit more information. so there we go if you look at it. it's headboard test. and it's a mirror and there's the two. discs and it's online. nice and simple. so let's destroy that. we don't need that one let's create a. stripe now. i wouldn't necessarily. recommend a stripe. with two disks because if you lose one. disk that's it. the whole data is gone but i'll show you. how to do it anyway. and we'll call it test. so there we go you don't need to tell it.

What type of. uh zebra it's going to be so if i now. said pull my list uh simple list. there you go just under a terabyte. do a zpool status. and it shows both the disks online. let's destroy that one. still don't need that one. so what about. raid zed levels. well the problem with raids levels and. we can't do it on this system because we. only got two discs. but it's just as simple so you'd go zed. pull. create. so we could call it whichever late raid. level we want. can we do raids that we might be able to. do a raid zed one ah let's give it a. name. see what happens. yeah. i think it needs. no i've done it the wrong way around. haven't i that's why. let's try that again. okay so let's do it. but i suspect this is just a strike. which it is. okay. so let's destroy that one. but the other raid levels that you could. do. are raised.

To. which we can't do requires at least. three drives. a raid z3. which requires at least four drives. so we can't do much of that. so what about let's create a mirror. again that was. the best one i think. for this setup. so there's our mirror so what about. encryption then. so we do this on. the zfs data set so if we go zfs. create. minus. zero. we go so we've now got a zed pool a zfs. data set that is encrypted. very cool. so we've got our encrypted. data set setup. so there it is. so let's. try a reboot so let's see what happens. shall we. hasn't yet that's interesting. interesting so it didn't. but look at that it's not mounted. but it is mounted. isn't that a strangest thing. anywho. we have an encrypted. um zfs dataset. and there it is at the top. so how can we get. the properties. of our encrypted data set. well. this will be quite an interesting one so.

Let's. let's output this to a file so. zfs. get. all. test. there we go so like i said it's a lot so. we'll output that to a file. so here we go so this should tell you. everything we need to know so what it is. how much space there is what's used what. the compression ratio is is it mounted. which is rather interesting absolute ton. of information about it. and what kind of encryption it's using. so it's using aes256 gcm. okay so if it's not mounted how am i in. that directory. well it creates the directory anyway so. let's get it remounted. i suspect that's not encrypted now. though. oh it is it's still encrypted all right. okay so we just needed to mount it. stupid me so there we go there's a. little overview of zfs. features that we've got. and there is our encrypted. data set ready to go. and ready to use. hope you find this useful guys.

All Devices iOS Android Chromecast