building freenas using nanobsd - freebsd.org personal …imp/bsdcan2011-slides.pdf · building...

36
Building FreeNAS using NanoBSD Warner Losh [email protected] The FreeBSD Project BSDCan 2011 — Ottawa, Canada 14 May 2010 http://people.freebsd.org/~imp/bsdcan2011-slides.pdf

Upload: duongdung

Post on 23-Dec-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

Building FreeNAS using NanoBSD

Warner [email protected]

The FreeBSD Project

BSDCan 2011 — Ottawa, Canada14 May 2010

http://people.freebsd.org/~imp/bsdcan2011-slides.pdf

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Outline

1 Background and Context

2 NanoBSD Overview

3 Runtime Environment

4 Case Study – FreeNAS

5 Build Walkthrough

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Outline

1 Background and Context

2 NanoBSD Overview

3 Runtime Environment

4 Case Study – FreeNAS

5 Build Walkthrough

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Overview

• Creating FreeBSD images for specialized purposes.

• NanoBSD: goals and non-goals

• NanoBSD new features

• FreeNAS case study

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

What is NanoBSD

• A shell script

• Builds FreeBSD

• Creates FreeBSD System Tree

• Creates Image for Target Media

• Provides Run–Time Environment Based on Diskless

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

What is FreeNAS

• FreeBSD–based NAS System

• NanoBSD–based

• Django–based GUI with Mysql Database

• MVC Architecture

• Merges Mysql Database with /etc/rc.conf

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Outline

1 Background and Context

2 NanoBSD Overview

3 Runtime Environment

4 Case Study – FreeNAS

5 Build Walkthrough

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

NanoBSD Overview

• What is NanoBSD (detailed)

• What NanoBSD isn’t

• Example at end, if time

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

What is NanoBSD?

• Collection of Metadata

• Shell Script to Build “stuff”

• Standard Scripts for Target

• Customized Files for Target

• Framework

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

What is Metadata?

• What Architecture to Use

• What Subset of FreeBSD to Build

• What Subset to Install on Image

• What Packages to Install

• How Big to Make Flash

• Overriding Default Behavior

• Other Customization Functions

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

What is “Stuff”?

• FreeBSD base (src tree, user land and kernel)

• Images of Partitions

• Images of CF/SD/etc cards

• uboot Images

• Administrative Databases

• Your Changes Here

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Standard Scripts

• /root/updatep1, /root/updatep2, /root/update

• /root/cfg save

• /root/change password

• /root/save sshkeys

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Customizations

• Customization via Shell Script

• Include Trees on Target

• Partition Image

• Memory Disks

• Extra Partitions/FS to Mount

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

What NanoBSD Isn’t

• Configuration Management System

• Source Code Control

• Build System (limited cases)

• Build Orchestration (limited cases)

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Common Uses

• Embedded Boxes

• Appliances

• Jail Factory

• VM maker

• Standardized Test Images

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Examples

• FreeNAS

• BSDRP

• Examples from the Studio Audience

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

9.0 Improvements (some merged)

• Generic Flash

• Better /data Support

• More Configuration Knobs

• Optionally use UFS labels (media independent booting)

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Future Improvements

• Package/Ports (maybe 9 with luck)

• Maybe a NanoBSDng?

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Outline

1 Background and Context

2 NanoBSD Overview

3 Runtime Environment

4 Case Study – FreeNAS

5 Build Walkthrough

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Process

• NanoBSD Config File

• Build w/NanoBSD

• Boot NanoBSD• Diskless Environment• Read Only Code• Data in RAM• Save to Disk

• Upgrade

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Disk Layout

• MBR (4 partitions s1-s4)

• s1 and s2 are system partitions

• s3 is optional configuration data (mostly r/o)

• s4 is optional data (can be r/w)

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Diskless Environment

• / read only

• /etc md copied from /conf/base/etc and /cfg

• /var md copied from /conf/base/var

• /mnt md to hold mount points

• /cfg for config (unmounted)

• /data for r/w data

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Outline

1 Background and Context

2 NanoBSD Overview

3 Runtime Environment

4 Case Study – FreeNAS

5 Build Walkthrough

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS

• NAS Box

• ZFS

• Django GUI with full AJAX

• Back End

• Upgrade via GUI

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS Build

• Custom Build Script• Checkout FreeBSD src• Checkout FreeBSD ports• Apply patches• Build FreeBSD with NanoBSD

• Custom Packaging Script• Package NanoBSD on LiveCD• Package NanoBSD Update Blobs

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS Build

• NanoBSD Customizations• Build Packages from Ports (cached)• Build “pure” Database• Support for Cross Building (limited)

• Cross Building• Building i386 on amd64• w/o package cache: arm

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS GUI

• Django

• Dojango

• lighttpd

• custom backend

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS Screen Shot

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS Screen Shot

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS Screen Shot

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS Screen Shot

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Database

• Mysql Database

• Lives on /data Partition (rw)

• Migrations (up/down grade)

• All admin data here

• Inflexible for experts, easy to update, backup for novice

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Backend

• Converts database data to FreeBSD formats

• Shell scripts

• Built into /etc/rc system

• Changes triggered from Django GUI

• Changes triggered from Console Menu GUI

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Outline

1 Background and Context

2 NanoBSD Overview

3 Runtime Environment

4 Case Study – FreeNAS

5 Build Walkthrough

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

FreeNAS Build and Config files

Repohttps://freenas.svn.sourceforge.net/svnroot/freenas/trunk

Exampleshttp://people.freebsd.org/~imp/bsdcan2011-freenas-common

http://people.freebsd.org/~imp/bsdcan2011-common

http://people.freebsd.org/~imp/bsdcan2011-do-build.sh

Warner Losh Building FreeNAS using NanoBSD

Background and ContextNanoBSD Overview

Runtime EnvironmentCase Study – FreeNAS

Build WalkthroughQuestions/Comments

Questions? Comments?Warner [email protected]

http://people.freebsd.org/~imp/bsdcan2011-slides.pdf

Warner Losh Building FreeNAS using NanoBSD