Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jan 2018 19:52:41 +0700
From:      Victor Sudakov <vas@mpeks.tomsk.su>
To:        Manish Jain <bourne.identity@hotmail.com>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: Dualboot and ZFS
Message-ID:  <20180115125241.GB60956@admin.sibptus.transneft.ru>
In-Reply-To: <VI1PR02MB12007D071EA5398373D2189CF6EB0@VI1PR02MB1200.eurprd02.prod.outlook.com>
References:  <20180115051308.GA45168@admin.sibptus.transneft.ru> <VI1PR02MB12007D071EA5398373D2189CF6EB0@VI1PR02MB1200.eurprd02.prod.outlook.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Manish Jain wrote:
> > 
> > I have a box with dual boot: Windows and FreeBSD/UFS:
> > 
> > $ gpart show ada0
> > =>       63  976773105  ada0  MBR  (466G)
> >           63       1985        - free -  (993K)
> >         2048  293029888     1  ntfs  [active]  (140G)
> >    293031936  598958080     2  ntfs  (286G)
> >    891990016   83886080     3  freebsd  (40G)
> >    975876096     897072        - free -  (438M)
> > 
> > $ gpart show ada0s3
> > =>       0  83886080  ada0s3  BSD  (40G)
> >           0  75497472       1  freebsd-ufs  (36G)
> >    75497472   8388607       2  freebsd-swap  (4.0G)
> >    83886079         1          - free -  (512B)
> > 
> > $
> > 
> > boot0 handles the OS selection, everything works just fine.
> > 
> > Can I install FreeBSD with root-on-zfs into ada0s3 somehow?
> > 
> 
> Hi Victor,
> 
> Yes, you can. But you will need a spare slice somewhere - another disk 
> (SATA / USB). If the used potion of your ada0s3a is small, you can even 
> use a USB pen drive.
> 
> You can rsync your current installation to the spare slice, and then 
> mirror the sync back to a newly created ada0s3-zfs.

Sorry if my question was misleading, I did not mean converting the
existing system from UFS to ZFS at ada0s3. Suppose ada0s3 is an unused
slice, I can probably create a zpool thereon. But a few questions
remain:

1. Can I install a root-on-zfs system on ada0s3 with bsdinstall? I
suppose not?

2. In case of rsync/restore/installworld, what do I do about the VBR
in ada0s3? This VBR should support booting from ZFS. Looks like
zfsboot(8) allows this.

3. Please see the other questions below, step by step.

> 
> Let's say your spare disk is da0 with 40G spare (or at least the used 
> size of ada0s3a).
> 
> gpart destroy -F da0		# only if needed
> gpart create -s MBR da0		# only if needed
> 
> If da0 already has a spare slice, the 2 steps above are not needed, but 
> then you will need to replace the slice number instead of da0s1 in the 
> steps below.
> 
> gpart add -t freebsd da0	# adds da0s1; note the slice number here
> gpart create -s BSD da0s1
> gpart set -a active -i 1 da0
> gpart add -t freebsd-zfs da0s1
> zpool create zroot /dev/da0s1a

Why are you creating a zpool within a BSD "a" partition, and not in
da0s1 directly? I have never seen such a configuration. Is it even
possible to set the "freebsd-zfs" type on a BSD partition?

And a pool created this way would be non-compatible with beadm. If
anyone has a script to create a beadm-compatible set of datasets,
please share it. But it's already a different matter.

> zpool set bootfs=zroot zroot
> gpart bootcode -b /boot/boot0 da0
> zpool export zroot

So you suggest using boot0 in MBR with zfsboot in VBR? Will that work?

> dd if=/boot/zfsboot of=/tmp/zfsboot1 count=1
> gpart bootcode -b /tmp/zfsboot1 /dev/da0s1
> dd if=/boot/zfsboot of=/dev/da0s1a skip=1 seek=1024

It looks like the procedure described in zfsboot(8) but the da0s1a
(the "a" partition) beats me. Should not the pool be in da0s1 ?

> zpool import zroot
> zfs set checksum=fletcher4 zroot
> 
> 
> {
> cat <<- EOF
> 
> /dev/*
> /proc/*
> /sys/*
> /tmp/*
> /mnt/*
> /media/*
> /lost+found
> /usr/ports
> /usr/src/*
> /zroot
> } > /root/excl
> 
> rsync -aAHXv --delete --exclude-from /root/excl / /zroot/
> 
> 
> echo 'zfs_load=YES' > /zroot/boot/loader.conf
> echo 'vfs.root.mountfrom="zfs:zroot"' >> /zroot/boot/loader.conf
> echo 'kern.geom.label.disk_ident.enable=0' >> /zroot/boot/loader.conf
^^^^^^^^^^^^^^^^^^^^^^^^^^^ why would I need to set this sysctl to 0?
It's "1" by default on my root-on-zfs boxes.

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
AS43859



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180115125241.GB60956>