Re: gpart, bsdlabel and fdisk

From: Robert Noland <rnoland_at_FreeBSD.org>
Date: Wed, 21 Oct 2009 20:16:28 -0500
On Wed, 2009-10-21 at 16:17 +1100, Aristedes Maniatis wrote:
> We are setting up a FreeBSD system from scratch and wanting to understand the new gpart utility. Our goal is to create a ZFS bootable install (mirror). In the past our approach has been to:
> 
> 1. fdisk (allocate entire disk)
> 2. partition (1Gb UFS boot partition, swap and rest empty for ZFS)
> 3. set up ZFS [1]

Make sure that your loader has zfs support.  Setting
LOADER_ZFS_SUPPORT="YES" in make.conf will take care of it.

gpart create -s GPT <disk>
gpart add -t freebsd-boot -s 128 <disk>
gpart add -t freebsd-swap -s XXX[mg] <disk>
gpart add -t freebsd-zfs <disk>
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 <disk>
[I committed a patch that will set the active flag when you install
bootcode, but it is only in -CURRENT so far.

zpool create <pool> [mirror, raidz] <disk> <disk> ...

If you want more than a single root filesystem:

zfs create <filesystem>

You will need 3 other steps...

Now, install FreeBSD.

I generally bootstrap from a running system, so I just stick the disks
in and "make installworld DESTDIR=/pool && make installkernel
DESTDIR=/pool" followed by a "mergemaster -i -D /pool"

You need to install a cache in /boot/zfs/zpool.cache on the new
filesystem.  I generally do this by setting "zpool set
cachefile=/tmp/<poolname>.cache and then copying that
to /boot/zfs/zpool.cache.

After that, I usually set "zfs set mountpoint=legacy <pool>" which will
unmount the filesystem.

The gpart piece is really easy, once you get the hang of it...  Setting
up zfs root on a new machine is mostly tricky because you need to make
sure that you have a working loader.

robert.

> Now we want to understand how to avoid the bootable UFS partition (which causes us some grief), but there is very little information about gpart as the tool to do it. I've found various guides (eg [2]) but am a little underwhelmed by the documentation, especially with magic commands like this as part of the set up:
> 
> echo 'a 1' | fdisk -f - /dev/ad4
> 
> It appears that gpart is largely replacing fdisk and bsdlabel.
> 
> * is this the future for FreeBSD and we should use gpart from here on? Are the old tools deprecated?
> 
> * we tried to reinstall the machine with some 7.2 CDs but the gparted disks caused fdisk to crash. Is this expected?
> 
> * is the result of using gpart completely different to the bsdlabel/fdisk we've known? Are the partitions on disk quite different?
> 
> * is there some source of good documentation out there other than the man page for gpart?
> 
> * has the MBR changed now with gpart?
> 
> 
> Thanks
> 
> Ari Maniatis
> 
> 
> [1] https://www.ish.com.au/solutions/articles/freebsdzfs
> [2] http://outpost.h3q.com/patches/manageBE/create-FreeBSD-ZFS-bootfs.txt

-- 
Robert Noland <rnoland_at_FreeBSD.org>
FreeBSD
Received on Wed Oct 21 2009 - 23:16:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:57 UTC