Bug 155484 - [ufs] GPT + UFS boot don't work well together
Summary: [ufs] GPT + UFS boot don't work well together
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-11 22:50 UTC by Andrey Vladimirov
Modified: 2011-06-02 15:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Vladimirov 2011-03-11 22:50:10 UTC
I'm trying to setup a system with a large RAID array (total ~4TB)
I do next step:
1. Create the boot, swap and UFS partitions:
 Fixit# gpart add -s 64K -t freebsd-boot mfid0
 Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
 Fixit# gpart add -t freebsd-ufs -l disk0 mfid0
2. Install the Protected MBR (pmbr) and gptboot loader 
Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0
Then install FreeBSD and add this:
echo 'vfs.root.mountfrom="ufs:/dev/mfid0p2"' >> /boot/loader.conf
After rebooting (system not booting) i see message:
is unable to find loader at /boot/loader or can it load /boot/kernel/kernel

I load from DVD and go to Fixit
Copying /boot/loader to /loader allows me to enter /loader at the "boot:"
prompt and the loader will load, however, its unable to load the kernel.

If I do an "ls" at the loader prompt I can see boot listed as a directory
(with a "d" before it).  Trying to do "ls boot" inexplicably it says
"boot: not a directory"

Fix: 

If do next step:
 Fixit# gpart add -s 64K -t freebsd-boot mfid0
 Fixit# gpart add -s 3800G -t freebsd-ufs -l disk0 mfid0
 Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
or
 Fixit# gpart add -s 64K -t freebsd-boot mfid0
next partition must be root(/) 
 Fixit# gpart add -s 3G -t freebsd-ufs -l disk0 mfid0  
 Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0

No problem with boot on GPT.
How-To-Repeat: do next step:
1. Create the boot, swap and UFS partitions:
 Fixit# gpart add -s 64K -t freebsd-boot mfid0
 Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
 Fixit# gpart add -t freebsd-ufs -l disk0 mfid0
2. Install the Protected MBR (pmbr) and gptboot loader 
Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0
echo 'vfs.root.mountfrom="ufs:/dev/mfid0p2"' >> /boot/loader.conf
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-03-12 03:54:09 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Reclassify and assign.
Comment 2 Andriy Gapon freebsd_committer freebsd_triage 2011-03-12 07:47:43 UTC
gpart(8)
/bootme
Does this help?

-- 
Andriy Gapon
Comment 3 Alexander Best freebsd_committer freebsd_triage 2011-03-12 08:22:30 UTC
On Fri Mar 11 11, Andrey Vladimirov wrote:
> 
> >Number:         155484
> >Category:       kern
> >Synopsis:       GPT + UFS boot
> >Confidential:   no
> >Severity:       serious
> >Priority:       medium
> >Responsible:    freebsd-bugs
> >State:          open
> >Quarter:        
> >Keywords:       
> >Date-Required:
> >Class:          sw-bug
> >Submitter-Id:   current-users
> >Arrival-Date:   Fri Mar 11 22:50:10 UTC 2011
> >Closed-Date:
> >Last-Modified:
> >Originator:     Andrey Vladimirov
> >Release:        Freebsd 8.2 RELEASE
> >Organization:
> >Environment:
> FreeBSD  8.2-STABLE FreeBSD 8.2-STABLE #0: Wed Mar  9 20:11:11 UTC 2011     andrey@:/usr/obj/usr/src/sys/x3650m2  amd64
> >Description:
> I'm trying to setup a system with a large RAID array (total ~4TB)
> I do next step:
> 1.Create the boot, swap and UFS partitions:
>  Fixit# gpart add -s 64K -t freebsd-boot mfid0
>  Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
>  Fixit# gpart add -t freebsd-ufs -l disk0 mfid0
> 2. Install the Protected MBR (pmbr) and gptboot loader 
> Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0
> Then install FreeBSD and add this:
> echo 'vfs.root.mountfrom="ufs:/dev/mfid0p2"' >> /boot/loader.conf

isn't this line pointing to your swap partition?

try echo 'vfs.root.mountfrom="ufs:/dev/mfid0p3"' >> /boot/loader.conf

...also shouldn't this be:

gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptboot -i 1 mfid0 ?

also i'm not sure -b and -p can be used together in one command. at least the
gpart(8) manual uses two commands for it.

