# zfs reserve



## Beeblebrox (Nov 25, 2010)

Creating classic partition schemes under zfs can be done by specifying (as example),
`# zfs set reservation=10G tank0/whatever`thereby fixing a static size for the zfs volume.  However, I would like to understand how to specify disk geometry priority for certain partitions while using zfs file sys.

A clear example is swap with zfs - which is illogical under the initial zfs design, but makes sense when you have several distros (bsd + linux) running on the same disk and want to use 1 swap space for all.  Linux now supports zfs so you can at least place /home, docs, bookmarks on a zfs volume enabling access to your files under any O/S.

But as swap likes to be near the spin center and as a fragmented swap makes absolutely no sense, one would need to not only reserve space, but staticaly own disk "land" by specifying cylinder / block or such. Again, the purpose of doing this is because zfs (as far as I have found) is the only practical file sys currently capable of accommodating both BSD and linux O/S.

Other suggestions / views appreciated.


----------



## graudeejs (Nov 25, 2010)

Create separate partition for swap on all your HDD's.
Can't be more static than that.
Note that Linux unlike FreeBSD needs formated swap....

So if you want to use same partition as swap space for FreeBSD and Linux you need to write custom Linux script to format swap partitions, before using them (there was thread about this on forum, try searching for swap)


----------



## phoenix (Nov 26, 2010)

The whole point of ZFS is to stop worrying about all the nitty gritty details of all your drives.  Just stuff all the storage space into a pool, and create filesystems without all that annoying "partition, label, format, and geometry" crap.

If you're going to lose sleep over it, just plug in a USB stick and configure that as your swap space.


----------



## Beeblebrox (Nov 26, 2010)

Thanks to the both of you for your comments.

@killasmurf86: Yes, am aware of the issue with Linux swap and had already found this:


> While FreeBSD can use any type of partition as swap space, Linux needs a special signature in the swap partition. This signature is made by mkswap. FreeBSD ruins this signature when it uses the shared swap partition, so you will have to run mkswap each time you boot into Linux. To do this automagically you have to find the script that runs swapon at boot time. In Red Hat Linux it is /etc/rc.d/rc.sysinit. Put the following line into that file just before swapon -a:
> 
> awk -- '/swap/ && ($1 !~ /#/) { system("mkswap "$1"") }' /etc/fstab


from this page:  http://www.linux.org/docs/ldp/howto/Linux+FreeBSD-3.html

This is an acceptable problem for me since I plan to make fBSD my primary system and have linux sitting as backup on some faraway slice of the disk. USB stick really not an option...

@phoenix:  Completely agree with your take on the "usage ease" of zfs for crap management.  My concern (and there are threads describing problems exactly with this issue) is that you really do not want a swap which has been fragmented across the disk surface because of a) stability b) speed. It's better to dedicate a surface area of the disk for swap, and conceivably zfs may not be the way to go when you look at the issue from this angle.  However, zfs would add value in the event I should decide to resize the swap space some time in the future...

Idea:  Maybe there's a zfs set command like "contiguous"?


----------



## danbi (Nov 29, 2010)

It is also worth to note, that modern drives (since many years ago) pretty much lie about their real geometry and the OS rarely has any realistic idea about heads, cylinders and such. Not surprisingly, ATA and SCSI spec deal with logical blocks.

On your comment to phoenix's suggestion, I would add that if you have the resources to use ZFS on your system, without tuning it much (which is the whole point), that is, sufficient amount of RAM, then you are unlikely to worry much about swap 'performance'. If you need very finely tuned system that has limited resources -- you will spend lots of efforts, to achieve say 5-10% improvement in performance (typically) at the cost of many, many hours. And, which is worse, will have to redo this tuning each time you upgrade or change something. ZFS is made to address this type of concern.

On my workstation, with 8GB RAM and ZFS, I actually use swap over ZFS. Didn't notice any slowness, it's all KDE and pretty much loaded


```
last pid:  9185;  load averages:  1.54,  0.97,  0.91                           up 16+18:48:30  13:37:25
310 processes: 2 running, 306 sleeping, 2 zombie
CPU: 68.2% user,  0.0% nice, 13.7% system,  0.0% interrupt, 18.0% idle
Mem: 1696M Active, 590M Inact, 3990M Wired, 112M Cache, 691M Buf, 1455M Free
Swap: 4035M Total, 517M Used, 3518M Free, 12% Inuse
```

By the way, it was running happily without swap at all, because of typo on my part. The only trouble was the occasional killing of thunderbird, when that grows well over 2GB


----------

