Share UFS and ZFS on FreeBSD 9

       299 words, 2 minutes

On my way for a new experiment, I want to share a UFS and a ZFS partitions on a single disk using FreeBSD 9. Although it is a quite arguable configuration, it is quite simple achieve.

Install the FreeBSD system using your preferred media. When the partition tool pops up, use a customize configuration.

Leave the “freebsd-boot” GPT partition untouched and remove the “freebsd-ufs” and “freebsd-swap” ones.
Create a new swap partition, using the “freebsd-swap” type.
Create a new (smaller) UFS partition, using the “freebsd-ufs” type.
Create a new ZFS partition, using the “freebsd-zfs” type.

Finish the installation as usual.

When the system reboots, log-in using your preferred way, load the ZFS modules and create the new pool:

  # sudo kldload opensolaris.ko
  # sudo kldload zfs.ko
  
  # sudo vi /boot/loader.conf
  (...)
  vfs.zfs.prefetch_disable="1"
  zfs_load="YES"
  
  # sudo vi /etc/rc.conf 
  (...)
  zfs_enable="YES"
  
  # gpart list
  Geom name: ada0
  (...)
  Providers:
  1. Name: ada0p1
     Mediasize: 65536 (64k)
     type: freebsd-boot
  (...)
  2. Name: ada0p2
     Mediasize: 17179869184 (16G)
     label: root
     type: freebsd-ufs
  (...)
  3. Name: ada0p3
     Mediasize: 8589934592 (8.0G)
     label: swap
     type: freebsd-swap
  (...)
  4. Name: ada0p4
     Mediasize: 473520144384 (441G)
     label: zfs
     type: freebsd-zfs
  (...)
  Consumers:
  1. Name: ada0
     Mediasize: 500107862016 (465G)
     Sectorsize: 512
     Mode: r2w2e3
  
  # sudo zpool create tank ada0p4
  
  # zpool list
  NAME   SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
  tank   440G    77K   440G     0%  1.00x  ONLINE  -
  
  # zpool status tank
    pool: tank
   state: ONLINE
   scan: none requested
  config:
  
  	NAME        STATE     READ WRITE CKSUM
  	tank        ONLINE       0     0     0
  	  ada0p4    ONLINE       0     0     0
  
  errors: No known data errors
  # df -h
  Filesystem     Size    Used   Avail Capacity  Mounted on
  /dev/ada0p2     15G    2.8G     11G    19%    /
  devfs          1.0k    1.0k      0B   100%    /dev
  tank           433G     31k    433G     0%    /tank

That’s it, the system is now ready to use both UFS and ZFS storage.