April 2007 Archives

上帝把两群羊放在草原上,一群在南,一群在北。上帝还给羊群找了两种天敌, 一种是狮子,一种是狼。  上帝对羊群说:“如果你们要狼,就给一只,任它随意咬你们。如果你们要狮子,就给两头,你们可以在两头狮子中任选一头,还可以随时更换。”南边那群 羊想,狮子比狼凶猛得多,还是要狼吧。于是, 它们就要了一只狼。北边那群羊想,狮子虽然比狼凶猛得多,但我们有选择权,还是要狮子吧。于是,它们就要了两头狮子。  那只狼进了南边的羊群后,就开始吃羊。狼身体小,食量也小,一只羊够它吃几天了。  这样羊群几天才被追杀一次。北边那群羊挑选了一头狮子,另一头则留在上帝那里。这头狮子进入羊群后, 也开始吃羊。狮子不但比狼凶猛,而且食量惊人,每天都要吃一只羊。这样羊群就天天都要被追杀,惊恐万状。羊群赶紧请上帝换一头狮子。不料,上帝保管的那头 狮子一直没有吃东西,正饥饿难耐,它扑进羊群,比前面那头狮子咬得更疯狂。羊群一天到晚只是逃命,连草都快吃不成了。   南边的羊群庆幸自己选对了天敌,又嘲笑北边的羊群没有眼光。北边的羊群非常后悔,向上帝大倒苦水, 要求更换天敌,改要一只狼。上帝说:“天敌一旦确定,就不能更改,必须世代相随, 你们唯一的权利是在两头狮子中选择。”  北边的羊群只好把两头狮子不断更换。可两头狮子同样凶残,换哪一头都比南边的羊群悲惨得多,它们索性不换了,让一头狮子吃得膘肥体壮,另一头狮子则饿得精瘦。眼看那头瘦狮子快要饿死了,羊群才请上帝换一头。  这头瘦狮子经过长时间的饥饿后,慢慢悟出了一个道理:自己虽然凶猛异常,一百只羊都不是对手,可是自己的命运是操纵在羊群手里的。羊群随时可以把自 己送回上帝那里,让自己饱受饥饿的煎熬,甚至有可能饿死。想通这个道理后,瘦狮子就对羊群特别客气,只吃死羊和病羊,凡是健康的羊它都不吃了。羊群喜出望 外,有几只小羊提议干脆固定要瘦狮子,不要那头肥狮子了。  一只老公羊提醒说:“瘦狮子是怕我们送它回上帝那里挨饿,才对我们这么好。万一肥狮子饿死了,我们没有了选择的余地,瘦狮子很快就会恢复凶残的本性。”羊群觉得老羊说得有理,为了不让另一头狮子饿死,它们赶紧把它换回来。  原先膘肥体壮的那头狮子,已经饿得只剩下皮包骨头了,并且也懂得了自己的命运是操纵在羊群手里的道理。为了能在草原上待久一点,它竟百般讨好起羊群来。而那头被送交给上的狮子,则难过得流下了眼泪。 北边的羊群在经历了重重磨难后,终于过上了自由自在的生活。南边的那群羊的处境却越来越悲惨了,那只狼因为没有竞争对手,羊群又无法更换它,它就胡 作非为,每天都要咬死几十只羊,这只狼早已不吃羊肉了,它只喝羊心里的血。它还不准羊叫,哪只叫就立刻咬死哪只。南边的羊群只能在心中哀叹:“早知道这 样,还不如要两头狮子。” PS:我生活在南边.........

ZFS quick start

|

Pawel Jakub Dawidek pjd at FreeBSD.org
Fri Apr 6 21:43:39 UTC 2007


Ok, ZFS is now in the tree, what's now? Below you'll find some
instructions how to quickly make it up and running.

First of all you need some disks. Let's assume you have three spare SCSI
disks: da0, da1, da2.

Add a line to your /etc/rc.conf to start ZFS automatically on boot:

        # echo 'zfs_enable="YES"' >> /etc/rc.conf

Load ZFS kernel module, for the first time by hand:

        # kldload zfs.ko

Now, setup one pool using RAIDZ:

        # zpool create tank raidz da0 da1 da2

It should automatically mount /tank/ for you.

Ok, now put /usr/ on ZFS and propose some file systems layout.  I know
you probably have some files already, so we will work on /tank/usr
directory and once we ready, we will just change the mountpoint to /usr.

        # zfs create tank/usr

Create ports/ file system and enable gzip compression on it, because
most likely we will have only text files there. On the other hand, we
don't want to compress ports/distfiles/, because we keep compressed
stuff already in-there:

        # zfs create tank/usr/ports
        # zfs set compression=gzip tank/usr/ports
        # zfs create tank/usr/ports/distfiles
        # zfs set compression=off tank/usr/ports/distfiles

(You do see how your life is changing, don't you?:))

Let's create home file system, my own home/pjd/ file system. I know we
use RAIDZ, but I want to have directory where I put extremly important
stuff, you I'll define that each block has to be stored in tree copies:

        # zfs create tank/usr/home
        # zfs create tank/usr/home/pjd
        # zfs create tank/usr/home/pjd/important
        # zfs set copies=3 tank/usr/home/pjd/important

I'd like to have directory with music, etc. that I NFS share. I don't
really care about this stuff and my computer is not very fast, so I'll
just turn off checksumming (this is only for example purposes! please,
benchmark before doing it, because it's most likely not worth it!):

        # zfs create tank/music
        # zfs set checksum=off tank/music
        # zfs set sharenfs=on tank/music

Oh, I almost forget. Who cares about access time updates?

        # zfs set atime=off tank

Yes, we set it only on tank and it will be automatically inherited by
others.

Will be also good to be informed if everything is fine with our pool:

        # echo 'daily_status_zfs_enable="YES"' >> /etc/periodic.conf

For some reason you still need UFS file system, for example you use ACLs
or extended attributes which are not yet supported by our ZFS. If so,
why not just use ZFS to provide storage? This way we gain cheap UFS
snapshots, UFS clones, etc. by simply using ZVOLs.

        # zfs create -V 10g tank/ufs
        # newfs /dev/zvol/tank/ufs
        # mount /dev/zvol/tank/ufs /ufs

        # zfs snapshot tank/ufs at 20070406
        # mount -r /dev/zvol/tank/ufs at 20070406 /ufs20070406

        # zfs clone tank/ufs at 20070406 tank/ufsok
        # fsck_ffs -p /dev/zvol/tank/ufsok
        # mount /dev/zvol/tank/ufsok /ufsok

Want to encrypt your swap and still use ZFS? Nothing more trivial:

        # zfs create -V 4g tank/swap
        # geli onetime -s 4096 /dev/zvol/tank/swap
        # swapon /dev/zvol/tank/swap.eli

Trying to do something risky with your home? Snapshot it first!

        # zfs snapshot tank/home/pjd at justincase

Turns out it was more stupid than risky? Rollback your snapshot!

        # zfs rollback tank/home/pjd at justincase
        # zfs destroy tank/home/pjd at justincase

Ok, everything works, we may set tank/usr as our real /usr:

        # zfs set mountpoint=/usr tank/usr

Don't forget to read zfs(8) and zpool(8) manual pages and SUN's ZFS
administration guide:

        http://www.opensolaris.org/os/community/zfs/docs/zfsadmin.pdf

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20070406/d16eb0ea/attachment.pgp

About this Archive

This page is an archive of entries from April 2007 listed from newest to oldest.

March 2007 is the previous archive.

May 2007 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.1