> After rebooting (system not booting) i see message:
> is unable to find loader at /boot/loader or can it load /boot/kernel/kernel
> 
> I load from DVD and go to Fixit
> Copying /boot/loader to /loader allows me to enter /loader at the "boot:" prompt and the loader will load, however, its unable to load the kernel.
> 
> If I do an "ls" at the loader prompt I can see boot listed as a directory (with a "d" before it)
> Trying to do "ls boot" inexplicably it says "boot: not a directory"
> 
> 
> 
> 
> 
> >How-To-Repeat:
> do next step:
> 1.Create the boot, swap and UFS partitions:
>  Fixit# gpart add -s 64K -t freebsd-boot mfid0
>  Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
>  Fixit# gpart add -t freebsd-ufs -l disk0 mfid0
> 2. Install the Protected MBR (pmbr) and gptboot loader 
> Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0
> echo 'vfs.root.mountfrom="ufs:/dev/mfid0p2"' >> /boot/loader.conf
> 
> >Fix:
> If do next step:
>  Fixit# gpart add -s 64K -t freebsd-boot mfid0
>  Fixit# gpart add -s 3800G -t freebsd-ufs -l disk0 mfid0
>  Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
> or
>  Fixit# gpart add -s 64K -t freebsd-boot mfid0
> next partition must be root(/) 
>  Fixit# gpart add -s 3G -t freebsd-ufs -l disk0 mfid0  
>  Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
> 
> No problem with boot on GPT.
> 
> >Release-Note:
> >Audit-Trail:
> >Unformatted:

-- 
a13x
Comment 4 Andrey V. Elsukov 2011-03-12 08:36:10 UTC
On 12.03.2011 01:42, Andrey Vladimirov wrote:
> 2. Install the Protected MBR (pmbr) and gptboot loader 
> Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0

Did you try to use gptboot instead gptzfsboot?

-- 
WBR, Andrey V. Elsukov
Comment 5 Andrey Vladimirov 2011-03-12 13:58:35 UTC
Sorry it is misprint.

I use this:
Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptboot -i 1 mfid0


12 ÍÁÒÔÁ 2011 Ç. 10:36 ÐÏÌØÚÏ×ÁÔÅÌØ Andrey V. Elsukov
<bu7cher@yandex.ru>ÎÁÐÉÓÁÌ:

> On 12.03.2011 01:42, Andrey Vladimirov wrote:
> > 2. Install the Protected MBR (pmbr) and gptboot loader
> > Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1
> ad0
>
> Did you try to use gptboot instead gptzfsboot?
>
> --
> WBR, Andrey V. Elsukov
>




-- 
Best regards,
Andrey Vladimirov
Comment 6 Andrey Vladimirov 2011-03-12 14:09:53 UTC
2011/3/12 Alexander Best <arundel@freebsd.org>

> On Fri Mar 11 11, Andrey Vladimirov wrote:
> >
> > >Number:         155484
> > >Category:       kern
> > >Synopsis:       GPT + UFS boot
> > >Confidential:   no
> > >Severity:       serious
> > >Priority:       medium
> > >Responsible:    freebsd-bugs
> > >State:          open
> > >Quarter:
> > >Keywords:
> > >Date-Required:
> > >Class:          sw-bug
> > >Submitter-Id:   current-users
> > >Arrival-Date:   Fri Mar 11 22:50:10 UTC 2011
> > >Closed-Date:
> > >Last-Modified:
> > >Originator:     Andrey Vladimirov
> > >Release:        Freebsd 8.2 RELEASE
> > >Organization:
> > >Environment:
> > FreeBSD  8.2-STABLE FreeBSD 8.2-STABLE #0: Wed Mar  9 20:11:11 UTC 2011
>   andrey@:/usr/obj/usr/src/sys/x3650m2  amd64
> > >Description:
> > I'm trying to setup a system with a large RAID array (total ~4TB)
> > I do next step:
> > 1.Create the boot, swap and UFS partitions:
> >  Fixit# gpart add -s 64K -t freebsd-boot mfid0
> >  Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
> >  Fixit# gpart add -t freebsd-ufs -l disk0 mfid0
> > 2. Install the Protected MBR (pmbr) and gptboot loader
> > Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1
> ad0
> > Then install FreeBSD and add this:
> > echo 'vfs.root.mountfrom="ufs:/dev/mfid0p2"' >> /boot/loader.conf
>
> isn't this line pointing to your swap partition?
>

> try echo 'vfs.root.mountfrom="ufs:/dev/mfid0p3"' >> /boot/loader.conf
>
> ...also shouldn't this be:
>
> gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptboot -i 1 mfid0 ?
>
> also i'm not sure -b and -p can be used together in one command. at least
> the
> gpart(8) manual uses two commands for it.
>

Yes i this command(sorry it is my misprint):
gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptboot -i 1 mfid0

About this "vfs.root.mountfrom=" - it does not matter, because if create
swap partition after  (freebsd-boot) loader and kernel not booting.
If I create root partition after freebsd-boot - all work!!!!


