FreeBSD & ZFS RAID1 Root ++
Добавлено: 05 янв 2011, 05:07
FreeBSD & ZFS RAID1 Root ++
by ldr on February 24th, 2010
I’ve been using ZFS for a while now on OpenSolaris, the filesystem really rocks ! Unfortunately the OpenSolaris is not going to be so Open anymore now that Oracle made its plans clear. But fear not, there’s FreeBSD ! A great OS that we use at work for a lot of our servers which now has a stable implementation of ZFS as well !
I tried installing FreeBSD 8.0 on a ZFS filesystem, which went pretty well actually. I first installed the os on the third disk (/dev/ad14) in the system (regular sysinstall). When that was done, I continued installing the final system on the first two disks.
Below is a transcript of everything I did to get it running.
gpart create -s gpt ad10
gpart create -s gpt ad12
gpart add -s 64K -t freebsd-boot ad10
gpart add -s 64K -t freebsd-boot ad12
gpart add -t freebsd-zfs -l disk0 ad10
gpart add -t freebsd-zfs -l disk1 ad12
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad10
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad12
kldload opensolaris
kldload zfs
mkdir /boot/zfs
zpool create rpool mirror /dev/gpt/disk0 /dev/gpt/disk1
zpool set bootfs=rpool rpool
zfs set checksum=fletcher4 rpool
zfs create -o compression=on -o exec=on -o setuid=off rpool/tmp
chmod 1777 /rpool/tmp
zfs create rpool/usr
zfs create rpool/home
zfs create -o compression=lzjb -o setuid=off rpool/usr/ports
zfs create -o compression=off -o exec=off -o setuid=off rpool/usr/ports/distfiles
zfs create -o compression=off -o exec=off -o setuid=off rpool/usr/ports/packages
zfs create -o compression=lzjb -o exec=off -o setuid=off rpool/usr/src
zfs create rpool/var
zfs create -o compression=lzjb -o exec=off -o setuid=off rpool/var/crash
zfs create -o exec=off -o setuid=off rpool/var/db
zfs create -o compression=lzjb -o exec=on -o setuid=off rpool/var/db/pkg
zfs create -o exec=off -o setuid=off rpool/var/empty
zfs create -o compression=lzjb -o exec=off -o setuid=off rpool/var/log
zfs create -o compression=gzip -o exec=off -o setuid=off rpool/var/mail
zfs create -o exec=off -o setuid=off rpool/var/run
zfs create -o exec=lzjb -o exec=on -o setuid=off rpool/var/tmp
chmod 1777 /rpool/var/tmp
Thanks to Scot Hetzel on wiki.freebsd.org for the info btw!
Next up, I needed to get a fresh world and kernel on the new system:
cat > /etc/make.conf <<EOF
KERNCONF=DESK
CPUTYPE=nocona
NO_BIND=true
NO_LPR=true
NO_SENDMAIL=true
NOUUCP=true
SUIDPERL=false
PERL_VERSION=5.8.9
EOF
cat >/etc/cvsupfile <<EOF
*default host=cvsup.proserve.nl
*default base=/usr
*default prefix=/usr
*default release=cvs
*default tag=RELENG_8_0
*default delete
use-rel-suffix src-all
*default tag=. ports-all
EOF
cat >/etc/cvsupports <<EOF
*default host=cvsup.proserve.nl
*default base=/usr
*default prefix=/usr
*default release=cvs
*default tag=RELENG_8_0
*default delete
use-rel-suffix
*default tag=.
ports-all
EOF
cvsup -g -L 2 /etc/cvsupfile
I did the buildworld and kernel on the 3rd disk so in case of foobar on the new zfs pool, I could re-use the already built software. After the build finished, I just copied everything to zfs:
cd /usr/src
make buildworld
make installworld DESTDIR=/rpool
mergemaster -i -C -D /rpool
cd /usr/src/sys/amd64/conf
cp GENERIC DESK
config DESK
cd ../compile/DESK
make
make install DESTDIR=/rpool
cp -av /usr/src/* /rpool/usr/src
cp -av /usr/obj/* /rpool/usr/obj
cp -av /usr/ports/* /rpool/usr/ports
Then I continued as follows:
zfs set readonly=on rpool/var/empty
chroot /rpool
cat > /etc/rc.conf <<EOF
hostname="foo.bar"
ifconfig_re0="DHCP"
zfs_enable="YES"
EOF
cat > /boot/loader.conf <<EOF
zfs_load="YES"
vfs.root.mountfrom="zfs:rpool"
EOF
echo 'LOADER_ZFS_SUPPORT=YES' >/etc/src.conf
mount -t devfs devfs /dev
cd /usr/src/sys/boot
make obj
make depend
make
cd i386/loader
make install
passwd
tzsetup
cd /etc/mail
make aliases
umount /dev
exit
cp /boot/zfs/rpool.cache /rpool/boot/zfs
zfs unmount -a
zfs set mountpoint=legacy rpool
zfs set mountpoint=/home rpool/home
zfs set mountpoint=/tmp rpool/tmp
zfs set mountpoint=/usr rpool/usr
zfs set mountpoint=/var rpool/var
by ldr on February 24th, 2010
I’ve been using ZFS for a while now on OpenSolaris, the filesystem really rocks ! Unfortunately the OpenSolaris is not going to be so Open anymore now that Oracle made its plans clear. But fear not, there’s FreeBSD ! A great OS that we use at work for a lot of our servers which now has a stable implementation of ZFS as well !
I tried installing FreeBSD 8.0 on a ZFS filesystem, which went pretty well actually. I first installed the os on the third disk (/dev/ad14) in the system (regular sysinstall). When that was done, I continued installing the final system on the first two disks.
Below is a transcript of everything I did to get it running.
gpart create -s gpt ad10
gpart create -s gpt ad12
gpart add -s 64K -t freebsd-boot ad10
gpart add -s 64K -t freebsd-boot ad12
gpart add -t freebsd-zfs -l disk0 ad10
gpart add -t freebsd-zfs -l disk1 ad12
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad10
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad12
kldload opensolaris
kldload zfs
mkdir /boot/zfs
zpool create rpool mirror /dev/gpt/disk0 /dev/gpt/disk1
zpool set bootfs=rpool rpool
zfs set checksum=fletcher4 rpool
zfs create -o compression=on -o exec=on -o setuid=off rpool/tmp
chmod 1777 /rpool/tmp
zfs create rpool/usr
zfs create rpool/home
zfs create -o compression=lzjb -o setuid=off rpool/usr/ports
zfs create -o compression=off -o exec=off -o setuid=off rpool/usr/ports/distfiles
zfs create -o compression=off -o exec=off -o setuid=off rpool/usr/ports/packages
zfs create -o compression=lzjb -o exec=off -o setuid=off rpool/usr/src
zfs create rpool/var
zfs create -o compression=lzjb -o exec=off -o setuid=off rpool/var/crash
zfs create -o exec=off -o setuid=off rpool/var/db
zfs create -o compression=lzjb -o exec=on -o setuid=off rpool/var/db/pkg
zfs create -o exec=off -o setuid=off rpool/var/empty
zfs create -o compression=lzjb -o exec=off -o setuid=off rpool/var/log
zfs create -o compression=gzip -o exec=off -o setuid=off rpool/var/mail
zfs create -o exec=off -o setuid=off rpool/var/run
zfs create -o exec=lzjb -o exec=on -o setuid=off rpool/var/tmp
chmod 1777 /rpool/var/tmp
Thanks to Scot Hetzel on wiki.freebsd.org for the info btw!
Next up, I needed to get a fresh world and kernel on the new system:
cat > /etc/make.conf <<EOF
KERNCONF=DESK
CPUTYPE=nocona
NO_BIND=true
NO_LPR=true
NO_SENDMAIL=true
NOUUCP=true
SUIDPERL=false
PERL_VERSION=5.8.9
EOF
cat >/etc/cvsupfile <<EOF
*default host=cvsup.proserve.nl
*default base=/usr
*default prefix=/usr
*default release=cvs
*default tag=RELENG_8_0
*default delete
use-rel-suffix src-all
*default tag=. ports-all
EOF
cat >/etc/cvsupports <<EOF
*default host=cvsup.proserve.nl
*default base=/usr
*default prefix=/usr
*default release=cvs
*default tag=RELENG_8_0
*default delete
use-rel-suffix
*default tag=.
ports-all
EOF
cvsup -g -L 2 /etc/cvsupfile
I did the buildworld and kernel on the 3rd disk so in case of foobar on the new zfs pool, I could re-use the already built software. After the build finished, I just copied everything to zfs:
cd /usr/src
make buildworld
make installworld DESTDIR=/rpool
mergemaster -i -C -D /rpool
cd /usr/src/sys/amd64/conf
cp GENERIC DESK
config DESK
cd ../compile/DESK
make
make install DESTDIR=/rpool
cp -av /usr/src/* /rpool/usr/src
cp -av /usr/obj/* /rpool/usr/obj
cp -av /usr/ports/* /rpool/usr/ports
Then I continued as follows:
zfs set readonly=on rpool/var/empty
chroot /rpool
cat > /etc/rc.conf <<EOF
hostname="foo.bar"
ifconfig_re0="DHCP"
zfs_enable="YES"
EOF
cat > /boot/loader.conf <<EOF
zfs_load="YES"
vfs.root.mountfrom="zfs:rpool"
EOF
echo 'LOADER_ZFS_SUPPORT=YES' >/etc/src.conf
mount -t devfs devfs /dev
cd /usr/src/sys/boot
make obj
make depend
make
cd i386/loader
make install
passwd
tzsetup
cd /etc/mail
make aliases
umount /dev
exit
cp /boot/zfs/rpool.cache /rpool/boot/zfs
zfs unmount -a
zfs set mountpoint=legacy rpool
zfs set mountpoint=/home rpool/home
zfs set mountpoint=/tmp rpool/tmp
zfs set mountpoint=/usr rpool/usr
zfs set mountpoint=/var rpool/var