From owner-freebsd-questions@freebsd.org Tue Jan 16 08:52:19 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF343EB59E3 for ; Tue, 16 Jan 2018 08:52:19 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from smtp.fagskolen.gjovik.no (smtp.fagskolen.gjovik.no [IPv6:2001:700:1100:1:200:ff:fe00:b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.fagskolen.gjovik.no", Issuer "Fagskolen i Gj??vik" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 858FA6EAD8 for ; Tue, 16 Jan 2018 08:52:19 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from mail.fig.ol.no (localhost [127.0.0.1]) by mail.fig.ol.no (8.15.2/8.15.2) with ESMTPS id w0G8qCl2072850 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 16 Jan 2018 09:52:12 +0100 (CET) (envelope-from trond@fagskolen.gjovik.no) Received: from localhost (trond@localhost) by mail.fig.ol.no (8.15.2/8.15.2/Submit) with ESMTP id w0G8qC1v072847 for ; Tue, 16 Jan 2018 09:52:12 +0100 (CET) (envelope-from trond@fagskolen.gjovik.no) X-Authentication-Warning: mail.fig.ol.no: trond owned process doing -bs Date: Tue, 16 Jan 2018 09:52:12 +0100 (CET) From: =?ISO-8859-1?Q?Trond_Endrest=F8l?= Sender: Trond.Endrestol@fagskolen.gjovik.no To: FreeBSD questions Subject: Re: Dualboot and ZFS In-Reply-To: <20180116034929.GB89443@admin.sibptus.transneft.ru> Message-ID: References: <20180115051308.GA45168@admin.sibptus.transneft.ru> <20180115125241.GB60956@admin.sibptus.transneft.ru> <20180115144747.GA65526@admin.sibptus.transneft.ru> <20180115151526.GA66342@admin.sibptus.transneft.ru> <20180116034929.GB89443@admin.sibptus.transneft.ru> User-Agent: Alpine 2.21 (BSF 202 2017-01-01) Organization: Fagskolen Innlandet OpenPGP: url=http://fig.ol.no/~trond/trond.key MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail.fig.ol.no X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jan 2018 08:52:20 -0000 On Tue, 16 Jan 2018 10:49+0700, Victor Sudakov wrote: > Dean E. Weimer wrote: > > [dd] > > > > For me, however, running "make installworld DESTDIR=xxx" is also > > > installing. Can DESTDIR be a zpool on a MBR/BSD slice? > > > > You can do an install from source to a zfs dataset no matter where it > > exists as that just shows up as any other mount point, but if you want > > to be able to boot from it I would suggest making it on a GPT disk. > > The whole point of my question was to install FreeBSD/ZFS as a second > system to a box where Windows/NTFS already occupies one MBR partition and > there is another MBR partition for FreeBSD. Do you think there is no > such luck? I > > > checked and there is a section on the wiki > > about installing > > to MBR, but its flagged as will not boot. > > "Will not boot"? That is odd because: > > 1. That's basically the setup Manish suggested (using ada0s3a for > zpool), and I think it works for him if he gave this advice. > > 2. zfsboot(8) is designed for MBR so why would it fail to boot? > > > By the way the setup I sent was installed by using the live CD, creating > > But your setup is not dualboot which I was asking about. I couldn't resist attempting a proof of concept, so here it is. The main motivation for using a BSD disklabel within a MBR slice is to have a ZFS partition and a swap partition while only consuming one of the four available MBR slices. You also avoid using a zvol for swap/dump. See https://wiki.freebsd.org/RootOnZFS/ZFSBootPartition for more details. Script started on Tue Jan 16 08:40:32 2018 # PS1='[script]# ' !!! These are the two MBR slices created by Windows 10, half of ada0 is available for FreeBSD !!! [script]# gpart show ada0 => 63 134217665 ada0 MBR (64G) 63 1985 - free - (993K) 2048 1024000 1 ntfs [active] (500M) 1026048 66082816 2 ntfs (32G) 67108864 67108864 - free - (32G) !!! Now, add our FreeBSD slice !!! [script]# gpart add -t freebsd ada0 ada0s3 added !!! Here it is !!! [script]# gpart show ada0 => 63 134217665 ada0 MBR (64G) 63 1985 - free - (993K) 2048 1024000 1 ntfs [active] (500M) 1026048 66082816 2 ntfs (32G) 67108864 67108864 3 freebsd (32G) !!! Create a BSD disklabel within the FreeBSD slice !!! [script]# gpart create -s BSD ada0s3 ada0s3 created [script]# gpart show ada0 => 63 134217665 ada0 MBR (64G) 63 1985 - free - (993K) 2048 1024000 1 ntfs [active] (500M) 1026048 66082816 2 ntfs (32G) 67108864 67108864 3 freebsd (32G) !!! Yes, the disklabel is in place !!! [script]# gpart show ada0s3 => 0 67108864 ada0s3 BSD (32G) 0 67108864 - free - (32G) !!! Add our ZFS partition !!! [script]# gpart add -s 28G -t freebsd-zfs ada0s3 ada0s3a added !!! Add our swap partition !!! [script]# gpart add -t swap ada0s3 ada0s3b added !!! Show the resulting disklabel !!! [script]# gpart show ada0s3 => 0 67108864 ada0s3 BSD (32G) 0 58720256 1 freebsd-zfs (28G) 58720256 8388608 2 freebsd-swap (4.0G) !!! Load the ZFS module, and optionally set the ashift property to 12 !!! [script]# kldload zfs [script]# sysctl vfs.zfs.min_auto_ashift=12 vfs.zfs.min_auto_ashift: 9 -> 12 !!! Create our zpool, YMMV !!! [script]# zpool create -O mountpoint=legacy zroot /dev/ada0s3a !!! Create our initial BE, YMMV !!! [script]# uname -a FreeBSD 11.1-STABLE FreeBSD 11.1-STABLE #0 r327786: Wed Jan 10 22:26:38 UTC 2018 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 [script]# zfs create zroot/ROOT [script]# zfs create zroot/ROOT/20180110-r327786 [script]# zfs set mountpoint=/tmp/zroot zroot/ROOT/20180110-r327786 !!! The BE is temporary mounted at /tmp/zroot !!! [script]# df -ah Filesystem Size Used Avail Capacity Mounted on /dev/iso9660/11_1_STABLE_AMD64_CD 701M 701M 0B 100% / devfs 1.0K 1.0K 0B 100% /dev tmpfs 32M 124K 32M 0% /var tmpfs 20M 68K 20M 0% /tmp zroot/ROOT/20180110-r327786 27G 88K 27G 0% /tmp/zroot !!! Extract a minimum installation !!! [script]# cd /tmp/zroot [script]# tar xf /usr/freebsd-dist/base.txz [script]# tar xf /usr/freebsd-dist/kernel.txz [script]# tar xf /usr/freebsd-dist/lib32.txz !!! Ensure the ZFS module will be loaded by the loader !!! [script]# echo 'zfs_load="YES"' >> boot/loader.conf !!! Make a note of our swap partition !!! [script]# echo '/dev/ada0s3b none swap sw 0 0' >> etc/fstab !! Prepare our pool for export !!! [script]# zfs unmount -a [script]# zfs inherit mountpoint zroot/ROOT/20180110-r327786 [script]# zpool set bootfs=zroot/ROOT/20180110-r327786 zroot [script]# df -ah Filesystem Size Used Avail Capacity Mounted on /dev/iso9660/11_1_STABLE_AMD64_CD 701M 701M 0B 100% / devfs 1.0K 1.0K 0B 100% /dev tmpfs 32M 128K 32M 0% /var tmpfs 20M 68K 20M 0% /tmp [script]# zpool export zroot !!! Write the boot manager to the boot block in the MBR !!! [script]# gpart bootcode -b /boot/boot0 /dev/ada0 bootcode written to ada0 !!! Write /boot/zfsboot as two separate pieces to /dev/ada0s3{,a} !!! [script]# dd if=/boot/zfsboot of=/tmp/zfsboot1 count=1 1+0 records in 1+0 records out 512 bytes transferred in 0.000383 secs (1337758 bytes/sec) [script]# gpart bootcode -b /tmp/zfsboot1 /dev/ada0s3 bootcode written to ada0s3 [script]# dd if=/boot/zfsboot of=/dev/ada0s3a skip=1 seek=1024 128+0 records in 128+0 records out 65536 bytes transferred in 0.043591 secs (1503439 bytes/sec) !!! Import our pool !!! [script]# zpool import zroot [script]# zfs list -rt all NAME USED AVAIL REFER MOUNTPOINT zroot 742M 26.2G 88K legacy zroot/ROOT 742M 26.2G 88K legacy zroot/ROOT/20180110-r327786 742M 26.2G 742M legacy !!! Everything checks out, it's time for a reboot to assess the damage !!! [script]# exit Script done on Tue Jan 16 08:53:07 2018 Both Windows 10 and FreeBSD boots, so I would call this a success. -- Trond.