19887
![]() |
|
|
|
|
|||||||
| Howtos & FAQs (Moderated) Would you like to share some of your solutions for certain problems? Tips or tricks? Post here. All new topics are automatically moderated. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
I've been using zfs for some time now on my desktop pc. And finally I decided to share some tips.
Before we start, you need to know that I use geli to encrypt my HDD's. I boot from usb flash. And what I tell may depend on that. I don't intend to explain how to start using ZFS, I want to tell you how to use it and save some problems later. Let's imagine we have fresh zpool named mzfs. 1) set zfs options for your pool that you think would be default in most cases For example, I set: Code:
zfs set copies=2 mzfs zfs set compression=gzip mzfs In addition I do Code:
zfs set mountpoint=none mzfs create mzfs/root and install FreeBSD there. [I will explain later] 3) group jails To group my jails I create filesyste Code:
zfs create mzfs/jails zfs set mountpoint=/jails mzfs/jails Child file systems will have parent fs settings, and will be auto mounted 4) create snapshot for 1 jail use for all of them Now let's imagine you have build your system from sources and want to set up jails. First thing you need to do is create 1 jails, that will be used for all other jails as starting point. Code:
zfs create mzfs/jails/testbox cd /usr/src make buildworld make installworld DESTDIR=/jails/testbox cd etc make distribution DESTDIR=/jails/testbox cd /jails/testbox/etc touch fstab once you have finished editing files, this is the point every jail will have common. Create zfs snapshoot Code:
zfs snapshot mzfs/jails/testbox@fresh zfs clone mzfs/jails/testbox@fresh mzfs/jails/server this jail will be auto mounted I also keep /jails/fstab.JAIL_NAME files (replace JAIL_NAME with jail name) here's sample: Code:
/usr/ports /jails/testbox/usr/ports nullfs noatime,rw 0 0 /usr/src /jails/testbox/usr/src nullfs noatime,ro 0 0 Code:
jail_testbox_hostname="testbox" ifconfig_rl0_alias0="inet 192.168.128.99 netmask 0xffffff00" jail_testbox_ip="192.168.128.99" jail_testbox_rootdir="/jails/testbox" jail_testbox_exec="/bin/sh /etc/rc" jail_testbox_devfs_enable="YES" jail_testbox_fstab="/jails/fstab.testbox" jail_testbox_mount_enable="YES" and copy /jails/fstab.testbox to /jails/fstab.server add new jail to jail list and start it. creating new jails with zfs is very easy, and best of all it takes zero space. 5) Rebuild system from jail Now If you want to have fresh FreeBSD, you can build it in jail simply do what's written in tip 4 after you installed all apps from ports (or whatever you did) stop jail and then edit loader.conf change Code:
vfs.root.mountfrom="zfs:mzfs/root" Code:
vfs.root.mountfrom="zfs:mzfs/root2" Code:
cp /etc/rc.conf /jails/newfreebsd/etc/rc.conf cp /etc/fstab /jails/newfreebsd/etc/fstab and finally run Code:
zfs rename zfs/jails/newfreebsd zfs/root2 This way you will avoid downtime, and won't have to destroy zpool (pretty much no matter what) after reboot you can destroy old system Code:
zfs destroy a/root 6) you may not agree with this On zfs I prefer to not separate /usr /usr/local etc from root. Basically I keep everything I need to run FreeBSD as Desktop under 1 Filsystem. I separate /tmp /usr/src /usr/ports /usr/obj /var/db/portsnap becaue i use different zfs options on them (copies=1 for example) NOTE: don't forget to install kernel on usb flash [or the media you're using to boot from]Fallowing these tips I installed fresh FreeBSD with KDE4.3, just to test KDE, and later switched back to my good old fvwm. I attached tar with my config files, to help you understand what I was saying here. Note, that my fstab is empty. It really is empty on my pc. P.S. If you have questions, post here, I'll answer P.S.S. Now think what would you do if you had your FreeBSD root on zpool root? UPDATE: 7) compression=off Compression sounds, good, but in reality it isn't all that good. 1.) you can't boot from compressed pool 2.) when i was copying data to compressed pool on flash I had huge lags (well compression was high, but still, lags ware HUGE, really HUGE). When I was copying same data, to same flash, but with compression turned off, lags were gone. From now on, i will use compression only on very few parts of systems (ports tree, logs....) UPDATE: Remember that if you need to work with zfs in fixit mode (from fixit cd or dvd), you need to Code:
# mkdir /boot/zfs # ln -s /dist/boot/kernel /boot/kernel # ln -s /dist/lib /lib # kldload zfs UPDATE: If you want to make periodic zfs snapshots you may want to try sysutils/zfsnap UPDATE: in /etc/contab Code:
@reboot root /usr/local/sbin/zfSnap -a 1w -r a/home a/root a/local Last edited by graudeejs; August 29th, 2010 at 10:09. |
| The Following 8 Users Say Thank You to graudeejs For This Useful Post: | ||
|
#2
|
||||
|
||||
|
Thanks killasmurf86! I always look at the manuals when I do a ZFS install on our new Sun Servers. I have to configure ZFS once or twice a year so it is very rare for me to configure ZFS. But now that FreeBSD's ZFS has matured I'll be using it a lot more
.
__________________
- Simplicity is the ultimate sophistication. - Leonardo da Vinci - Intelligence is not defined by what you know, It's how you USE it. - I use the ssh/tcsh desktop environment and it includes the vi control panel. - Carpetsmoker - "Unix is simple. It just takes a genius to understand its simplicity." – Dennis Ritchie |
|
#3
|
||||
|
||||
|
Quote:
Quote:
|
|
#4
|
||||
|
||||
|
Well, I also use encryption.... but perhaps you're right...
Anyway, for my good old Pentium 4, compression=off works better. Thanks for sharing your experience. |
|
#5
|
||||
|
||||
|
thank you for sharing yours! reading you suggestions and thinking a bit about them, i was able to design my own way to upgrade my system
the only noticeable difference from your configuration is that i keep freebsd and the local stuff (ports, /var things, etc.) on different datasets: Code:
# zfs list NAME USED AVAIL REFER MOUNTPOINT tank 44.1G 29.2G 18K none tank/home-albi 34.7G 29.2G 34.7G /home/albi tank/jail-a51 149K 29.2G 203M /usr/jail/groomlake tank/local 2.20G 29.2G 2.20G /usr/local tank/obj 18K 29.2G 18K /usr/obj tank/ports 3.65G 29.2G 3.65G /usr/ports tank/root 204M 29.2G 204M legacy tank/src 296M 29.2G 296M /usr/src tank/swap 3G 31.6G 654M - tank/var 73.0M 29.2G 73.0M /var also, i moved /usr/compat to /usr/local/compat, so that i can get a fresh system at any time and, more interesting, i can replace /usr/local and /var when i like most (i work on kde's area 51 so i often need to test it, and i build it in the a51 jail, with a dataset for $jail/usr/local) to sum up my commands (and to leave a reference for me ):Code:
# cd /usr/src # make update && make buildworld buildkernel # zfs create -o mountpoint=/mnt tank/root-new # make installkernel DESTDIR=/mnt # mergemaster -piD /mnt (probably useless) # make installworld DESTDIR=/mnt # mergemaster -iD /mnt # echo 'clear_tmp_enable="YES"' > /mnt/etc/rc.conf # cp /etc/localtime /mnt/etc (and anything you'd like to have in your fresh jails) # zfs snapshot tank/root-new@8.0-beta3-20090906 # cd /boot && cp loader.conf splash.bmp /mnt/boot # cd /etc && cp $USEFUL_STUFF /mnt/etc # cd /mnt # mkdir cdrom # ln -s usr/local/compat compat # ln -s usr/home home # mkdir boot/zfs && cp /boot/zfs/zpool.cache boot/zfs # vi boot/loader.conf (set vfs.root.mountfrom="zfs:tank/root-new") # zpool set bootfs=tank/root-new tank # zfs set mountpoint=legacy tank/root-new hope this is someway useful
Last edited by avilla@; September 6th, 2009 at 09:09. Reason: move up `zfs snapshot` in the commands stack and add some `cp`'s |
|
#6
|
||||
|
||||
|
Quote:
|
|
#7
|
||||
|
||||
|
Quote:
coming back to tips, may i also suggest compression for swap on a zvol? have a look at this data: Code:
# swapinfo -h Device 1K-blocks Used Avail Capacity /dev/zvol/tank/swap 3145728 416M 2.6G 14% # zfs get compressratio,referenced tank/swap NAME PROPERTY VALUE SOURCE tank/swap compressratio 4.74x - tank/swap referenced 86.9M - here's how i configured my swap zvol: Code:
# zfs get all tank/swap NAME PROPERTY VALUE SOURCE tank/swap type volume - tank/swap creation Mon Sep 7 20:29 2009 - tank/swap used 3G - tank/swap available 30.0G - tank/swap referenced 86.9M - tank/swap compressratio 4.74x - tank/swap reservation none default tank/swap volsize 3G - tank/swap volblocksize 8K - tank/swap checksum off inherited from tank tank/swap compression on inherited from tank tank/swap readonly off default tank/swap shareiscsi off default tank/swap copies 1 default tank/swap refreservation 3G local tank/swap primarycache metadata local tank/swap secondarycache none local tank/swap usedbysnapshots 0 - tank/swap usedbydataset 86.9M - tank/swap usedbychildren 0 - tank/swap usedbyrefreservation 2.92G - tank/swap org.freebsd:swap on local |
|
#8
|
||||
|
||||
|
does swaping work well on freebsd already?
|
|
#9
|
||||
|
||||
|
probably, but swapping 1/5 of the data is obviously better
|
|
#10
|
||||
|
||||
|
I'm not using swap at all, for now (2.5G ram)
It's enough for me even when I build OOO even with Code:
vm.kmem_size="1100M" vm.kmem_size_max="1100M" vfs.zfs.arc_max="600M" |
|
#11
|
|||
|
|||
|
Jail tips are very useful, thanks.
|
|
#12
|
|||
|
|||
|
I think using changes from kmacy's branch with ZIO_USE_UMA enabled can improve I/O performance.
Last edited by john_doe; September 21st, 2009 at 08:28. |
![]() |
| Tags |
| kiss, zfs |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Solaris ZFS | ronaldprettyman | General | 9 | October 13th, 2009 15:24 |
| ZFS v13 | tanked | General | 11 | June 21st, 2009 04:27 |
| Zfs | SuperMiguel | General | 16 | June 5th, 2009 19:29 |
| zfs - to be or not to be | graudeejs | Off-Topic | 47 | May 26th, 2009 09:03 |
| FreeBSD 7 and KDE 3 really laggy, need some tips. | Mikael_L | Installing & Upgrading | 5 | December 10th, 2008 12:26 |