> > After rebooting (system not booting) i see message:
> > is unable to find loader at /boot/loader or can it load
> /boot/kernel/kernel
> >
> > I load from DVD and go to Fixit
> > Copying /boot/loader to /loader allows me to enter /loader at the "boot:"
> prompt and the loader will load, however, its unable to load the kernel.
> >
> > If I do an "ls" at the loader prompt I can see boot listed as a directory
> (with a "d" before it)
> > Trying to do "ls boot" inexplicably it says "boot: not a directory"
> >
> >
> >
> >
> >
> > >How-To-Repeat:
> > do next step:
> > 1.Create the boot, swap and UFS partitions:
> >  Fixit# gpart add -s 64K -t freebsd-boot mfid0
> >  Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
> >  Fixit# gpart add -t freebsd-ufs -l disk0 mfid0
> > 2. Install the Protected MBR (pmbr) and gptboot loader
> > Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1
> ad0
> > echo 'vfs.root.mountfrom="ufs:/dev/mfid0p2"' >> /boot/loader.conf
> >
> > >Fix:
> > If do next step:
> >  Fixit# gpart add -s 64K -t freebsd-boot mfid0
> >  Fixit# gpart add -s 3800G -t freebsd-ufs -l disk0 mfid0
> >  Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
> > or
> >  Fixit# gpart add -s 64K -t freebsd-boot mfid0
> > next partition must be root(/)
> >  Fixit# gpart add -s 3G -t freebsd-ufs -l disk0 mfid0
> >  Fixit# gpart add -s 8G -t freebsd-swap -l swap0 mfid0
> >
> > No problem with boot on GPT.
> >
> > >Release-Note:
> > >Audit-Trail:
> > >Unformatted:
>
> --
> a13x
>



-- 
Best regards,
Andrey Vladimirov
Comment 7 Andriy Gapon freebsd_committer freebsd_triage 2011-03-16 13:42:42 UTC
Let me ask again - did my suggestion help?

-- 
Andriy Gapon
Comment 8 Andrey Vladimirov 2011-03-16 22:52:58 UTC
>
>
> Let me ask again - did my suggestion help?
>
> --
> Andriy Gapon
>

No. (if swap partition after freebsd-boot)

-- 
Best regards,
Andrey Vladimirov
Comment 9 Andriy Gapon freebsd_committer freebsd_triage 2011-05-26 13:28:48 UTC
I can not reproduce your problem.
This is what I did (to provide a full and clean picture unlike your original example):

$ gpart create -s gpt /dev/zvol/pond/zvol2
zvol/pond/zvol2 created
$ gpart add -s 64K -t freebsd-boot zvol/pond/zvol2
zvol/pond/zvol2p1 added
$ gpart add -s 128m -t freebsd-swap -l swap0 zvol/pond/zvol2
zvol/pond/zvol2p2 added
$ gpart add -t freebsd-ufs -l disk0 zvol/pond/zvol2
zvol/pond/zvol2p3 added
$ gpart bootcode -b /boot/pmbr -p /boot/gptboot -i1 zvol/pond/zvol2
bootcode written to zvol/pond/zvol2
$ newfs /dev/zvol/pond/zvol2p3
/dev/zvol/pond/zvol2p3: 895.9MB (1834812 sectors) block size 16384, fragment size 2048
        using 5 cylinder groups of 183.72MB, 11758 blks, 23552 inodes.
super-block backups (for fsck -b #) at:
 160, 376416, 752672, 1128928, 1505184
$ mount /dev/zvol/pond/zvol2p3 /mnt
$ cp -a /boot /mnt/boot
$ umount /mnt
$ gpart show zvol/pond/zvol2
=>     34  2097085  zvol/pond/zvol2  GPT  (1.0G)
       34      128                1  freebsd-boot  (64k)
      162   262144                2  freebsd-swap  (128M)
   262306  1834813                3  freebsd-ufs  (895M)
$ name -srm
FreeBSD 9.0-CURRENT amd64

After this I can boot to kernel from this zvol in qemu without any problems.
So either there is some pilot error, or some problems with your boot blocks or
with 8GB size of the swap partition (but somehow I doubt that this is the case).

Do you have a chance to play with your configuration more?
If so, can you try smaller swap partition sizes (starting with 128M for example)?
Can you try to use boot blocks (gptboot) from a recent head/CURRENT snapshot?

-- 
Andriy Gapon
Comment 10 Andriy Gapon freebsd_committer freebsd_triage 2011-06-01 17:57:40 UTC
I have tried with 8GB swap partition size and still couldn't reproduce the
problem.  I am going to close this PR.

Layout of my test setup:
$ gpart show zvol/pond/zvol5
=>      34  20971453  zvol/pond/zvol5  GPT  (10G)
        34       128                1  freebsd-boot  (64k)
       162  16777216                2  freebsd-swap  (8.0G)
  16777378   4194109                3  freebsd-ufs  (2G)

-- 
Andriy Gapon
Comment 11 Andriy Gapon freebsd_committer freebsd_triage 2011-06-02 15:11:44 UTC
State Changed
From-To: open->closed

Works for me.