Simba7
November 15th, 2011, 02:37
Having recently returned to FreeBSD from a 4 year stint with Gentoo, I decided to switch most of my systems back to FreeBSD (a few still run Gentoo). I've been using FreeBSD since 1998 and it proved to be a solid OS back then while I was a Radioman in the Navy (operating on a small P166 server in the ships library). I'm glad things are better now that ZFS is out.
Enough about me, let's get down to getting ZFS working on your Sparc64-based system.
1. Build your disk partitions. You can adjust the sizes to your taste.
sunlabel -B ada0
gpart destroy -F ada0
gpart create -s vtoc8 ada0
gpart add -s 192M -t freebsd-ufs /dev/ada0
gpart add -s 1G -t freebsd-swap /dev/ada0
gpart add -t freebsd-zfs /dev/ada0
2. Load the appropriate modules to get ZFS working.
kldload /boot/kernel/opensolaris.ko
kldload /boot/kernel/zfs.ko
3. Create the ZFS pool and adjust checksum and compression settings. I would suggest keeping the checksum settings. If you want to change the compression or disable it altogether, go ahead.
zpool create -f -m /mnt zroot /dev/ada0d
zpool set bootfs=zroot zroot
zfs set checksum=fletcher4 zroot
zfs set compression=lzjb zroot
zfs create zroot/usr
zfs create zroot/var
zfs create zroot/tmp
zfs create zroot/data
chmod 1777 /mnt/tmp
zpool export zroot
zpool import -o cachefile=/tmp/zpool.cache zroot
4. Mount your UFS /bootdir partition.
mkdir /mnt/bootdir
newfs -m 0 /dev/ada0a
mount /dev/ada0a /mnt/bootdir
5. Extract the .txz files onto your system.
*NOTE* I have the /usr/ports on a dedicated server due to having several FreeBSD servers running. That way I don't waste valuable space. If you want to add the ports collection, just add ports.txz after doc.txz below.
cd /usr/freebsd-dist
export DESTDIR=/mnt
for file in base.txz kernel.txz doc.txz games.txz ; do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}) ; done
cp /tmp/zpool.cache /mnt/boot/zfs/zpool.cache
6. Chroot into your system so you can change some of the system files.
chroot /mnt
echo 'zfs_enable="YES"' > /etc/rc.conf
echo 'hostname="server.example.lan"' >> /etc/rc.conf
echo 'ifconfig_dc0="DHCP"' >> /etc/rc.conf
echo 'sshd_enable="YES"' >> /etc/rc.conf
echo 'zfs_load="YES"' > /boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot"' >> /boot/loader.conf
echo 'vfs.zfs.prefetch_disable="1"' >> /boot/loader.conf
echo 'console="ofw"' >> /boot/loader.conf
mv boot bootdir/
ln -s bootdir/boot /boot
chflags -h sunlink /boot
7. Edit your /etc/fstab to include these lines:
# Device Mountpoint FStype Options Dump Pass#
/dev/ada0a /bootdir ufs rw 0 0
/dev/ada0b none swap sw 0 0
8. Create a password for your system, change your timezone, and create aliases for the mail system.
passwd
tzsetup
cd /etc/mail
make aliases
9. Leave the chroot.
exit
10. Unmount the entire filesystem and create mountpoints for the ZFS filesystem.
cd
umount /mnt/bootdir
zfs umount -a
zfs set mountpoint=legacy zroot
zfs set mountpoint=/tmp zroot/tmp
zfs set mountpoint=/var zroot/var
zfs set mountpoint=/usr zroot/usr
zfs set mountpoint=/data zroot/data
11. Reboot the system and you're done with the initial install.
reboot
This entire script took a SunFire V100 about 10 minutes to install FreeBSD 9.0-RELEASE on a ZFS filesystem with lzjb compression. Not bad for an UltraSPARC IIe.
Enough about me, let's get down to getting ZFS working on your Sparc64-based system.
1. Build your disk partitions. You can adjust the sizes to your taste.
sunlabel -B ada0
gpart destroy -F ada0
gpart create -s vtoc8 ada0
gpart add -s 192M -t freebsd-ufs /dev/ada0
gpart add -s 1G -t freebsd-swap /dev/ada0
gpart add -t freebsd-zfs /dev/ada0
2. Load the appropriate modules to get ZFS working.
kldload /boot/kernel/opensolaris.ko
kldload /boot/kernel/zfs.ko
3. Create the ZFS pool and adjust checksum and compression settings. I would suggest keeping the checksum settings. If you want to change the compression or disable it altogether, go ahead.
zpool create -f -m /mnt zroot /dev/ada0d
zpool set bootfs=zroot zroot
zfs set checksum=fletcher4 zroot
zfs set compression=lzjb zroot
zfs create zroot/usr
zfs create zroot/var
zfs create zroot/tmp
zfs create zroot/data
chmod 1777 /mnt/tmp
zpool export zroot
zpool import -o cachefile=/tmp/zpool.cache zroot
4. Mount your UFS /bootdir partition.
mkdir /mnt/bootdir
newfs -m 0 /dev/ada0a
mount /dev/ada0a /mnt/bootdir
5. Extract the .txz files onto your system.
*NOTE* I have the /usr/ports on a dedicated server due to having several FreeBSD servers running. That way I don't waste valuable space. If you want to add the ports collection, just add ports.txz after doc.txz below.
cd /usr/freebsd-dist
export DESTDIR=/mnt
for file in base.txz kernel.txz doc.txz games.txz ; do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}) ; done
cp /tmp/zpool.cache /mnt/boot/zfs/zpool.cache
6. Chroot into your system so you can change some of the system files.
chroot /mnt
echo 'zfs_enable="YES"' > /etc/rc.conf
echo 'hostname="server.example.lan"' >> /etc/rc.conf
echo 'ifconfig_dc0="DHCP"' >> /etc/rc.conf
echo 'sshd_enable="YES"' >> /etc/rc.conf
echo 'zfs_load="YES"' > /boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot"' >> /boot/loader.conf
echo 'vfs.zfs.prefetch_disable="1"' >> /boot/loader.conf
echo 'console="ofw"' >> /boot/loader.conf
mv boot bootdir/
ln -s bootdir/boot /boot
chflags -h sunlink /boot
7. Edit your /etc/fstab to include these lines:
# Device Mountpoint FStype Options Dump Pass#
/dev/ada0a /bootdir ufs rw 0 0
/dev/ada0b none swap sw 0 0
8. Create a password for your system, change your timezone, and create aliases for the mail system.
passwd
tzsetup
cd /etc/mail
make aliases
9. Leave the chroot.
exit
10. Unmount the entire filesystem and create mountpoints for the ZFS filesystem.
cd
umount /mnt/bootdir
zfs umount -a
zfs set mountpoint=legacy zroot
zfs set mountpoint=/tmp zroot/tmp
zfs set mountpoint=/var zroot/var
zfs set mountpoint=/usr zroot/usr
zfs set mountpoint=/data zroot/data
11. Reboot the system and you're done with the initial install.
reboot
This entire script took a SunFire V100 about 10 minutes to install FreeBSD 9.0-RELEASE on a ZFS filesystem with lzjb compression. Not bad for an UltraSPARC IIe.