Tag Archives: zfs

expand AWS EC2 FreeBSD ZFS disk

For testing purpose, I setup a Freebsd instance on AWS, which is using zfs on root.
And then I add 10G disk space to the root volume. Even though I enabled auto-expand for zroot, it seems the 10G space is not added to system. Here are the steps to expand the disk for zroot:

1. Reboot the server.  Even though it’s said that reboot is not necessary, I suggest to reboot the server to make sure server can recognize the new size.

2. As the disk size change, we need to fix the GPT partition table first.

gpart recovery ada0

3. Some documents said can use “zpool online -e” to expand the disk. As shown in above picture, the command can’t auto update GPT and assign the space to zfs partition.

4. We need to use gpart to update GPT first, then expand the zfs partition.

#gpart resize -i 2 ada0
#zpool online -e zrrot /dev/adap2

Increasing disk/zpool size of FreeBSDZFS disks in Linode

I’m running a FreeBSD instance in Linode. And FreeBSD is not the official supported OS in Linode.The disk type is set to raw to install FreeBSD.

And recently Linode upgraded my instance and the disk size is increased from 40G to 80G.

But when I login to the system, I found that my zpool is still 40G. But the disk is shown as 80G.

# gpart show
=>       34  100663229  ada0  GPT  (80G) [CORRUPT]
         34          6        - free -  (3.0K)
         40       1024     1  freebsd-boot  (512K)
       1064        984        - free -  (492K)
       2048    4194304     2  freebsd-swap  (2.0G)
    4196352   96464896     3  freebsd-zfs  (46G)
  100661248       2015        - free -  (1.0M)

I tried to enable zfs autoexpand on my zpool, the same. Then how to increase the disk/zpool size?

First, re-write disk metadata

# gpart recover ada0
ada0 recovered

After this, gpart can show the real disk space info

#:~ # gpart show
=>       40  167772080  ada0  GPT  (80G)
         40       1024     1  freebsd-boot  (512K)
       1064        984        - free -  (492K)
       2048    4194304     2  freebsd-swap  (2.0G)
    4196352   96464896     3  freebsd-zfs  (46G)
  100661248   67110872        - free -  (32G)

Then, expand zfs partition

# gpart resize -i 3 ada0
ada0p3 resized

Then, expand the zpool

zpool online -e zroot /dev/ada0p3

Done!

#:~ # df -h /
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default     74G     29G     45G    39%    /

Don’t forget to write zfs info to disk

gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0

FreeBSD: use mrsas driver to replace mfi driver

My server got a Dell PERC H330 raid card, and I made it’s working in HBA mode to make sure that it can get best performance under FreeBSD with zfs.
But every time when I boot the server, I’ll get below error message and it take a long time to pass the disk check stage.

1

After research, it seems this timeout error was caused by the old mfi driver.
And LSI has released a new mrsas driver for FreeBSD. So It’s better to switch the driver from mfi to mrsas.

First, add below line into /boot/loader.conf

mrsas_load="YES"

And then add below device hint into /boot/device.hints . This line is very important. Without this device hint, FreeBSD will use the old mfi driver for raid card even though you enabled maras drvier.

hw.mfi.mrsas_enable="1"

And then, add below line into /boot/loader.conf to disable disk id identity.

kern.geom.label.gptid.enable="0"
kern.geom.label.disk_ident.enable="0"

Without above two line, after you switch from mfi to mrsas, all the disks will be shown as diskid-*****************。

And don’t forget to update /etc/fstab to change the swap partition from mfi*p* to da*p*. Otherwise you’ll lose your swap partition.

Then, reboot your server, and enjoy.

forget to update the bootloader when updating ZFS filesystems.

Today, when I reboot my freebsd server. Server can’t boot. The error message is

ZFS: unsupported ZFS version 5000 (should be 28)
can't find /boot/zfsloader

default: ssd::/boot/kernel/kernel

boot:
can't find /boot/zfsloader

The problem is caused by that after I update zfs version, I should update bootloader at the same time.

Fix it:

Download the latest Freebsd 9.1 current image. Note:if you are using the stable image, the bootloader in the image is still old and can’t support zfs 29.

Then use the image to boot the server, then enter ‘shell’,run below command for all boot disks:

#gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 mfid0

then reboot the server