1 * <lisp>(setq Title "FreeNAS0.68开发人员手册")</lisp>
2 - 作者: [[http://www.freenas.org][FreeNAS Projects Team]]
3 - 翻译,改编: [[stoneszone.net][石磊]]
16 *** 1.2 配置User 和 Shell
17 **** 1.2.1 安装Bash Shell
19 $pkg_add -r bash #(-r 表示使用远程下载:ftp)
23 $chpass username #(更改用户的登录shell=/usr/local/bin/bash,chpass实际会修改/etc/passwd文件)
25 $cp .profile .bash_profile
38 *** 1.3 升级FreeBSD宿主系统源代码树
40 CVSup 用于从远程服务器主机上的主CVS仓库发布和升级源代码树的软件包。用户可以用其保持其源代码树更新。
43 $pkg_add -r cvsup-without-gui
47 CVSup的配置文件为/etc/supfile,可以参考/usr/share/examples/cvsup/下的模板文件撰写(具体参考FreeBSD用户手册 附录A)
50 $cp /usr/share/examples/cvsup/stable-supfile /etc/supfile
51 $cp /usr/share/examples/cvsup/ports-supfile /etc/ports-supfile
54 编辑/etc/supfile和/etc/ports-suppfile,寻找并更改下面,表示从那个站点下载
55 *default host=cvsup.fr.FreeBSD.org
61 $cvsup -g -L 2 /etc/supfile
62 $cvsup -g -L 2 /etc/ports-supfile
66 **** 1.4.1 配置/etc/make.conf
67 安装完所有的FreeBSD的Patches,使用动态库重新编译所有的程序,来节约磁盘空间
68 编辑 /etc/make.conf 加入(可参考/usr/share/examples/etc/make.conf更改/etc/make.conf)
75 $make -j4 buildworld #在/usr/obj下建立一个全新的stable树,-j4表示并行编译4个程序
76 $make buildkernel #建立新的stable缺省内核
77 $make installkernel #安装内核
82 启动时使用单用户模式,给loader传入参数 boot -s
84 $fsck -p #使用preen模式检测文件系统,仅仅修复一部分错误,遇到特殊错误会报错并退出
85 $mount -u / #装载根分区。 -u 表示一个已经mount的磁盘状态应该改变
86 $mount -a -t ufs #-a 表示mount /etc/fstab所有后面 -t 表示的ufs文件系统
87 $swapon -a #打开交换分区。-a 表示使用所有 /etc/fstab中列出的swap,除了noauto
88 $adjkerntz -i #保持cmos中的local和kernel中的UTC时间的offset,-i表示将 adjkerntz 加入启动和关闭中来自动运行,/etc/rc中会加入相应条目。
89 $mergemaster -p #安装系统配置文件的脚本工具,建立一个临时的根环境,把新的配置文件映射到这个环境
91 $make installworld #安装新的stable程序树
93 $mergemaster #更新/etc配置文件,需要与用户交互,如果是新安装的系统,则直接更新
103 $pkg_add -r portupgrade #安装portupgrade工具,来简化port升级过程
104 $portversion -l "<" #显示需要升级的port
105 $portupgrade -arR #开始升级port,-a升级所有已安装且过时的程序 -r按照依赖关系递归的升级 -R按照需要关系递归的升级
109 安装FreeNAS需要的工具和PHP脚本,如果指令不是很清楚,下载FreeNAS的根文件系统.tgz文件并与你安装的相比较来进行分析。
113 $export WORKINGDIR="/usr/local/freenas"
114 $export FREENAS="/usr/local/freenas/rootfs"
115 $export BOOTDIR="/usr/local/freenas/bootloader" #引导程序
116 $export CDROOT="/usr/local/freenas/cdroot" #生成最终cd iso文件的目录
122 $mkdir /usr/local/freenas
124 **** 2.2.2 生成最小root文件系统
125 下载freenas-create-dir.sh,其内容为:
130 # This script was written by David Courtney of Ultradesic
131 # http://www.ultradesic.com
132 # E-Mail Contact: minibsd@ultradesic.com
134 # Adapted for FreeNAS by Olivier Cochard-Labbé (http://www.freenas.org)
135 # Modified by Volker Theile (votdev@gmx.de)
137 MINIBSD_DIR=/usr/local/freenas/rootfs;
139 # Initialize variables.
142 # Parse the command-line options.
143 while getopts 'fh' option
147 "h") echo "$(basename $0): Create FreeNAS directory structure";
148 echo "Common Options:";
149 echo " -f Force executing this script";
151 ?) echo "$0: Bad option specified. Exiting...";
156 shift `expr $OPTIND - 1`
158 echo "Create FreeNAS directory structure..."
160 if [ ! -z "$1" ]; then
162 echo "Using directory $1.";
165 if [ 1 != $opt_f -a -d "$MINIBSD_DIR" ]; then
167 echo "$MINIBSD_DIR already exists. Remove the directory" ;
168 echo "before running this script." ;
179 mkdir boot ; # fdisk 和bsdlabel使用
180 mkdir boot/kernel ; # 保存kernel 模块
182 mkdir cf ; # 用于挂载Compact Flash card , Hard disk ..
183 mkdir ftmp ; # 用于通过WebGUI进行防火墙升级时挂载临时的内存文件系统
184 mkdir conf.default ; # 保存出厂时的默认配置文件config.xml
188 mkdir etc/inc ; # 保存boot脚本和WebGUI所需要的php include文件
205 mkdir usr/local/lib ;
206 mkdir usr/local/sbin ;
207 mkdir usr/local/share ;
208 mkdir usr/local/share/locale ;
209 mkdir usr/local/etc ;
210 mkdir usr/local/www ; # WebGUI文件
211 mkdir usr/local/www/syntaxhighlighter ;
214 mkdir usr/share/misc ;
215 mkdir usr/share/locale ;
219 # Creating symbolic links. Most of the target files will be created at runtime.
220 # 大多数的连接目标文件在FreeNAS运行时生成
222 ln -s /var/run/htpasswd usr/local/www/.htpasswd #在webGUI运行时用户配置的user/passwd会保存在/var/run/htpasswd中
223 ln -s /var/etc/resolv.conf etc/resolv.conf
224 ln -s /var/etc/master.passwd etc/master.passwd
225 ln -s /var/etc/passwd etc/passwd
226 ln -s /var/etc/group etc/group
227 ln -s /var/etc/hosts etc/hosts
228 ln -s /var/etc/pwd.db etc/pwd.db
229 ln -s /var/etc/spwd.db etc/spwd.db
230 ln -s /var/etc/crontab etc/crontab
231 ln -s /var/etc/ssh/sshd_config etc/ssh/sshd_config
232 ln -s /var/etc/ssh/ssh_host_dsa_key etc/ssh/ssh_host_dsa_key
233 ln -s /var/etc/iscsi/targets etc/iscsi/targets
234 ln -s /var/etc/pam.d/ftp etc/pam.d/ftp
235 ln -s /var/etc/pam.d/ftp etc/pam.d/pure-ftpd
236 ln -s /var/etc/pam.d/sshd etc/pam.d/sshd
237 ln -s /var/etc/pam.d/login etc/pam.d/login
238 ln -s /var/etc/pam.d/system etc/pam.d/system
239 ln -s /var/etc/ldap.conf usr/local/etc/ldap.conf
240 ln -s /var/etc/nsswitch.conf etc/nsswitch.conf
241 ln -s /libexec/ld-elf.so.1 usr/libexec/ld-elf.so.1
246 下载 freenas.files 和 mkmini.pl
247 - freenas.files 包含所有的Freenas需要的二进制文件
253 $perl mkmini.pl freenas.files / $FREENAS
259 # List of files required for a the FreeNAS,
260 # intended to be parsed by mkmini.pl (script created by Manuel Kasper <mk@neon1.net>)
262 # Lines with colons (':') in them list files that should be hard-linked
263 # to each other, e.g.
265 # instructs mkmini.pl to copy over bin/link, then hard link ln to it.
267 ####### contents of /bin
269 ## Test: condition evaluation utility
272 ## cat -- concatenate and print files
275 ## chmod -- change file modes
281 ## tcsh - C shell with file name completion and command line editing
284 ## date -- display or set date and time
287 ## dd -- convert and copy a file
290 ## df -- display free disk space
293 ## echo -- write arguments to the standard output
296 ## expr -- evaluate expression
299 ## hostname -- set or print name of current host system
302 ## kill -- terminate or signal a process
305 ## ln, link -- make links
308 ## ls -- list directory contents
311 ## mkdir -- make directories
317 ## pax -- read and write file archives and copy directory hierarchies
320 ##ps -- process status
323 ##pwd -- return working directory name
324 #Prevent WinSCP to Generate Error message
327 ## rm, unlink -- remove directory entries
330 ##sh -- command interpreter (shell)
333 ## sleep -- suspend execution for an interval of time
336 ## stty -- set the options for a terminal device interface
339 ## sync -- force completion of pending disk writes (flush cache)
343 ####### contents of /sbin
344 # adjkerntz -- adjust local time CMOS clock to reflect time zone changes and keep current timezone offset for the kernel
347 ## bsdlabel -- read and write disk pack label
350 ##devfs -- DEVFS control (NEW from FreeBSD 5.2, replace the )
353 ## dhclient -- Dynamic Host Configuration Protocol (DHCP) client
356 ## dhclient-script -- DHCP client network configuration script
359 ## dmesg -- display the system message buffer
362 ## reboot, halt, fastboot, fasthalt -- stopping and restarting the system
363 sbin/fastboot:sbin/fasthalt:sbin/halt:sbin/reboot
365 ## fdisk -- PC slice table maintenance utility
368 ## fsck -- file system consistency check and interactive repair
371 ## fsck -- UFS,FFS 4.2BSD file system consistency check and interactive repair
372 sbin/fsck_ufs:sbin/fsck_ffs:sbin/fsck_4.2bsd
374 ## fsck -- DOS/WINDOWS file system consistency check and interactive repair
377 ## Gconcat -- Geom concat
380 # Growfs -- grow size of an existing ufs file system
383 ## gstripe -- Geom stripe
386 ## gmirror -- Geom mirror
389 # geli -- Control utility for cryptographic GEOM class
392 ## gpt -- Manipulate GUID partition tables
395 ## gvinum -- Volume manager (RAID0,1,5)
398 ## ifconfig -- configure network interface parameters
401 ## init -- process control initialization
404 ## kldload -- load a file into the kernel
407 ## kldstat -- display status of dynamic kernel linker
410 ## kldunload -- unload a file from the kernel
413 ## ldconfig -- configure the shared library cache
416 # mdconfig -- configure and enable memory disks
419 ## mknod -- build special file
422 ## mount -- mount file systems
425 ## mount_std, mount_devfs, mount_fdescfs, mount_linprocfs, mount_procfs -- mount ``standard'' file systems
426 sbin/mount_devfs:sbin/mount_fdescfs:sbin/mount_linprocfs:sbin/mount_procfs:sbin/mount_std:
428 ## mdmfs, mount_mfs -- configure and mount an in-memory file system using the md(4) driver
431 ## mount_nullfs -- mount a loopback file system sub-tree; demonstrate the use of a null file system layer
434 ## mount_umapfs -- sample file system layer
437 ## mount_unionfs -- mount union file systems
440 ## mount_msdosfs -- mount MS-DOS file system
443 ## mount_nfs -- mount NFS file system
446 ## mount_nfs4 -- mount NFSv4 file system
449 ## mount_ntfs -- mount NTFS file system: Replaced by NTFS-3G
452 ## mount_ext2fs -- mount ext2fs file system
455 ## mount_cd9660 -- mount CDROM file system
458 ## mount_reiserfs -- mount ReiserFS file system
461 ## mount_udf -- mount UDF file system
464 ## natd -- Network Address Translation daemon
467 ## newsfs -- construct a new UFS1/UFS2 file system
470 ## newsfs -- construct a FAT (16/32) file system
473 ##nologin -- politely refuse a login
476 ## ping -- send ICMP ECHO_REQUEST packets to network hosts
479 ## route -- manually manipulate the routing tables
482 ## shutdown -- close down the system at a given time
485 ##sysctl -- get or set kernel state
488 ## swapon - Enable swap
491 ## swapoff - Disable swap
494 ##tunefs -- tune up an existing file system
497 ## umount -- unmount file systems
500 # atacontrol: manage IDE disk
503 # camcontrol: manage SCSI disk
506 ####### contents of /usr/bin
507 # chgrp: change group
510 # fstat -- identify active files . Fuse mount use fstat
513 ## FTP/HTTP download tools
516 ## This utility prevent WinSCP to display error message
519 ## gzip, gunzip, zcat - compress or expand files
520 usr/bin/gzip:usr/bin/gunzip
522 ## id - displays the user and group names and numeric IDs, of the calling process
525 ## killall -- kill processes by name
528 ## logger -- make entries in the system log
531 ## netstat -- show network status
534 ## nohup -- invoke a utility immune to hangups
537 ## passwd -- Change user passwd
540 ## su -- substitute user identity
543 ##scp -- secure copy (remote file copy program)
546 ##ssh -- secure Shell Client (used for RSYNC and Unison over SSH)
547 # FreeNAS use the port openssh-portable with HPN-SSH patch enabled
550 ## tail -- display the last part of a file
553 ## tar -- manipulate tape archives
556 ## top - display and update information about the top cpu processes
559 ## touch -- create/change file access and modification times
562 ## uptime -- show how long system has been running
563 usr/bin/uptime:usr/bin/w
566 ####### contents of /usr/sbin
567 ## ancontrol -- configure Aironet 4500/4800 devices
570 ## arp -- address resolution display and control
573 #boot0cfg -- boot manager installation/configuration utility
576 ## chown -- change file owner and group
579 ##chroot -- change root directory
582 ## cron - The scheduler
585 ## powerd -- System power control utility
588 ## pwd_mkdb -- generate the password databases
591 ## swapinfo - Give info on the swap disk
594 ## traceroute - print the route packets take to network host
597 # wicontrol -- configure Lucent, Intersil, and Atheros wireless devices
607 # sshd - Daemon program for ssh
608 # FreeNAS use the port openssh-portable with HPN-SSH patch enabled
611 ####### contents of /usr/libexec
612 # ld-elf.so.1, ld.so, rtld -- run-time link-editor
613 libexec/ld-elf.so.1:usr/libexec/ld-elf.so.1
616 # FreeNAS use the port openssh-portable with HPN-SSH patch enabled
617 #usr/libexec/sftp-server
619 ####### contents of /usr/share/misc
620 usr/share/misc/termcap
622 ####### contents of /usr/share/locale
623 usr/share/locale/en_US.ISO8859-1/*
624 usr/share/locale/en_US.UTF-8/*
625 usr/share/locale/la_LN.US-ASCII/*
626 usr/share/locale/UTF-8/*
628 ####### contents of /usr/local/bin
629 # nano - a small, free and friendly editor: IT's a port!!!
632 ####### contents of /usr/lib
636 ####### contents of /lib/geom
640 ####### contents of /etc/ssh
641 # moduli -- system moduli file
648 **** 2.4.1 安装etc和PHP配置脚本
649 下载freenas-etc.tgz 并解压缩至$FREENAS/目录
651 $fetch http://www.freenas.org/downloads/freenas-etc.tgz
652 $tar -xzf freenas-etc.tgz -C $FREENAS/
654 并且确保/etc/rc下的rc.*文件有执行权限 chmod 755
656 **** 2.4.2 其他注意事项 (自己写,未验证)
657 在主机生成$FREENAS/etc/master.passwd并拷贝至$FREENAS/etc/,通过下列命令生成newpasssword数据库(pwd.db和spwd.db) -p表示重新生成/etc/passwd
659 $pwd_mkdb -p -d $FREENAS/etc $FREENAS/etc/master.passwd
660 $tar cfvz freenas-tgz $FRRRNAS/etc/* #为了节省空间,???
664 /etc/platform文件非常重要,它标识出image是由什么系统生成的,php脚本使用它确定配置存储在何处以及webGUI中应该显示出的option。可以设置为以下值:
668 $echo "0.67b" > $FREENAS/etc/version
669 $date > $FREENAS/etc/version.buildtime
670 $echo "generic-pc-cdrom">$FREENAS/etc/platform
673 **** 2.4.4 配置 config.xml
674 下载最新的默认配置文件http://www.freenas.org/downloads/config.xml
675 拷贝至$FREENAS/conf.defalut/config.xml
677 $cd $FREENAS/conf.default/
678 $fetch http://www.freenasw.org/downloads/config.xml
682 FreeNAS将时区信息保存在/usr/share/zoneinfo中,为了保存空间,m0n0wall使用一个stripped down的版本,并将其打包tar...
684 $cd $FREENAS/usr/share
685 $fetch http://www.freenas.org/downloads/zoneinfo.tgz
689 *** 2.5.1 添加A100U2 U2W-SCSI-Controller驱动程序
693 $fetch http://www.freenas.org/downloads/bsd4a100.zip
695 $cp a100.* /usr/src/sys/pci
696 $echo "pci/a100.c optional ihb device-driver" >> /usr/src/sys/conf/files
703 $fetch http://www.freenas.org/downloads/FREENAS
707 $config FREENAS #config 命令产生内核源代码,并命名为FREENAS
708 $cd ../compile/FREENAS/ #进入编译目录
709 $make cleandepend;make depend #编译
711 $gzip -9 kernel #压缩编译出的内核
716 $cp /sys/i386/compile/FREENAS/modules/usr/src/sys/modules/geom/geom_vinum/geom_vinum.ko $FREENAS/boot/kernel
717 $cp /sys/i386/compile/FREENAS/modules/usr/src/sys/modules/geom/geom_stripe/geom_stripe.ko $FREENAS/boot/kernel
718 $cp /sys/i386/compile/FREENAS/modules/usr/src/sys/modules/geom/geom_concat/geom_concat.ko $FREENAS/boot/kernel
719 $cp /sys/i386/compile/FREENAS/modules/usr/src/sys/modules/geom/geom_mirror/geom_mirror.ko $FREENAS/boot/kernel
720 $cp /sys/i386/compile/FREENAS/modules/usr/src/sys/modules/geom/geom_gpt/geom_gpt.ko $FREENAS/boot/kernel
721 ####$cp /sys/i386/compile/FREENAS_GENERIC/modules/usr/src/sys/modules/ntfs/ntfs.ko $FREENAS/boot/kernel
722 $cp /sys/i386/compile/FREENAS/modules/usr/src/sys/modules/ext2fs/ext2fs.ko $FREENAS/boot/kernel/
725 *** 2.5.4 添加试验版本的geom RAID 5模块
728 $fetch http://home.tiscali.de/cmdr_faako/geom_raid5.tbz
729 $tar zxvf geom_raid5.tbz
730 $cd /usr/src/sys/modules/geom/geom_raid5/
733 $cp geom_raid5.ko $FREENAS/boot/kernel/
734 $cd /usr/src/sbin/geom/class/raid5/
735 $mkdir /usr/include/geom/raid5
736 $cp /usr/src/sys/geom/raid5/g_raid5.h /usr/include/geom/raid5/
740 $cp -p /sbin/graid5 $FREENAS/sbin/
741 $mkdir $FREENAS/lib/geom/
742 $cp geom_raid5.so $FREENAS/lib/geom/
748 $cp /boot/mbr $FREENAS/boot/
753 **** 2.6.1.1 安装 libxml2
757 **** 2.6.1.2 下载并解压PHP5.2 http://www.php.net
759 $./configure --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect --without-mysql --without-pear --with-openssl --without-sqlite --with-pcre-regex
761 $install -s sapi/cgi/php $FREENAS/usr/local/bin
764 **** 3.6.1.3 写配置文件$FREENAS/usr/local/lib/php.ini
766 magic_quotes_gpc = Off
767 magic_quotes_runtime = Off
768 max_execution_time = 0
770 register_argc_argv = Off
772 upload_tmp_dir = /ftmp
773 upload_max_filesize = 256M
776 include_path = ".:/etc/inc:/usr/local/www"
781 $fetch http://www.lighttpd.net/download/lighttpd-1.4.13.tar.gz
782 $tar zxvf lighttpd-1.4.13.tar.gz
784 $./configure --sysconfdir=/var/etc/ --enable-lfs --without-mysql --without-ldap --with-openssl --without-lua --with-bzip2 --without-pam
786 $install -s src/lighttpd $FREENAS/usr/local/sbin
787 $mkdir $FREENAS/usr/local/bin/lighttpd
788 $cp src/.libs/mod_indexfile.so $FREENAS/usr/local/lib/lighttpd/
789 $cp src/.libs/mod_access.so $FREENAS/usr/local/lib/lighttpd/
790 $cp src/.libs/mod_accesslog.so $FREENAS/usr/local/lib/lighttpd/
791 $cp src/.libs/mod_dirlisting.so $FREENAS/usr/local/lib/lighttpd/
792 $cp src/.libs/mod_staticfile.so $FREENAS/usr/local/lib/lighttpd/
793 $cp src/.libs/mod_cgi.so $FREENAS/usr/local/lib/lighttpd/
794 $cp src/.libs/mod_auth.so $FREENAS/usr/local/lib/lighttpd/
795 $cp src/.libs/mod_webdav.so $FREENAS/usr/local/lib/lighttpd/
800 clog程序记录所有到子网的连接。它使用pcap 库。
802 $fetch http://www.freenas.org/downloads/clog-1.0.1.tar.gz
803 $fetch http://www.freenas.org/downloads/syslogd_clog-current.tgz
804 $tar zxvf clog-1.0.1.tar.gz
805 $tar zxvf syslogd_clog-current.tgz
808 $install -s syslogd $FREENAS/usr/sbin/
811 $install -s clog $FREENAS/usr/sbin/
815 MSNTP为SNTP客户端,与NTP和SNTP服务器通讯显示和设置本地系统时间。可运行于交互模式,cron,或者daemon。
817 $cd /usr/ports/net/msntp/
819 $install -s work/msntp-1.6/msntp $FREENAS/usr/local/bin/
822 配置$FREENAS/usr/local/bin/runmsntp.sh并更改为可执行权限。
826 # write our PID to file
829 # execute msntp in endless loop; restart if it
830 # exits (wait 1 second to avoid restarting too fast in case
831 # the network is not yet setup)
833 /usr/local/bin/msntp -r -P no -l $2 -x $3 $4
839 ataid处理ata协议硬盘在空闲时间放低转速。
841 $cd /usr/ports/sysutils/ataidle
843 $install -s work/ataidle-0.9/ataidle $FREENAS/usr/local/sbin/
846 *** 2.6.6 iscsi initiator
848 $fetch ftp://ftp.cs.huji.ac.il/users/danny/freebsd/iscsi-2.0.1.tar.bz2
849 $tar zxvf iscsi-2.0.1.tar.bz2
853 $cd modules/iscsi_initiator
857 $cp iscsi_initiator.ko $FREENAS/boot/kernel/
858 $cd ../../../iscontrol/
860 $install -s iscontrol $FREENAS/usr/local/sbin/
866 $fetch http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz
867 $tar zxvf pure-ftpd-1.0.21.tar.gz
869 $./configure --with-rfc2640 --with-largefile --with-pam
871 $install -s src/pure-ftpd $FREENAS/usr/local/sbin/
874 *** 2.6.8 samba (CIFS server)
876 fetch http://us2.samba.org/samba/ftp/samba-latest.tar.gz
878 tar zxvf samba-latest.tar.gz
880 cd samba-3.0.23d/source/
882 ./configure --without-cups --with-ads --disable-cups --without-ads --with-pam --with-ldapsam --with-acl-support --with-winbind --with-pam_smbpass --with-logfilebase=/var/log/samba --with-piddir=/var/run --with-privatedir=/var/etc/private --with-configdir=/var/etc --with-lockdir=/var/run --with-piddir=/var/run --with-shared-modules=idmap_rid --with-pammodulesdir=/usr/local/lib --with-syslog
888 install -s bin/smbd $FREENAS/usr/local/sbin/
890 install -s bin/nmbd $FREENAS/usr/local/sbin/
892 install -s bin/winbindd $FREENAS/usr/local/sbin/
894 install -s bin/smbpasswd $FREENAS/usr/local/bin/
896 install -s bin/net $FREENAS/usr/local/bin/
898 install -s nsswitch/nss_winbind.so $FREENAS/usr/local/lib/
900 install -s nsswitch/nss_wins.so $FREENAS/usr/local/lib/
902 install -s bin/pam_winbind.so $FREENAS/usr/local/lib/
904 ln -s $FREENAS/usr/local/lib/nss_winbind.so $FREENAS/usr/local/lib/nss_winbind.so.1
906 mkdir $FREENAS/usr/local/samba/lib/idmap
908 mkdir $FREENAS/usr/local/samba/lib/vfs
910 install -s bin/rid.so $FREENAS/usr/local/samba/lib/idmap
912 mkdir $FREENAS/usr/local/lib/samba
914 mkdir $FREENAS/usr/local/lib/samba/charset
916 mkdir $FREENAS/usr/local/lib/samba/rpc
918 mkdir $FREENAS/usr/local/lib/samba/pdb
920 cp bin/CP*.so $FREENAS/usr/local/lib/samba/charset
922 cp codepages/*.dat $FREENAS/usr/local/lib/samba/
924 cp po/*.* $FREENAS/usr/local/lib/samba/
926 cp bin/recycle.so $FREENAS/usr/local/samba/lib/vfs
931 $cp /usr/sbin/nfsd $FREENAS/usr/sbin
932 $cp /usr/sbin/mountd $FREENAS/usr/sbin
933 $cp /usr/sbin/rpcbind $FREENAS/usr/sbin
937 Netatalk使用AppleTalk协议,为Apple电脑提供文件服务。
939 **** 2.6.10.1 安装Database Berkeley port
941 $cd /usr/ports/databases/db42
948 fetch http://ovh.dl.sourceforge.net/sourceforge/netatalk/netatalk-2.0.3.tar.gz
950 tar zxvf netatalk-2.0.3.tar.gz
954 ./configure --bindir=/usr/local/bin --sbindir=/usr/local/sbin --sysconfdir=/var/etc --localstatedir=/var --enable-largefile --disable-tcp-wrappers --disable-cups --with-pam --with-uams-path=/etc/uams/
956 install -s etc/afpd/afpd $FREENAS/usr/local/sbin/
958 mkdir $FREENAS/etc/uams
960 cp etc/uams/.libs/uams_passwd.so $FREENAS/etc/uams
962 cp etc/uams/.libs/uams_dhx_passwd.so $FREENAS/etc/uams
964 cp etc/uams/.libs/uams_guest.so $FREENAS/etc/uams
966 cp etc/uams/.libs/uams_randnum.so $FREENAS/etc/uams
970 ln -s uams_passwd.so uams_clrtxt.so
972 ln -s uams_dhx_passwd.so uams_dhx.so
974 cd $FREENAS/usr/local/lib/
976 cp /usr/local/lib/libdb-4.2.so.2 .
980 cp /usr/lib/librpcsvc.so.3 .
984 RSYNC数据镜像和备份工具。本地/远程,目录之间进行快速同步镜像,远程数据备份等。仅仅更新变动部分。
986 $fetch http://samba.anu.edu.au/ftp/rsync/rsync-2.6.9.tar.gz
987 $tar zxvf rsync-2.6.9.tar.gz
989 $./configure --with-rsyncd-conf=/var/etc
991 $install -s rsync $FREENAS/usr/local/bin/
995 Unison 目录文件同步工具,与rsync不同为,它同步是双向的。
997 $cd /usr/ports/net/unison/
999 $cp work/unison-2.13.16/unison $FREENAS/usr/local/bin/
1003 为采用ssh加密的sftp提供一个安全的chroot环境,它可以生成一个scponlyc的shell,只能运行scp / sftp等命令,且于rsync,svn,gftp兼容。
1006 $cd /usr/ports/shells/scponly/
1010 WITH_SCPONLY_RSYNC=YES
1012 WITH_SCPONLY_SCP=YES
1014 WITH_SCPONLY_WINSCP=YES
1016 WITH_SCPONLY_UNISON=YES
1018 WITH_SCPONLY_SFTP_LOGGING=YES
1024 $install -s work/scponly-4.4/scponly $FREENAS/usr/local/bin/
1027 *** 2.6.14 openssh-portable with HPN patch
1029 编辑/usr/ports/security/openssh-portable/Makefile
1031 HPN "Enable HPN-SSH patch" on \
1036 $install -vs work/openssh-4.5p1/sshd $FREENAS/usr/sbin/
1037 $install -vs work/openssh-4.5p1/sftp-server $FREENAS/usr/libexec/
1042 cd /usr/ports/sysutils/fusefs-kmod
1046 cp -pv work/fuse4bsd-*/mount_fusefs/mount_fusefs $FREENAS/usr/local/sbin/
1048 cp -pv work/fuse4bsd-*/fuse_module/fuse.ko $FREENAS/boot/kernel
1050 cd /usr/ports/sysutils/fusefs-ntfs/
1054 cp -p work/ntfs-3g-0.20070118-BETA/libntfs-3g/.libs/libntfs-3g.so $FREENAS/usr/local/lib/libntfs-3g.so.0
1056 install -s work/ntfs-3g-0.20070118-BETA/src/.libs/ntfs-3g $FREENAS/usr/local/bin/
1058 install -s /usr/local/lib/libfuse.so.2 $FREENAS/usr/local/lib/
1063 $cd /usr/ports/sysutils/e2fsprogs/
1065 $install -s work/e2fsprogs-1.39/e2fsck/e2fsck $FREENAS/usr/local/sbin/
1070 $cd /usr/ports/sysutils/smartmontools/
1072 $install -s work/smartmontools-5.37/smartctl $FREENAS/usr/local/sbin/
1073 $install -s work/smartmontools-5.37/smartd $FREENAS/usr/local/sbin/
1077 Adaptec SCSI RAID 管理工具,可以用来监控RAID卡状态。
1079 $cd /usr/ports/sysutils/aaccli/
1081 $tar zxvf work/aaccli-1.0_0.tgz
1082 $cp work/bin/aaccli $FREENAS/usr/local/bin/
1087 $cd /usr/ports/audio/beep
1089 $install -s work/beep/beep $FREENAS/usr/local/bin/
1092 *** 2.6.20 mDNSReponder (Apple bonjour)
1093 一种apple的无须配置的网络连接方式。
1095 $cd /usr/ports/net/mDNSResponder
1097 $install -s work/mDNSResponder-108/mDNSPosix/build/prod/mDNSResponderPosix $FREENAS/usr/local/sbin/
1100 *** 2.7 构建boot loader
1101 使用freenas-create-bootdir.sh生成引导需要的文件。
1106 # This script was written by David Courtney of Ultradesic
1107 # http://www.ultradesic.com
1108 # E-Mail Contact: minibsd@ultradesic.com
1110 # Adapted for m0n0wall on FreeBSD 6.1 by Olivier Cochard-Labbé (http://www.freenas.org)
1111 # Modified by Volker Theile (votdev@gmx.de)
1113 MINIBSD_DIR=/usr/local/freenas/bootloader;
1115 # Initialize variables.
1121 # Parse the command-line options.
1122 while getopts 'adfhs' option
1129 "h") echo "$(basename $0): Build boot loader";
1130 echo "Common Options:";
1131 echo " -a Disable ACPI"
1132 echo " -d Enable debug"
1133 echo " -s Enable serial console";
1134 echo " -f Force executing this script";
1136 ?) echo "$0: Bad option specified. Exiting...";
1141 shift `expr $OPTIND - 1`
1143 echo "Building the boot loader..."
1145 if [ -n "$1" ]; then
1147 echo "Using directory $1."
1150 if [ 1 != $opt_f -a -d "$MINIBSD_DIR" ]; then
1152 echo "=> $MINIBSD_DIR already exists. Remove the directory"
1153 echo "=> before running this script."
1155 echo "=> Exiting..."
1160 # Create the boot directory that will contain boot, and kernel
1162 mkdir $MINIBSD_DIR/defaults
1163 mkdir $MINIBSD_DIR/kernel
1165 # Copy the file in this directory:
1166 cp -v /boot/defaults/loader.conf $MINIBSD_DIR/defaults
1167 cp -v /boot/loader $MINIBSD_DIR
1168 cp -v /boot/boot $MINIBSD_DIR
1169 cp -v /boot/mbr $MINIBSD_DIR
1170 cp -v /boot/cdboot $MINIBSD_DIR
1171 cp -v /boot/loader.4th $MINIBSD_DIR
1172 cp -v /boot/support.4th $MINIBSD_DIR
1173 cp -v /boot/device.hints $MINIBSD_DIR
1175 # Generate the loader.rc file using by bootloader
1176 echo "Generate $MINIBSD_DIR/loader.rc"
1177 echo 'include /boot/loader.4th
1179 check-password' > $MINIBSD_DIR/loader.rc
1181 # Generate the loader.conf file using by bootloader
1182 echo "Generate $MINIBSD_DIR/loader.conf"
1183 echo 'mfsroot_load="YES"
1184 mfsroot_type="mfs_root"
1185 mfsroot_name="/mfsroot"
1186 autoboot_delay="-1"' > $MINIBSD_DIR/loader.conf
1188 if [ 0 != $opt_d ]; then
1189 echo 'verbose_loading="YES"' >> $MINIBSD_DIR/loader.conf
1190 echo 'boot_verbose=""' >> $MINIBSD_DIR/loader.conf
1192 # Enable serial console?
1193 if [ 0 != $opt_s ]; then
1194 echo 'console="comconsole"' >> $MINIBSD_DIR/loader.conf
1198 if [ 0 != $opt_a ]; then
1199 echo 'hint.acpi.0.disabled="1"' >> $MINIBSD_DIR/device.hints
1203 if [ -e "/usr/obj/usr/src/sys/FREENAS/kernel.gz" ] ; then
1204 cp /usr/obj/usr/src/sys/FREENAS/kernel.gz $MINIBSD_DIR/kernel
1206 echo "=> ERROR: File kernel.gz does not exist!";
1214 为MBR(位于硬盘1扇区)。对应LILO。使用boot0cfg安装,默认基于/boot/boot0。446字节。
1215 MBR 包括主引导程序、硬盘分区表且以0x55AA结尾。显示可选择的引导操作系统。
1216 可以用FreeBSD的MBR覆盖现有的MBR
1217 $fdisk -B -b /boot/boot0 device
1218 device为要写入的磁盘名,如ad0,ad2(ide);da0(scsi)
1221 与boot2都属于同一个程序/boot/boot,处于磁盘的相同区域(文件系统外,引导分区的第一个轨道,第一个扇区),但由于空间限制,被分为两部分。可以使用bsdlabel更改。
1222 - boot1 识别存储这分区信息的bsdlabel,并寻找执行boot2。
1223 - boot2 可以理解FreeBSD的文件系统,可以选择内核和加载器。
1226 最后阶段,放置在文件系统中,为/boot/loader.
1229 3.1 探测控制台和磁盘,识别从那个盘引导,来设置变量
1231 3.2 读取运行/boot/loader.rc ,loader.rc读取/boot/defaults/loader.conf设置默认变量
1233 3.3 loader.rc读取/boot/loader.conf对读取/boot/defaults/loader.conf的变量作本地修改。
1236 需要的动态连接库还没有添加。通过下载mklibs.pl并在root文件系统上运行来创建。
1239 $fetch http://www.freenas.org/downloads/mklibs.pl
1240 $perl mklibs.pl $FREENAS > freenas.libs
1241 $perl mkmini.pl freenas.libs / $FREENAS
1242 $cp -p /usr/lib/pam_*.so.3 $FREENAS/usr/lib
1243 $cd /usr/ports/security/pam_ldap/
1245 $cp -p /usr/local/lib/pam_ldap.so $FREENAS/usr/local/lib
1246 $cp /libexec/ld-elf.so.1 $FREENAS/libexec
1247 $mkdir $FREENAS/lib/geom
1253 下载FreeNAS GUI 文件并拷贝他们到$FREENAS/usr/local/www
1254 确保所有的.php文件有执行权限 chmod 755
1257 $fetch http://www.freenas.org/downloads/freenas-gui.tgz
1258 $tar -zxvf freenas-gui.tgz -C $FREENAS
1262 创建一个压缩的系统文件,它被用来运行在RAM disk上。其中为根文件系统,不包括引导程序。
1263 首先下载并运行freenas-create-msfroot.sh脚本来创建一个用0填充的image文件。目前的大小为32MB。如果你添加了大的部件,需要提高其容量。
1266 $fetch http://www.freenas.org/downloads/freenas-create-msfroot.sh
1267 $./freenas-create-msfroot.sh
1274 # Generate the mfs ROOT file system
1278 WORKINGDIR="/usr/local/freenas"
1279 FREENAS="/usr/local/freenas/rootfs"
1280 CDROOT="/usr/local/freenas/cdroot"
1281 BOOTDIR="/usr/local/freenas/bootloader"
1283 #lauching the script
1286 if [ $WORKINGDIR/mfsroot.gz ] ; then
1288 echo "mfsroot.gz already exists. Removing this file" ;
1290 rm $WORKINGDIR/mfsroot.gz;
1294 # umount the /mnt directory
1297 # Remove the memory file
1300 # Create a 32Mb empty file
1301 dd if=/dev/zero of=$WORKINGDIR/mfsroot bs=1k count=32768
1303 # Configure this file as a virtual disk
1304 mdconfig -a -t vnode -f $WORKINGDIR/mfsroot -u 0
1306 # Create Label on this disk
1307 bsdlabel -w md0 auto
1310 newfs -b 8192 -f 1024 -o space -m 0 /dev/md0c
1313 mount /dev/md0c /mnt
1315 # Copy the file on it
1317 tar -cf - -C $FREENAS ./ | tar -xvpf -
1320 # umount the /mnt directory
1323 # Remove the memory file
1329 - mdconfig 创建并使用内存磁盘
1332 <example> $mdconf -d -u 4 </example>
1333 释放/dev/md4使用的所有资源。 -d 从系统释放内存磁盘并释放所有的资源。
1334 -u 指定一个md设备单元号,而不使用自动生成的。
1338 <example> $mdconfig -a -t vnode -f diskimage -u 0</example>
1342 malloc: 使用malloc分配空间
1343 vnode: 与之后的-f filename配合,用该文件保存内存磁盘内容
1344 swap: 使用swap空间保存内存磁盘的内容
1345 -dd 把指定的输入文件转换到输出文件,并可以进行格式转换。
1347 <exmaple>$dd if=/dev/zero of=newimage bs=1k count=5k</example>
1352 count: 只拷贝输入的多少块(次),每次单位为bs字节
1356 fdisk用来划分主分区(slice),它的操作对象是硬盘的第一个扇区(MBR),在MBR中写入标准引导程序(boot0),以及主分区的分区信息。
1358 bsdlabel用来在主分区中划分逻辑分区,操作对象是硬盘中主分区的第一个扇区,用来写入boot1和boot2,以及位于该主分区中的逻辑分区的分区信息以及标识号。
1362 $bsdlabel -B -w /dev/ad0s1 auto
1364 -B 表示在该主分区ad0s1中写入该主分区的引导记录boot1,boot2。
1366 auto表示 在主分区中自动划出一个逻辑分区
1371 $newfs -b 8192 -f 1024 -o space -m 0 /dev/md0c
1375 -o 优化选项 space 或者是 time
1382 $tar -cf - -C $FREENAS ./ | tar -xvpf -
1388 *** 2.11 创建image (为了hard drive 或 CF)
1389 与创建mfsroot类似。使用freenas-create-image.sh
1393 $fetch http://freenas.org/downloads/freenas-create-image.sh
1394 $./freenas-create-image.sh
1401 # FreeNAS script for generating .img
1404 FREENAS="/usr/local/freenas/rootfs"
1405 WORKINGDIR="/usr/local/freenas"
1406 CDROOT="/usr/local/freenas/imgroot"
1407 BOOTDIR="/usr/local/freenas/bootloader"
1408 PLATFORM="generic-pc"
1409 VERSION=`cat $FREENAS/etc/version`
1410 ISOFILENAME="FreeNAS-$PLATFORM-$VERSION.img"
1412 # Remove old directory
1413 if [ -d $CDROOT ] ; then
1415 echo "$CDROOT already exists. Removing this directory" ;
1422 if [ $WORKINGDIR/$ISOFILENAME ] ; then
1424 echo "$ISOFILENAME already exists. Removing this directory" ;
1427 rm $WORKINGDIR/$ISOFILENAME;
1431 echo $PLATFORM > $FREENAS/etc/platform
1432 date > $FREENAS/etc/version.buildtime
1433 $WORKINGDIR/freenas-create-mfsroot.sh
1434 echo Generating $CDROOT folder
1437 #Creating a 16Mb empty file
1438 dd if=/dev/zero of=image.bin bs=1k count=18432
1440 #use this file as a virtual RAM disk
1441 mdconfig -a -t vnode -f image.bin -u 0
1443 #Create partition on this disk
1444 fdisk -BI -b $BOOTDIR/mbr /dev/md0
1446 #Create label on this disk
1447 bsdlabel -B -w -b $BOOTDIR/boot /dev/md0 auto
1448 bsdlabel md0 >/tmp/label.$$
1452 sed "s/unused/4.2BSD/" >>/tmp/label.$$
1453 bsdlabel -R -B md0 /tmp/label.$$
1456 #Create filesystem on this disk
1457 newfs -b 8192 -f 1024 -o space -m 0 /dev/md0a
1460 mount /dev/md0a $CDROOT
1461 cp $WORKINGDIR/mfsroot.gz $CDROOT
1463 mkdir $CDROOT/boot/kernel $CDROOT/boot/defaults
1465 cp $FREENAS/conf.default/config.xml $CDROOT/conf
1466 cp $BOOTDIR/kernel/kernel.gz $CDROOT/boot/kernel
1467 cp $BOOTDIR/boot $CDROOT/boot
1468 cp $BOOTDIR/loader $CDROOT/boot
1469 cp $BOOTDIR/loader.conf $CDROOT/boot
1470 cp $BOOTDIR/loader.rc $CDROOT/boot
1471 cp $BOOTDIR/loader.4th $CDROOT/boot
1472 cp $BOOTDIR/support.4th $CDROOT/boot
1473 cp $BOOTDIR/defaults/loader.conf $CDROOT/boot/defaults/
1474 cp $BOOTDIR/device.hints $CDROOT/boot
1478 mv image.bin.gz $ISOFILENAME
1480 # Cleaning directory and temp file
1481 if [ $WORKINGDIR/mfsroot.gz ] ; then
1483 echo "cleaning mfsroot.gz" ;
1485 rm $WORKINGDIR/mfsroot.gz
1488 if [ -d $CDROOT ] ; then
1490 echo "cleaning $CDROOT by Removing this directory" ;
1498 **** 2.12.1 安装CDRTools
1499 在创建可引导CD之前,我们必须安装CDRTools
1502 $cd /usr/ports/sysutils/cdrtools
1507 **** 2.12.2 创建可引导iso文件
1508 使用freenas-create-cd.sh
1511 $fetch http://www.freenas.org/downloads/freenas-create-cd.sh
1512 $./freenas-create-cd.sh
1519 # FreeNAS script for generating iso file
1520 FREENAS="/usr/local/freenas/rootfs"
1521 WORKINGDIR="/usr/local/freenas"
1522 CDROOT="/usr/local/freenas/cdroot"
1523 BOOTDIR="/usr/local/freenas/bootloader"
1524 PLATFORM="generic-pc-cdrom"
1525 VERSION=`cat $FREENAS/etc/version`
1526 ISOFILENAME="FreeNAS-$VERSION.iso"
1528 #remove old directory
1529 if [ -d $CDROOT ] ; then
1531 echo "$CDROOT already exists. Removing this directory" ;
1532 echo "before running this script." ;
1534 #echo "Exiting..." ;
1540 echo "$PLATFORM" > $FREENAS/etc/platform
1541 date > $FREENAS/etc/version.buildtime
1542 $WORKINGDIR/freenas-create-mfsroot.sh
1544 rm $WORKINGDIR/$ISOFILENAME
1545 echo Generating $CDROOT folder
1547 cp $WORKINGDIR/mfsroot.gz $CDROOT
1549 mkdir $CDROOT/boot/kernel $CDROOT/boot/defaults
1550 cp $BOOTDIR/kernel/kernel.gz $CDROOT/boot/kernel
1551 cp $BOOTDIR/cdboot $CDROOT/boot
1552 cp $BOOTDIR/loader $CDROOT/boot
1553 cp $BOOTDIR/loader.conf $CDROOT/boot
1554 cp $BOOTDIR/loader.rc $CDROOT/boot
1555 cp $BOOTDIR/loader.4th $CDROOT/boot
1556 cp $BOOTDIR/support.4th $CDROOT/boot
1557 cp $BOOTDIR/defaults/loader.conf $CDROOT/boot/defaults/
1558 cp $BOOTDIR/device.hints $CDROOT/boot
1560 ###### BEGIN: NEW RELEASE CHANGE ######
1561 $WORKINGDIR/freenas-create-image.sh
1562 cp $WORKINGDIR/FreeNAS-generic-pc-$VERSION.img $CDROOT/FreeNAS-generic-pc.gz
1563 ###### END: NEW RELEASE CHANGE ######
1565 mkisofs -b "boot/cdboot" -no-emul-boot -A "FreeNAS CD-ROM image" -c "boot/boot.catalog" -d -r -publisher "freenas.org" -p "Olivier Cochard" -V "freenas_cd" -o "$ISOFILENAME" $CDROOT
1567 if [ -d $CDROOT ] ; then
1569 echo "Cleaning directory" ;