【更新2012/11/28】FreeBSD9使用ZFS作root安装脚本,支持raid0/1/5/10及4K对齐!
本帖最后由 iceblood 于 2012-11-28 09:43 编辑freebsd_zfs_inst.sh使用说明
脚本介绍:
这是一个快速将FreeBSD系统以ZFS文件格式形式安装的脚本,并且连根分区以及SWAP分区都已经以ZFS文件系统形式存在。使用该脚本需要你有一点FreeBSD基本知识,比如网络的设置等。
注意事项:
使用该脚本前请确认该服务器里所有硬盘的所有数据都已经备份或者不再需要,因为脚本会删除所有硬盘的所有数据。
安装方法:
一、首先使用FreeBSD 9.0以后版本的光盘启动服务器。
二、进入SHELL模式
三、使用ifconfig设置IP地址及默认网关(具体方法请自行参考其他资料)
四、下载freebsd_zfs_inst.sh脚本到/tmp文件夹
五、执行脚本,命令如下:
cd /tmp
chmod 755 freebsd_zfs_inst.sh
./freebsd_zfs_inst.sh normal
六、支持模式:普通、RAID1、RAID5、RAID10
普通安装模式是将所有硬盘以条带的形式组合成一个超级大硬盘。如果您的系统已经有硬RAID,基本都可以用此方法安装。
RAID1安装模式会将2个大小一样的硬盘组合成镜像模式,这样保证系统的可靠性。
RAID5将3个以上硬盘组合成N-1的容量模式,速度更快。
RAID10将多个RAID1组合成一个超级大硬盘,速度和安全两者都兼具的模式。
另外您还可以修改脚本里的SWAP参数。
# SWAP分区为4G
SWAPSIZE=4G
当这个地方设置为空的时候,将自动分配SWAP大小,默认按照当内存小于4G的时候SWAP为2倍内存,当内存大于4G的时候,SWAP和内存大小一致的方式来设置。
安装完毕后网络配置、以及各种服务配置请自行解决。
硬盘损坏后的恢复:
注意事项:只有在RAID1和RAID5模式才支持不丢数据的硬盘更换。并且只能在原来损坏的硬盘的盘位上进行更换。并且损坏的硬盘数必须只能1个。
一、正常关闭服务器。
二、拔掉坏硬盘,在原来的位置换上新硬盘。(必须保证新盘的大小和原来的一致)
三、正常启动服务器。(如果无法启动可能是因为BIOS里设置启动的那个盘损坏,修改调换为用其他硬盘启动即可。)
四、下载replacehd.sh到服务器。
五、开始执行更换命令:
1、查看是哪一个硬盘损坏。
zpool status
2、开始替换,假设替换的硬盘为da0
./replacehd.sh da0
安装完毕后的效果:
# zpool status
pool: BSDROOT
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
BSDROOT ONLINE 0 0 0
raidz1-0ONLINE 0 0 0
ada0p2ONLINE 0 0 0
ada1p2ONLINE 0 0 0
ada2p2ONLINE 0 0 0
da0p2 ONLINE 0 0 0
errors: No known data errors
# df -h
Filesystem Size Used Avail CapacityMounted on
BSDROOT 7.4G 212M 7.2G 3% /
devfs 1.0k 1.0k 0B 100% /dev
BSDROOT/home 7.2G 31k 7.2G 0% /home
BSDROOT/tmp 7.2G 35k 7.2G 0% /tmp
BSDROOT/usr 7.4G 216M 7.2G 3% /usr
BSDROOT/var 7.2G 244k 7.2G 0% /var
# swapinfo
Device 1K-blocks Used Avail Capacity
/dev/zvol/BSDROOT/swap 4194304 04194304 0%
RAID10默认安装效果:
# zpool status
pool: ICEBLOOD
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
ICEBLOOD ONLINE 0 0 0
mirror-0ONLINE 0 0 0
ada0p2ONLINE 0 0 0
ada1p2ONLINE 0 0 0
mirror-1ONLINE 0 0 0
da0p2 ONLINE 0 0 0
da2p2 ONLINE 0 0 0
errors: No known data errors
脚本下载:
https://code.google.com/p/iceblood/source/browse/FreeBSD_ZFS #!/bin/sh
#############################
# #
#Write by iceblood #
# iceblood@163.com #
#############################
TANKNAME=BSDROOT
SWAPSIZE=4G
PATH=/bin:/sbin:/usr/bin:/usr/sbin
DISKLIST=$(cat /var/run/dmesg.boot | grep 'MB (' | awk -F':' '{print $1}')
SYSDISK=$(echo $DISKLIST | awk '{print $1}')
DISKCOUNT=$(cat /var/run/dmesg.boot | grep 'MB (' | wc -l)
help()
{
cat << HELP
$0 {normal|raid1|raid5}
HELP
exit 1
}
cleardisk()
{
OS=$(uname)
if [ "$OS" != "FreeBSD" ]; then
echo "isn't FreeBSD!!!"
exit 1
fi
echo -n "WARNING!!!now clear all harddisk data!!are you agree"
read AGREE
if [ "$AGREE" != "y" ]; then
exit
fi
for DISK in $DISKLIST; do
PARTITION=$(gpart show ${DISK} | awk '{print $3}' | sed 1d | tr -d '-' | sed '/^$/d')
for P in $PARTITION; do
gpart delete -i $P ${DISK} > /dev/null 2>&1
done
gpart destroy ${DISK} > /dev/null 2>&1
done
}
case $1 in
normal)
cleardisk;
mkdir -p /tmp/zfsbsd
mdmfs -s 512m md /tmp/zfsbsd
echo -n "Create filesystem..."
gpart create -s gpt $SYSDISK > /dev/null 2>&1
gpart add -b 34 -s 64k -t freebsd-boot $SYSDISK > /dev/null 2>&1
gpart add -t freebsd-zfs $SYSDISK > /dev/null 2>&1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $SYSDISK > /dev/null 2>&1
zpool create -f $TANKNAME /dev/${SYSDISK}p2 > /dev/null 2>&1
NOSYSDISK=$(echo $DISKLIST | sed "s/$SYSDISK//")
zpool add -f $TANKNAME $NOSYSDISK
zpool set bootfs=$TANKNAME $TANKNAME
zfs set checksum=fletcher4 $TANKNAME
zfs create -V $SWAPSIZE $TANKNAME/swap
zfs set checksum=off $TANKNAME/swap
zfs set org.freebsd:swap=on $TANKNAME/swap
zfs set mountpoint=/mnt $TANKNAME
zfs mount $TANKNAME
zfs create $TANKNAME/usr
zfs create $TANKNAME/var
zfs create -o compression=on -o exec=on -o setuid=off $TANKNAME/tmp
zfs create $TANKNAME/home
zpool export $TANKNAME
zpool import -o cachefile=/tmp/zfsbsd/zpool.cache $TANKNAME
chmod 1777 /mnt/tmp
mkdir -p /mnt/var/tmp
chmod 1777 /mnt/var/tmp
echo "done."
echo -n "Install base system..."
cd /usr/freebsd-dist
DESTDIR=/mnt
cat kernel.txz | tar --unlink -xpJf - -C ${DESTDIR:-/}
cat base.txz | tar --unlink -xpJf - -C ${DESTDIR:-/}
echo "done."
echo -n "Init new freebsd..."
cp /tmp/zfsbsd/zpool.cache /mnt/boot/zfs/zpool.cache
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf
touch /mnt/etc/fstab
cat << LOADER > /mnt/boot/loader.conf
zfs_load="YES"
vfs.root.mountfrom="zfs:${TANKNAME}"
vm.kmem_size="512M"
vm.kmem_size_max="512M"
vfs.zfs.arc_max="40M"
vfs.zfs.vdev.cache.size="5M"
LOADER
zfs umount -a > /dev/null 2>&1
zfs set mountpoint=legacy $TANKNAME
zfs set mountpoint=/tmp $TANKNAME/tmp> /dev/null 2>&1
zfs set mountpoint=/usr $TANKNAME/usr > /dev/null 2>&1
zfs set mountpoint=/var $TANKNAME/var > /dev/null 2>&1
zfs set mountpoint=/home $TANKNAME/home > /dev/null 2>&1
echo "done."
echo "Install done,Please run \"reboot\"."
;;
*)
help;
;;
esac mfsbsd 里有个zfs的安装脚本 芭比小柒 发表于 2012-09-05 16:34 static/image/common/back.gif
mfsbsd 里有个zfs的安装脚本
哦。是嘛?难道我白幸苦啦?:shock: @芭比小柒脚本在哪 :emn31: 太感谢了,我照着网上的搞了一个,结果,就是引导不了。
https://github.com/mmatuska/mfsbsd/blob/master/tools/zfsinstall
:em03:
[ghw@7axu.pts/3] ~ % zpool list
NAME SIZEALLOC FREE CAPDEDUPHEALTHALTROOT
tank 199G17.7G 181G 8%1.36xONLINE-
[ghw@7axu.pts/3] ~ % zfs list
NAME USEDAVAILREFERMOUNTPOINT
tank 18.0G 178G93.5Mlegacy
tank/home 10.7G 178G10.7G/home
tank/usr 6.95G 178G 215M/usr
tank/usr/local 2.63G 178G2.63G/usr/local
tank/usr/ports 3.05G 178G 847M/usr/ports
tank/usr/ports/distfiles2.23G 178G2.23G/usr/ports/distfiles
tank/usr/src 1.05G 178G1.05G/usr/src
tank/var 149M 178G3.59M/var
tank/var/crash 148K 178G 148K/var/crash
tank/var/db 143M 178G 143M/var/db
tank/var/empty 144K 178G 144K/var/empty
tank/var/log 580K 178G 580K/var/log
tank/var/mail 144K 178G 144K/var/mail
tank/var/run 388K 178G 388K/var/run
tank/var/tmp 368K 178G 368K/var/tmp
[ghw@7axu.pts/3] ~ % geli status
NameStatusComponents
ada0s1d.eliACTIVEada0s1d
ada0s1b.eliACTIVEada0s1b
[ghw@7axu.pts/3] ~ % zdb
tank:
version: 28
name: 'tank'
state: 0
txg: 174
pool_guid: 4273006994210631156
hostid: 1256830924
hostname: '7axu.com'
vdev_children: 1
vdev_tree:
type: 'root'
id: 0
guid: 4273006994210631156
children:
type: 'disk'
id: 0
guid: 8589119704594412908
path: '/dev/ada0s1d.eli'
phys_path: '/dev/ada0s1d.eli'
whole_disk: 1
metaslab_array: 30
metaslab_shift: 30
ashift: 12
asize: 214743384064
is_log: 0
create_txg: 4
[ghw@7axu.pts/3] ~ %
芭比小柒 发表于 2012-09-05 20:43 static/image/common/back.gif
https://github.com/mmatuska/mfsbsd/blob/master/tools/zfsinstall
#!/bin/sh
# $Id$
#
# mfsBSD ZFS install script
# Copyright (c) 2011 Martin Matuska <mm at FreeBSD.org>
#
FS_LIST="var tmp"
usage() {
echo "Usage: $0 [-h] -d geom_provider [-d geom_provider ...] -t archive_file [-r mirror|raidz] [-m mount_point] [-p zfs_pool_name] [-V zfs_pool_version] [-s swap_partition_size] [-z zfs_partition_size] [-c] [-l] [-4]"
}
help() {
echo; echo "Install FreeBSD using ZFS from a compressed archive"
echo; echo "Required flags:"
echo "-d geom_provider: geom provider(s) to install to (e.g. da0)"
echo "-t archive_file : tar archive file containing the FreeBSD distribution"
echo " supported compression formats are: gzip, bzip2, xz"
echo; echo "Optional flags:"
echo "-r raidz|mirror : select raid mode if more than one -d provider given"
echo "-s swap_part_size : create a swap partition with given size (default: no swap)"
echo "-z zfs_part_size: create zfs parition of this size (default: all space left)"
echo "-p pool_name : specify a name for the ZFS pool (default: tank)"
echo "-V pool_version : specify a version number for ZFS pool (default: 13)"
echo "-m mount_point : use this mount point for operations (default: /mnt)"
echo "-c : enable lzjb compression for all datasets"
echo "-l : use legacy mounts (via fstab) instead of ZFS mounts"
echo "-4 : use fletcher4 as default checksum algorithm"
echo; echo "Examples:"
echo "Install on a single drive with 2GB swap:"
echo "$0 -d ad4 -s 2G"
echo "Install on a mirror without swap, pool name rpool:"
echo "$0 -d ad4 -d ad6 -r mirror -p rpool"
echo; echo "Notes:"
echo "When using swap and raidz/mirror, the swap partition is created on all drives."
echo "The /etc/fstab entry will contatin only the first drive's swap partition."
echo "You can enable all swap partitions and/or make a gmirror-ed swap later."
}
while getopts d:t:r:p:s:z:m:V:hcl4 o; do
case "$o" in
d) DEVS="$DEVS ${OPTARG##/dev/}" ;;
t) ARCHIVE="${OPTARG}" ;;
p) POOL="${OPTARG}" ;;
s) SWAP="${OPTARG}" ;;
m) MNT="${OPTARG}" ;;
r) RAID="${OPTARG}" ;;
z) ZPART="${OPTARG}" ;;
V) VERSION="${OPTARG}" ;;
c) LZJB=1 ;;
l) LEGACY=1 ;;
4) FLETCHER=1 ;;
h) help; exit 1;;
[?]) usage; exit 1;;
esac
done
if ! `/sbin/kldstat -m zfs >/dev/null 2>/dev/null`; then
/sbin/kldload zfs >/dev/null 2>/dev/null
fi
ZFS_VERSION=`/sbin/sysctl -n vfs.zfs.version.spa 2>/dev/null`
if [ -z "$ZFS_VERSION" ]; then
echo "Error: failed to load ZFS module"
exit 1
elif [ "$ZFS_VERSION" -lt "13" ]; then
echo "Error: ZFS module too old, version 13 or higher required"
exit 1
fi
if [ -z "$DEVS" -o -z "$ARCHIVE" ]; then
usage
exit 1
fi
if [ -z "$POOL" ]; then
POOL=tank
fi
if [ -z "$VERSION" ]; then
VERSION=${ZFS_VERSION}
elif [ "$VERSION" -gt "$ZFS_VERSION" ]; then
echo "Error: invalid ZFS pool version (maximum: $ZFS_VERSION)"
exit 1
fi
if [ "$VERSION" = "5000" ]; then
VERSION=
else
VERSION="-o version=${VERSION}"
fi
if /sbin/zpool list $POOL > /dev/null 2> /dev/null; then
echo Error: ZFS pool \"$POOL\" already exists
echo Please choose another pool name or rename/destroy the existing pool.
exit 1
fi
EXPOOLS=`/sbin/zpool import | /usr/bin/grep pool: | /usr/bin/awk '{ print $2 }'`
if [ -n "${EXPOOLS}" ]; then
for P in ${EXPOOLS}; do
if [ "$P" = "$POOL" ]; then
echo Error: An exported ZFS pool \"$POOL\" already exists
echo Please choose another pool name or rename/destroy the exported pool.
exit 1
fi
done
fi
COUNT=`echo ${DEVS} | /usr/bin/wc -w | /usr/bin/awk '{ print $1 }'`
if [ "$COUNT" -lt "3" -a "$RAID" = "raidz" ]; then
echo "Error: raidz needs at least three devices (-d switch)"
exit 1
elif [ "$COUNT" = "1" -a "$RAID" = "mirror" ]; then
echo "Error: mirror needs at least two devices (-d switch)"
exit 1
elif [ "$COUNT" = "2" -a "$RAID" != "mirror" ]; then
echo "Notice: two drives selected, automatically choosing mirror mode"
RAID="mirror"
elif [ "$COUNT" -gt "2" -a "$RAID" != "mirror" -a "$RAID" != "raidz" ]; then
echo "Error: please choose raid mode with the -r switch (mirror or raidz)"
exit 1
fi
for DEV in ${DEVS}; do
if ! [ -c "/dev/${DEV}" ]; then
echo "Error: /dev/${DEV} is not a block device"
exit 1
fi
if /sbin/gpart show $DEV > /dev/null 2> /dev/null; then
echo "Error: /dev/${DEV} already contains a partition table."
echo ""
/sbin/gpart show $DEV
echo "You may erase the partition table manually with the destroygeom command"
exit 1
fi
done
if ! [ -f "${ARCHIVE}" ]; then
echo "Error: file $ARCHIVE does not exist"
exit 1
fi
DIRECT_TAR=0
FTYPE=`/usr/bin/file -b --mime-type ${ARCHIVE}`
if [ "$FTYPE" = "application/x-tar" ]; then
DIRECT_TAR=1
elif [ "$FTYPE" = "application/x-gzip" ]; then
EXTRACT_CMD=/usr/bin/gzip
elif [ "$FTYPE" = "application/x-bzip2" ]; then
EXTRACT_CMD=/usr/bin/bzip2
elif [ "$FTYPE" = "application/x-xz" ]; then
if [ ! -x "`/usr/bin/which xz`" ]; then
echo "xz-compressed file selected and xz is not installed";
exit 1
fi
EXTRACT_CMD=`which xz`
else
echo "Archive must be uncompressed or gzip, bzip2 or xz compressed"
exit 1
fi
if [ -z "$MNT" ]; then
MNT=/mnt
fi
if ! [ -d "${MNT}" ]; then
echo "Error: $MNT is not a directory"
exit 1
fi
if [ -n "${ZPART}" ]; then
SZPART="-s ${ZPART}"
fi
if [ "${LEGACY}" = "1" ]; then
ALTROOT=
ROOTMNT=legacy
else
ALTROOT="-o altroot=${MNT} -o cachefile=/boot/zfs/zpool.cache"
ROOTMNT=/
fi
# Create GPT
for DEV in ${DEVS}; do
echo -n "Creating GUID partitions on ${DEV} ..."
if ! /sbin/gpart create -s GPT /dev/${DEV} > /dev/null; then
echo " error"
exit 1
fi
/bin/sleep 1
if ! echo "a 1" | /sbin/fdisk -f - ${DEV} > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
if ! /sbin/gpart add -t freebsd-boot -s 128 ${DEV} > /dev/null; then
echo " error"
exit 1
fi
if [ -n "${SWAP}" ]; then
if ! /sbin/gpart add -t freebsd-swap -s "${SWAP}" ${DEV} > /dev/null; then
echo " error"
exit 1
fi
SWAPPART=`/sbin/glabel status ${DEV}p2 | /usr/bin/grep gptid | /usr/bin/awk '{ print $1 }'`
if [ -z "$SWAPPART" ]; then
echo " error determining swap partition"
fi
if [ -z "$FSWAP" ]; then
FSWAP=${SWAPPART}
fi
fi
if ! /sbin/gpart add -t freebsd-zfs ${SZPART} ${DEV} > /dev/null; then
echo " error"
exit 1
fi
/bin/dd if=/dev/zero of=/dev/${DEV}p2 bs=512 count=560 > /dev/null 2> /dev/null
if [ -n "${SWAP}" ]; then
/bin/dd if=/dev/zero of=/dev/${DEV}p3 bs=512 count=560 > /dev/null 2> /dev/null
fi
echo " done"
echo -n "Configuring ZFS bootcode on ${DEV} ..."
if ! /sbin/gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${DEV} > /dev/null; then
echo " error"
exit 1
fi
echo " done"
/sbin/gpart show ${DEV}
done
# Create zpool and zfs
for DEV in ${DEVS}; do
PART=`/sbin/gpart show ${DEV} | /usr/bin/grep freebsd-zfs | /usr/bin/awk '{ print $3 }'`
if [ -z "${PART}" ]; then
echo Error: freebsd-zfs partition not found on /dev/$DEV
exit 1
fi
GPART=`/sbin/glabel list ${DEV}p${PART} | /usr/bin/grep gptid | /usr/bin/awk -F"gptid/" '{ print "gptid/" $2 }'`
GPARTS="${GPARTS} ${GPART}"
PARTS="${PARTS} ${DEV}p${PART}"
done
echo -n "Creating ZFS pool ${POOL} on${PARTS} ..."
if ! /sbin/zpool create -f -m none ${ALTROOT} ${VERSION} ${POOL} ${RAID} ${PARTS} > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
echo " done"
if [ "${FLETCHER}" = "1" ]; then
echo -n "Setting default checksum to fletcher4 for ${POOL} ..."
if ! /sbin/zfs set checksum=fletcher4 ${POOL} > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
echo " done"
fi
if [ "${LZJB}" = "1" ]; then
echo -n "Setting default compression to lzjb for ${POOL} ..."
if ! /sbin/zfs set compression=lzjb ${POOL} > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
echo " done"
fi
echo -n "Creating ${POOL} root partition:"
if ! /sbin/zfs create -o mountpoint=${ROOTMNT} ${POOL}/root > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
echo " ... done"
echo -n "Creating ${POOL} partitions:"
for FS in ${FS_LIST}; do
if [ "${LEGACY}" = 1 ]; then
MNTPT="-o mountpoint=legacy"
else
MNTPT=
fi
if ! /sbin/zfs create ${MNTPT} ${POOL}/root/${FS} > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
echo -n " ${FS}"
done
echo " ... done"
echo -n "Setting bootfs for ${POOL} to ${POOL}/root ..."
if ! /sbin/zpool set bootfs=${POOL}/root ${POOL} > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
echo " done"
/sbin/zfs list -r ${POOL}
# Mount and populate zfs (if legacy)
if [ "${LEGACY}" = "1" ]; then
echo -n "Mounting ${POOL} on ${MNT} ..."
/bin/mkdir -p ${MNT}
if ! /sbin/mount -t zfs ${POOL}/root ${MNT} > /dev/null 2> /dev/null; then
echo " error mounting pool/root"
exit 1
fi
for FS in ${FS_LIST}; do
/bin/mkdir -p ${MNT}/${FS}
if ! /sbin/mount -t zfs ${POOL}/root/${FS} ${MNT}/${FS} > /dev/null 2> /dev/null; then
echo " error mounting ${POOL}/root/${FS}"
exit 1
fi
done
echo " done"
fi
echo -n "Extracting FreeBSD distribution ..."
if [ "${DIRECT_TAR}" = "1" ]; then
if ! /usr/bin/tar -C ${MNT} -x -f ${ARCHIVE} > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
else
if ! ${EXTRACT_CMD} -d -c ${ARCHIVE} | /usr/bin/tar -C ${MNT} -x -f - > /dev/null 2> /dev/null; then
echo " error"
exit 1
fi
fi
echo " done"
# Adjust configuration files
echo -n "Writing /boot/loader.conf..."
echo "zfs_load=\"YES\"" > ${MNT}/boot/loader.conf
echo "vfs.root.mountfrom=\"zfs:${POOL}/root\"" >> ${MNT}/boot/loader.conf
echo " done"
# Write fstab if swap or legacy
echo -n "Writing /etc/fstab..."
rm -f ${MNT}/etc/fstab
touch ${MNT}/etc/fstab
if [ -n "${FSWAP}" -o "${LEGACY}" = "1" ]; then
if [ -n "${FSWAP}" ]; then
echo "/dev/${FSWAP} none swap sw 0 0" > ${MNT}/etc/fstab
fi
if [ "${LEGACY}" = "1" ]; then
for FS in ${FS_LIST}; do
echo ${POOL}/root/${FS} /${FS} zfs rw 0 0 >> ${MNT}/etc/fstab
done
fi
fi
if [ "${LEGACY}" != "1" ]; then
echo -n "Writing /etc/rc.conf..."
echo 'zfs_enable="YES"' >> ${MNT}/etc/rc.conf
fi
echo " done"
echo -n "Copying /boot/zfs/zpool.cache ..."
if [ -n "${LEGACY}" ]; then
for FS in ${FS_LIST}; do
/sbin/umount ${MNT}/${FS} > /dev/null 2> /dev/null
done
/sbin/umount ${MNT} > /dev/null 2> /dev/null
fi
if ! /sbin/zpool export ${POOL} > /dev/null 2> /dev/null; then
echo " error exporting pool"
exit 1
fi
if ! /sbin/zpool import ${ALTROOT} ${POOL} > /dev/null 2> /dev/null; then
echo " error importing pool"
exit 1
fi
if [ -n "${LEGACY}" ]; then
if ! /sbin/mount -t zfs ${POOL}/root ${MNT} > /dev/null 2> /dev/null; then
echo " error mounting ${POOL}/root"
exit 1
fi
fi
if ! /bin/cp /boot/zfs/zpool.cache ${MNT}/boot/zfs/ > /dev/null 2> /dev/null; then
echo " error copying zpool.cache"
exit 1
fi
if [ -n "${LEGACY}" ]; then
for FS in ${FS_LIST}; do
if ! /sbin/mount -t zfs ${POOL}/${FS} ${MNT}/${FS} > /dev/null 2> /dev/null; then
echo " error mounting ${POOL}/${FS}"
exit 1
fi
done
fi
echo " done"
# Mount devfs for post-configuration
if ! /sbin/mount -t devfs devfs ${MNT}/dev; then
echo "Error mounting devfs on ${MNT}/dev"
fi
echo ""
echo "Installation complete."
echo "The system will boot from ZFS with clean install on next reboot"
echo ""
echo "You may type \"chroot ${MNT}\" and make any adjustments you need."
echo "For example, change the root password or edit/create /etc/rc.conf for"
echo "for system services. "
echo ""
echo "WARNING - Don't export ZFS pool \"${POOL}\"!" 果真有啊
不管有没有,必须顶楼主,赞一个 本帖最后由 iceblood 于 2012-09-07 15:47 编辑
芭比小柒 发表于 2012-09-05 20:43 static/image/common/back.gif
https://github.com/mmatuska/mfsbsd/blob/master/tools/zfsinstall
从他的脚本看,不支持SWAP也放在ZFS里。这样SWAP的大小就不能灵活的调整。
看来我的脚本完善后功能上将来还是会有一定的优势,又或者说是另外一种风格。