{"id":1085,"date":"2016-11-20T17:37:41","date_gmt":"2016-11-20T16:37:41","guid":{"rendered":"http:\/\/www.hauweele.net\/~gawen\/blog\/?p=1085"},"modified":"2016-12-09T12:08:33","modified_gmt":"2016-12-09T11:08:33","slug":"install-freebsd-11-with-zfs-on-dedibox-xc-2016","status":"publish","type":"post","link":"https:\/\/hauweele.net\/~gawen\/blog\/?p=1085","title":{"rendered":"Install FreeBSD 11 with ZFS on Dedibox XC 2016"},"content":{"rendered":"<p><a href=\"https:\/\/www.online.net\/en\/dedicated-server\/dedibox-xc\">Online.net&#8217;s Dedibox XC 2016<\/a> comes with 16 GB DDR3 and 1 To SATA or 250 GB SSD on a 8 cores Atom CPU. This is a very nice entry-level dedicated box for anyone who want to upgrade from a small VPS (yes, there is some upgrade in the air). There is only one HDD and no RAID though. But they offer (for free) a 100 GB FTP storage space which is more than enough to backup the base system and bootstrap it again in case of disk failure.<\/p>\n<p>An advantage of dedicated over VPS is that you can install almost any OS you want. The management console comes with an easy install for FreeBSD 11 on UFS. But I thought it would be nice to use ZFS instead. Yeah, I hear you, why using ZFS with only one HDD and non-ECC memory? But with 16 GB it still comes as a viable alternative.<\/p>\n<p>The method I used was adapted from a post on <a href=\"https:\/\/forum.online.net\/index.php?\/topic\/5879-en-2016-freebsd-prend-ses-aises\">Online.net&#8217;s forum<\/a>. So here we go. First, reboot in rescue mode from the console. Choose FreeBSD 10.2 (or higher) as the rescue OS. Once you are logged on the rescue, switch to root and bootstrap FreeBSD:<\/p>\n<p><code><br \/>\nSWAP_SIZE=4g<br \/>\nTEMP_ROOT_PASSWORD=\"1337rul35\"<\/p>\n<p># Create partitions table<br \/>\ngpart destroy -F ada0<br \/>\ngpart create -s gpt ada0<br \/>\ngpart add -t freebsd-boot -l boot -s 512K ada0<br \/>\ngpart add -t freebsd-swap -l swap -s $SWAP_SIZE -a 1m ada0<br \/>\ngpart add -t freebsd-zfs  -l zfs0 ada0<\/p>\n<p># Install MBR<br \/>\ndd if=\/dev\/zero of=ada0p3 count=560 bs=512<br \/>\ngpart bootcode -b \/boot\/pmbr -p \/boot\/gptzfsboot -i 1 ada0<\/p>\n<p># Create ZFS pool and FS<br \/>\nzpool create -f -m none -o altroot=\/mnt -o cachefile=\/tmp\/zpool.cache -O compress=lz4 -O atime=off zroot gpt\/zfs0<br \/>\nzfs create -o mountpoint=\/         zroot\/ROOT<br \/>\nzfs create -o mountpoint=\/usr      zroot\/usr<br \/>\nzfs create -o mountpoint=\/var      zroot\/var<br \/>\nzfs create -o mountpoint=\/tmp      zroot\/tmp<br \/>\nzfs create -o mountpoint=\/www      zroot\/www<br \/>\nzfs create -o mountpoint=\/usr\/home zroot\/usr\/home<br \/>\nzpool set bootfs=zroot\/ROOT zroot<\/p>\n<p># Bootstrap<br \/>\ncd \/mnt<br \/>\nfetch ftp:\/\/ftp.freebsd.org\/pub\/FreeBSD\/releases\/amd64\/amd64\/11.0-RELEASE\/base.txz<br \/>\nfetch ftp:\/\/ftp.freebsd.org\/pub\/FreeBSD\/releases\/amd64\/amd64\/11.0-RELEASE\/kernel.txz<br \/>\ntar --unlink -Jxpf base.txz -C \/mnt<br \/>\ntar --unlink -Jxpf kernel.txz -C \/mnt<br \/>\nrm base.txz kernel.txz<\/p>\n<p># Configuration<br \/>\n# 1) fstab and swap<br \/>\ncat << EOF > \/mnt\/etc\/fstab<br \/>\nada0p2 none swap sw 0 0<br \/>\nEOF<\/p>\n<p># 2) rc.conf<br \/>\ncat << EOF > \/mnt\/etc\/rc.conf<br \/>\nkeymap=\"fr.acc\"<br \/>\nifconfig_igb0=\"DHCP\"<br \/>\nifconfig_igb1=\"DHCP\"<br \/>\nfsck_y_enable=\"YES\"<br \/>\nbackground_fsck=\"YES\"<br \/>\nzfs_enable=\"YES\"<br \/>\nsshd_enable=\"YES\"<br \/>\nEOF<\/p>\n<p># 3) loader.conf<br \/>\ncat << EOF > \/mnt\/boot\/loader.conf<br \/>\nzfs_load=\"YES\"<br \/>\nvfs.root.mountfrom=\"zfs:zroot\/ROOT\"<br \/>\nboot_multicons=\"YES\"<br \/>\nboot_serial=\"YES\"<br \/>\ncomconsole_speed=\"9600\"<br \/>\nconsole=\"comconsole\"<br \/>\ncomconsole_port=\"0x2F8\"<br \/>\nEOF<\/p>\n<p># 4) TTY for serial console<br \/>\ncat << EOF >> \/mnt\/etc\/ttys<br \/>\nttyu1   \"\/usr\/libexec\/getty std.9600\"   vt100   on  secure<br \/>\nEOF<\/p>\n<p># 5) Temporary root password<br \/>\necho \"$TEMP_ROOT_PASSWORD\" | pw -R \/mnt user mod -n root -h 0<\/p>\n<p># Last step<br \/>\ncd ~<br \/>\nzpool export zroot<br \/>\nzpool import -o altroot=\/mnt -o cachefile=\/tmp\/zpool.cache zroot<br \/>\ncp \/tmp\/zpool.cache \/mnt\/boot\/zfs<\/p>\n<p># Terminated!<br \/>\nhalt<br \/>\n<\/code><\/p>\n<p>Now from the management console, reboot in normal mode and connect to your box using serial connection. You should be able to login with root and continue the configuration from there.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Online.net&#8217;s Dedibox XC 2016 comes with 16 GB DDR3 and 1 To SATA or 250 GB SSD on a 8 cores Atom CPU. This is a very nice entry-level dedicated box for anyone who want to upgrade from a small &hellip; <a href=\"https:\/\/hauweele.net\/~gawen\/blog\/?p=1085\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[771,756,772,389,769,773,755,770,768],"class_list":["post-1085","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-bootstrap","tag-dedibox","tag-dedicated","tag-freebsd","tag-install","tag-online","tag-online-net","tag-xc-2016","tag-zfs"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1085"}],"version-history":[{"count":0,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1085\/revisions"}],"wp:attachment":[{"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}