New desktop machine and how to start with FreeBSD

Hey,

Next month I'll be getting a brand new desktop PC - Intel Haswell, SSD, and for starters NO GPU (I hope to get some of the new nVidia cards, but I don't know when). And I want to switch to FreeBSD (I've been using Linux for some time).

Is the new Intel HD 4600 supported or will I have some troubles with it? As far as I know it will work on FreeBSD 9.1+, right?

I checked the handbook, and also this - https://wiki.freebsd.org/RootOnZFS but I need your help and guidance. On the RootOnZfs link I provided there is no 'SSD' nor 'align' words, but while I was doing research regarding SSDs, most of the guides were talking about aligning partitions.

So what I need is a good and up to date guide for root on ZFS.

This will be my personal machine, a 'workstation', where I hope I will learn FreeBSD. Any advice you have is welcome, even books/articles/anything really.

Thanks,
developej
 
This is a very good ZFS how-to, I suggest you start from there, and then compare with what you already have. Here's a link to these forums which I googled with freebsd ssd zfs.

As for the Intel graphics, I think the intel driver that comes with x11/xorg works fine, but you have to enable KMS. @wblock@ posted some pointers on how to do it here. You can see some suggestions on FreeBSD wiki pages here, and here. As you already guessed, it should work on FreeBSD 9.1-RELENG (so, the release version) and 9.1-STABLE (because of the KMS support).

More on hardware compatibility can be found in the handbook, or 9.1 release notes.
 
Last edited by a moderator:
Ok, thanks. I'll keep researching and try to figure out what works best for me. If anyone else has some good guides/links, please share.

Thanks,
developej
 
New desktop will arrive in the middle of this month (I hope), so I still have time to do research. I got some new questions:
  1. If I have 16[]GB of RAM, do I need swap? Or is this one of those questions with not one true answer?
  2. I read that ARC first uses RAM. How can I be sure that level 2 ARC (L2ARC) uses SSD and not HDD?
  3. . What are your thoughts on NOT using ECC RAM with ZFS? I read it's not smart, then I read it's not so big of a deal - again one of those questions with not one true answer?
  4. If I install my system on a SSD, and I have two HDDs in a ZFS mirror, what happens with that mirror if after some time I need to reinstall the system? Or say I get a newer/faster/larger SSD? Does mirror need to be reinitialized in some way or anything like that?

Thanks,
developej
 
I don't use zfs or SSD hard drives, so I cannot answer all those questions. I can give you some advice regarding partitioning and SWAP though. I recommend that you read tuning(8)() and the corresponding section in the Handbook.

As you can see, tuning(8)() suggests that you use twice as much SWAP as you have RAM, because this way the kernel will really take advantage of RAM to the fullest, without holding back. If you have more than 4 GiB RAM, use as much space for SWAP as you have RAM, so in your case 16 GiB.

However, you can experiment, don't use a SWAP partition, but a SWAP file (see Handbook for instructions) and see if you really need it. I have 3 GiB of RAM, and most SWAP I've used so far with my current configuration was 16 MiB (unless I'm running my own calculations which can easily take 10 GiB of memory). If you are planning to use that monster of a machine for numerics, then no amount of SWAP will be enough, but at least you can adjust it at will, using the SWAP file. There are some disadvantages to performance when you use SWAP files, and can also decrease the lifetime of your SSD drives, so use that with caution.
 
  1. The old guideline of having twice as much swap as RAM is outdated. With 16[ ]GB of RAM, the system is unlikely to require swap, but it's still useful to have some.
  2. No idea.
  3. ECC is nice, nicer the more memory you have. Really a judgement call.
  4. The metadata on the ZFS array lets it be moved from system to system with no changes.
 
If I have 16[]GB of RAM, do I need swap? Or is this one of those questions with not one true answer?
I have 8 GB RAM and do not use SWAP with ZFS, haven't seen any issues.

I read that ARC first uses RAM. How can I be sure that level 2 ARC (L2ARC) uses SSD and not HDD?
ARC (L1ARC) = RAM cache
L2ARC is cache on disk additional to ARC, it can be deployed on any block storage, but it works best when deployed on fast I/O drives (SSDs/Flash).
 
vermaden said:
ARC (L1ARC) = RAM cache
L2ARC is cache on disk additional to ARC, it can be deployed on any block storage, but it works best when deployed on fast I/O drives (SSDs/Flash).

Yes, I understand that, but how do I make sure that it is deployed on SSD and not HDD? I found here that I should do a zpool add <pool> cache <device>, but the problem is I don't want to dedicate the whole SSD to it - so how do I limit it? I'm guessing that the more space I give it the better, but since this will not be a server - I'm only playing with this - I'd like to limit the size.
 
I've been doing some more research and wrote a few scripts to help me with the install process. Most parts are taken from several different guides and then tweaked to fit my needs.

My machine will have one 256 GB SSD and one 1 TB HDD, but scripts are written in such a way that they can be used with any number of disks. I decided on a setup that will have one zpool on SSD for the system, and one zpool on HDD for the storage.

Since I'm new to this, I need someone to tell me if everything is ok with the scripts.

1. First script is for GPT programming of the system disk(s). It destroys any partitions, creates a boot, swap, and zfs partitions.
It also takes into account the alignment of the partitions.

Code:
#!/bin/sh

echo "gpt programming system disk(s) ..."
ctr=0
for disk in $*; do
	gpart destroy -F $disk
	gpart create -s gpt $disk
	gpart add -b 34 -s 478 -t freebsd-boot       -l bootfs${ctr} $disk
	gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $disk
	gpart add -b 1M -s 8G  -t freebsd-swap -a 4K -l swap${ctr} $disk
        gpart add              -t freebsd-zfs  -a 4K -l sys${ctr} $disk
	gnop create -S 4096 ${disk}p3
	ctr=`expr $ctr + 1`
done

2. Second script is for GPT programming of the storage disk(s). It destroys any partitions, and then creates a single zfs partition.
It also takes into account the alignment of the partitions.

#!/bin/sh

Code:
echo "gpt programming storage disk(s) ..."
ctr=0
for disk in $*; do
	gpart destroy -F $disk
	gpart create -s gpt $disk
        gpart add              -t freebsd-zfs  -a 4K -l storage${ctr} $disk
	gnop create -S 4096 ${disk}p1
	ctr=`expr $ctr + 1`
done

3. Third script is for ZFS-ing system disk(s).

Code:
#!/bin/sh

echo -e "provide the list of disk(s) ..."'\r'
read disks
echo "disks: $disks"

zpool create -o altroot=/mnt zsys $disks

zfs set checksum=fletcher4
zfs unmount zsys
zfs create -o mountpoint=/                                    zsys/zroot
zfs create -o compression=on    -o exec=on     -o setuid=off  zsys/tmp
zfs create                                                    zsys/usr
zfs create                                                    zsys/usr/home
zfs create -o compression=lzjb                 -o setuid=off  zsys/usr/ports
zfs create -o compression=lzjb  -o exec=off    -o setuid=off  zsys/usr/src
zfs create                                                    zsys/var
zfs create -o compression=lzjb  -o exec=off    -o setuid=off  zsys/var/log
zfs create -o compression=lzjb  -o exec=on     -o setuid=off  zsys/var/tmp
chmod 1777 /mnt/tmp
chmod 1777 /mnt/var/tmp

zfs unmount -a

zpool set bootfs=zsys/zroot     zsys
zfs set mountpoint=/zsys        zsys
zfs set atime=off               zsys
zfs set mountpoint=/            zsys/zroot
zfs set mountpoint=/tmp         zsys/tmp
zfs set mountpoint=/usr         zsys/usr
zfs set mountpoint=/var         zsys/var

zfs mount -a

4. Fourth script is for ZFS-ing storage disk(s).

Code:
#!/bin/sh

echo -e "provide the list of disks(s) ..."'\r'
read disks
echo "disks: $disks"

zpool create -o altroot=/mnt zstorage $disks

zfs set checksum=fletcher4
zfs unmount zstorage
zfs create -o mountpoint=/storage                             zstorage/storage

zfs unmount -a

zfs set mountpoint=/zstorage    zstorage
zfs set atime=off               zstorage
zfs set mountpoint=/storage     zstorage/storage

zfs mount -a

5. Fifth script is for installing FreeBSD.

Code:
#!/bin/sh

echo "installing FreeBSD - base.txz, lib32.txz, kernel.txz, doc.txz, ports.txz, src.txz"
echo "this will take a few minutes ..."
cd /usr/freebsd-dist
export DESTDIR=/mnt
for file in base.txz lib32.txz kernel.txz doc.txz ports.txz src.txz;
do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done
echo "done"

6. Sixth script is post-install stuff.

#!/bin/sh

Code:
mount -t devfs devfs /dev
echo 'zfs_load="YES"' >> /boot/loader.conf
echo 'zfs_enable="YES"' >> /etc/rc.conf
zfs set readonly=on  zsys/var/empty
zpool set cachefile=/boot/zfs/zpool.cache  zsys
sync

Will this work in a way I described at the begining of the post (one zpool on SSD for the system, and one zpool on HDD for the storage)?

Thanks,
developej
 
developej said:
[*] If I have 16[]GB of RAM, do I need swap?

No true answer really.

Strictly speaking with 16 GB you don't NEED swap unless your workload is larger than 16 GB in size.

How big is your workload? We have no idea.
 
throAU said:
No true answer really.

Strictly speaking with 16 GB you don't NEED swap unless your workload is larger than 16 GB in size.

How big is your workload? We have no idea.

Well that's the problem - I don't know yet. As I said I'm only starting with FreeBSD and I will mostly play with features. I just needed a 'safe' start, and as far as I understood, 16 GB of RAM and 8 GB of swap should be a safe bet.
 
developej said:
Well that's the problem - I don't know yet. As I said I'm only starting with FreeBSD and I will mostly play with features. I just needed a 'safe' start, and as far as I understood, 16 GB of RAM and 8 GB of swap should be a safe bet.

So just create SWAP on ZFS with desired size, you will be able to change that zillion times after installation.

Code:
# zfs create -V 2G zpool/swap
# zfs set org.freebsd:swap=on zpool/swap
# zfs set checksum=off zpool/swap
 
To be on the safe side turn off caching for the swap ZVOL as well, this may prevent a race between swap and ARC cache in low memory situations:

zfs set primarycache=none zpool/swap
zfs set secondarycache=none zpool/swap

You will lose the ability to save a kernel crash dump when the swap is on a ZVOL but in your case it probably doesn't matter.
 
Here is the updated version of the scripts. I added some comments so other like me can maybe find all this a little easier...

A question - in script 4 - zfsstorage.sh, can I set the altroot the way I did? Considering I already have a zpool (created in script 3 - zfssys.sh) - will these two zpools work this way or I need to set them in some other way?

Code:
# 1 - gptsystemdisks.sh
#!/bin/sh

echo "gpt programming system disk(s) ..."
ctr=0
for disk in $*; do
    echo "destroying the partitioning scheme on $disk ..."
    gpart destroy -F $disk
    echo "creating the partitioning scheme on $disk ..."
    gpart create -s gpt $disk
    echo "adding the boot partition to $disk ..."
    # lba 34 is the first usable sector on the disk.
    # 512k is the largest safe size due to code limitations in the loader.
    # although the boot code is much smaller, there is no reason
    # not to make it future proof
    gpart add -b 34 -s 512k -t freebsd-boot       -l bootfs${ctr} $disk
    gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $disk
    echo "adding the zfs partition to $disk ..."
    # we start at 1M because of the alignment
    gpart add -b 1M         -t freebsd-zfs  -a 4k -l sys${ctr} $disk
    ctr=`expr $ctr + 1`
done

echo "done."


# 2 - gptstoragedisks.sh
#!/bin/sh

echo "gpt programming storage disk(s) ..."
ctr=0
for disk in $*; do
    echo "destroying the partitioning scheme on $disk ..."
    gpart destroy -F $disk
    echo "creating the partitioning scheme on $disk ..."
    gpart create -s gpt $disk
    echo "adding the zfs partition to $disk ..."
    # we start at 1M because of the alignment
    gpart add -b 1M         -t freebsd-zfs  -a 4k -l storage${ctr} $disk
    ctr=`expr $ctr + 1`
done

echo "done."


# 3 - zfssys.sh
#!/bin/sh

echo -e "provide the list of disk(s) ..."'\r'
read disks
echo "disks: $disks"

echo "creating the zsys pool ..."
zpool create -o altroot=/mnt zsys $disks

zfs set checksum=fletcher4
zfs unmount zsys

echo "creating zfs filesystems ..."
zfs create -o mountpoint=/                                    zsys/zroot
zfs create -o compression=on    -o exec=on     -o setuid=off  zsys/tmp
zfs create                                                    zsys/usr
zfs create                                                    zsys/usr/home
zfs create -o compression=lzjb                 -o setuid=off  zsys/usr/ports
zfs create -o compression=lzjb  -o exec=off    -o setuid=off  zsys/usr/src
zfs create                                                    zsys/var
zfs create -o compression=lzjb  -o exec=off    -o setuid=off  zsys/var/log
zfs create -o compression=lzjb  -o exec=on     -o setuid=off  zsys/var/tmp

echo "creating swap on zfs ..."
zfs create -V 8G zsys/swap
zfs set org.freebsd:swap=on zsys/swap
zfs set checksum=off zsys/swap
zfs set primarycache=none zsys/swap
zfs set secondarycache=none zsys/swap

echo "setting some permissions ..."
chmod 1777 /mnt/tmp
chmod 1777 /mnt/var/tmp

zfs unmount -a

zpool set bootfs=zsys/zroot     zsys
zfs set mountpoint=/zsys        zsys
zfs set atime=off               zsys
zfs set mountpoint=/            zsys/zroot
zfs set mountpoint=/tmp         zsys/tmp
zfs set mountpoint=/usr         zsys/usr
zfs set mountpoint=/var         zsys/var

zfs mount -a

echo "done."


# 4 - zfsstorage.sh
#!/bin/sh

echo -e "provide the list of disk(s) ..."'\r'
read disks
echo "disks: $disks"

echo "creating the zstorage pool ..."
zpool create -o altroot=/mnt zstorage $disks

zfs set checksum=fletcher4
zfs unmount zstorage

echo "creating zfs filesystem ..."
zfs create -o mountpoint=/storage                             zstorage/storage

zfs unmount -a

zfs set mountpoint=/zstorage    zstorage
zfs set atime=off               zstorage
zfs set mountpoint=/storage     zstorage/storage

zfs mount -a

echo "done."


# 5 - installfreebsd.sh
#!/bin/sh

echo "installing FreeBSD ..."
sleep 1
echo "this will take a few minutes ..."
cd /usr/freebsd-dist
export DESTDIR=/mnt
echo "installing base ...";   cat base.txz   | tar --unlink -xpJf - -C ${DESTDIR:-/}
echo "installing doc ...";    cat doc.txz    | tar --unlink -xpJf - -C ${DESTDIR:-/}
echo "installing kernel ..."; cat kernel.txz | tar --unlink -xpJf - -C ${DESTDIR:-/}
echo "installing lib32 ...";  cat lib32.txz  | tar --unlink -xpJf - -C ${DESTDIR:-/}
echo "installing ports ...";  cat ports.txz  | tar --unlink -xpJf - -C ${DESTDIR:-/}
echo "installing src ...";    cat src.txz    | tar --unlink -xpJf - -C ${DESTDIR:-/}

echo "done."


# 6 - post-install.sh
#!/bin/sh

echo "post-install stuff ..."
mount -t devfs devfs /dev
echo 'zfs_load="YES"' >> /boot/loader.conf
echo 'zfs_enable="YES"' >> /etc/rc.conf
echo 'ifconfig_igb="dhcp"' >> /etc/rc.conf
touch /etc/fstab
zfs set readonly=on  zsys/var/empty
zpool set cachefile=/boot/zfs/zpool.cache  zsys
sync

echo "done."
sleep 1
echo "you can reboot now."

Thanks,
developej
 
Back
Top