ZFS and FreeBSD Jails

6,172 views

Published on

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,172
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
48
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

ZFS and FreeBSD Jails

  1. 1. ZFS and FreeBSD Jails apeiron (old Greek word for ∞) apeiron@cpan.org fosscon 2012Saturday, August 11, 12
  2. 2. A stroll dive down the rabbit hole This wont hurt a bit (that may or may not be a facsimile of me when working)Saturday, August 11, 12http://www.flickr.com/photos/stars6/4381851322/in/photostream/
  3. 3. Some FreeBSD mythbusting Fully functional Unix Server, desktop, router, firewall, etc. >23000 third-party applications in the ports tree Probably not the best desktop; well-suited to a server Has most of the cool features from Solaris; will be talking about one and a half of them todaySaturday, August 11, 12
  4. 4. One and a half? This talk discusses ZFS and FreeBSD jails ZFS, of course, comes from Solaris This talk also covers FreeBSD jails When creating zones, the Solaris devs used jails as an inspirationSaturday, August 11, 12
  5. 5. ZFS The Zettabyte File SystemSaturday, August 11, 12http://www.flickr.com/photos/ess-jay/2438565511/
  6. 6. What the heck is a Zettabyte, anyway? 2^70 bytes ZFS is meant to scale far beyond the current and projected possible future limitations of hardware The theoretical maximum filesystem size is 256 quadrillion zettabytes Thats 256,000,000,000,000,000 zettabytes Thats 256,000,000,000,000,000 * 2^70 bytesSaturday, August 11, 12
  7. 7. Feature summary Resource forks Built-in software RAID POSIX attributes and Snapshots ACLs COW data model (cheap Compression snapshots (very important for us)) Encryption Caching Deduplication Too much for one slide Built-in volume managerSaturday, August 11, 12
  8. 8. Things well talk about today Volume manager Snapshots COW data modelSaturday, August 11, 12
  9. 9. Volume manager The ZFS volume manager provides native striping Makes it easy to add heterogenous disks to a pool No more worrying about getting geometries exactly the same Creates a nice abstraction from the physical layerSaturday, August 11, 12
  10. 10. Snapshots Theyre exactly what they say on the tin Take a snapshot of the filesystem and its there when you want it You can do all kinds of cool things with them, like send them over the network and clone themSaturday, August 11, 12
  11. 11. COW Data Model The COW model is really where ZFS shines for containers COW (copy on write): if two copies of a snapshot have the same data, only one copy exists on disk until a clone writes to a file; then, a copy is made for the delta This makes snapshots, clones, and thus jails quick and cheap to create Absolutely critical to the container use caseSaturday, August 11, 12
  12. 12. Lets be Jailbirds You may pay me $50 to get outSaturday, August 11, 12
  13. 13. Some FreeBSD background FreeBSD boots via /sbin/init like any other Unix /sbin/init runs /etc/rc, which sources /etc/rc.conf /etc/rc.conf controls which services start at boot, and also configures things like IP addresses, default route, and jailsSaturday, August 11, 12
  14. 14. Jails: Not just chroot(2) Everything lives under a directory mounted on the FS You can access the jail via chroot, but you dont get all the wins with this technique Every jail has at least one IPv4/IPv6 address Lightweight Lots of management tools Advanced technique: run Linux in a jailSaturday, August 11, 12
  15. 15. Some jail tools jexec jailrc jls jailuser jailadmin jailutils jailctl jkill jailer jps jailme ... and so onSaturday, August 11, 12
  16. 16. How jails work Install enough of FreeBSD to boot (/sbin/init calls /etc/ rc, which boots the system) Generally do this by building + installing source tree Then configure the jail and start it Well be using the more flexible jailrc from the ports tree, rather than the default scriptSaturday, August 11, 12
  17. 17. Still not as cool as Zones But pretty closeSaturday, August 11, 12http://www.flickr.com/photos/paldorslate/1761863421/
  18. 18. What does this get us? It turns out that it gets us lots of cool stuffSaturday, August 11, 12http://www.flickr.com/photos/daikrieg/1294053038/
  19. 19. Basic workflow summary Create a zpool Snapshot Create a filesystem Clone desired environment or base as Install base jail to desired filesystem ??? Snapshot Profit! Create desired environmentSaturday, August 11, 12
  20. 20. Some workflows this supports Per-developer dev environments Dev/staging/QA/etc./prod Dev/prod ProdSaturday, August 11, 12
  21. 21. Show Example jailrc ConfigSaturday, August 11, 12
  22. 22. Per-developer container Create base jail Create snapshot Clone as necessary per developer hack hack hack... Push changes up to git repo / etc.Saturday, August 11, 12
  23. 23. Dev/staging/QA/etc./prod Create base jail Snapshot Clone for dev zfs send | zfs recv for staging/qa/etc./prod If something passes a stage, promote it to the next- closest to prodSaturday, August 11, 12
  24. 24. Dev/prod Like dev/etc./prod but more cowboyish With ZFS its still better than other filesystems Snapshots mean its easy to fix mistakes when they make it into prod (no workflow prevents mistakes getting to prod) Just clone from a working snapshot and goSaturday, August 11, 12
  25. 25. Prod Even more cowbowish than dev/prod This is the sort of thing where developers work directly on production Unwise, but ZFS makes it less suck Snapshots save the daySaturday, August 11, 12
  26. 26. Live (prepared) demo!Saturday, August 11, 12
  27. 27. Bibliography FreeBSD Handbook ZFS Administration Guide jailrc manpageSaturday, August 11, 12
  28. 28. Questions?Saturday, August 11, 12

×