pavement

ZFS, creating datasets for the FreeBSD system

From FreeBSDwiki
Revision as of 09:55, 15 May 2010 by Jimbo (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Some admins may wish to create a customized set of datasets tailored to the FreeBSD system itself; ie configuring compression for the ports directory (but not distfiles!), turning execution off on directories like /var/db, etc.

Be warned that, should you choose to do this, you will create additional complexity you must maintain and wade through when monitoring the system - for one relatively trivial example, you will have an additional sixteen filesystems showing up in the output of df!

Fixit# zfs create -o compression=on    -o exec=on      -o setuid=off   zroot/tmp
Fixit# chmod 1777 /zroot/tmp

Fixit# zfs create zroot/usr
Fixit# zfs create zroot/usr/home
Fixit# zfs create -o compression=lzjb  -o setuid=off   zroot/usr/ports 
Fixit# zfs create -o compression=off   -o exec=off     -o setuid=off   zroot/usr/ports/distfiles
Fixit# zfs create -o compression=off   -o exec=off     -o setuid=off   zroot/usr/ports/packages

Note: If you use nullfs or nfs to mount /usr/ports to different locations/servers, you will also need to nullfs/nfs mount /usr/ports/distfiles and/or /usr/ports/packages.

Fixit# zfs create zroot/var
Fixit# zfs create -o exec=off     -o setuid=off   zroot/var/empty
Fixit# zfs create -o exec=off     -o setuid=off   zroot/var/db
Fixit# zfs create -o exec=off     -o setuid=off   zroot/var/run
Fixit# zfs create -o compression=lzjb  -o exec=off     -o setuid=off   zroot/usr/src
Fixit# zfs create -o compression=lzjb  -o exec=off     -o setuid=off   zroot/var/crash
Fixit# zfs create -o compression=lzjb  -o exec=on      -o setuid=off   zroot/var/db/pkg
Fixit# zfs create -o compression=lzjb  -o exec=off     -o setuid=off   zroot/var/log
Fixit# zfs create -o compression=gzip  -o exec=off     -o setuid=off   zroot/var/mail
Fixit# zfs create -o compression=lzjb  -o exec=on      -o setuid=off   zroot/var/tmp
Fixit# chmod 1777 /zroot/var/tmp

Notes: Compression may be set to on, off, lzjb, gzip, gzip-N (where N is an integer from 1 (fastest) to 9 (best compresion ratio. gzip is equivalent to gzip-6). Compression will cause some latency when accessing files on the ZFS filesystems. Use compression on ZFS filesystems which will not be accessed that often.

Personal tools