Re: gptboot rewrite, bootonce, etc.

From: Boris Samorodov <bsam_at_ipt.ru>
Date: Sun, 19 Sep 2010 21:10:52 +0400
Hi!

On Sat, 18 Sep 2010 01:45:42 +0200 Pawel Jakub Dawidek wrote:

> My company was in need for functionality similar to nextboot(8), but on
> boot loader level, so we can have two partitions we boot from where one
> is known to be good and the other is used for upgrades. We upgrade by
> dd(1)ing entire partition image onto unused partition, we mark it as
> try-to-boot-from-it-but-only-once, reboot and if we fail to boot from
> the new partition, we fall back to the old, good partition. If we
> succeed on the other hand, we mark the new partition as our boot
> partition and mark the other one as unused.

> Well, how hard can it be?

> After around two weeks of work, I ended up rewriting gptboot in large
> parts, reorganizing a lot of code, improving and extending gpart a bit
> and implementing desire functionality.

> Here is the patch for review and test:

> 	http://people.freebsd.org/~pjd/patches/gptboot.patch

Great! Since I need to have both i386 and amd64 at my box
here are my test results:
-----
[~]bsam_at_alya% uname -a
FreeBSD alya 9.0-CURRENT FreeBSD 9.0-CURRENT #1 r212758M: Sat Sep 18 16:13:38 MSD 2010
bsam_at_alya:/space/FreeBSD/base/head/obj/space/FreeBSD/base/head/src/sys/ALYA amd64

[~]bsam_at_alya% glabel status
                                      Name  Status  Components
gptid/c6053c9b-abcc-11df-b740-00251124aff4     N/A  ad4p1
                             label/9-amd64     N/A  ad4p2
                                label/swap     N/A  ad4p3
                               label/space     N/A  ad4p4
                              label/9-i386     N/A  ad4p5
[~]bsam_at_alya% mount
/dev/label/9-amd64 on / (ufs, local)
devfs on /dev (devfs, local, multilabel)
/dev/label/space on /space (ufs, local)
/dev/md0 on /tmp (ufs, local, nosuid, soft-updates)
procfs on /proc (procfs, local)
linprocfs on /compat/linux/proc (linprocfs, local)
linsysfs on /compat/linux/sys (linsysfs, local)
fdescfs on /dev/fd (fdescfs)

[~]bsam_at_alya% gpart show
=>       34  490234685  ad4  GPT  (234G)
         34        128    1  freebsd-boot  (64K)
        162   41943040    2  freebsd-ufs  (20G)
   41943202    8388608    3  freebsd-swap  (4.0G)
   50331810  209715200    4  freebsd-ufs  (100G)
  260047010   41943040    5  freebsd-ufs  (20G)
  301990050  188244669       - free -  (90G)

[~]bsam_at_alya% gpart set -a bootme -i 2 ad4
bootme set on ad4p2
[~]bsam_at_alya% gpart set -a bootonce -i 5 ad4
bootonce set on ad4p5
[~]bsam_at_alya% gpart show
=>       34  490234685  ad4  GPT  (234G)
         34        128    1  freebsd-boot  (64K)
        162   41943040    2  freebsd-ufs  [bootme]  (20G)
   41943202    8388608    3  freebsd-swap  (4.0G)
   50331810  209715200    4  freebsd-ufs  (100G)
  260047010   41943040    5  freebsd-ufs  [bootonce,bootme]  (20G)
  301990050  188244669       - free -  (90G)
-----

Install i386 kernel/world to ad4p5, successful reboot, get i386
system. Next reboot (get amd64 system back):
-----
[~]bsam_at_alya% gpart show
=>       34  490234685  ad4  GPT  (234G)
         34        128    1  freebsd-boot  (64K)
        162   41943040    2  freebsd-ufs  [bootme]  (20G)
   41943202    8388608    3  freebsd-swap  (4.0G)
   50331810  209715200    4  freebsd-ufs  (100G)
  260047010   41943040    5  freebsd-ufs  (20G)
  301990050  188244669       - free -  (90G)
-----

All seems to work fine.

> Any comments or suggestions?

Only one for now. With current default syslog configuration
logging to local0.warning and local0.info goes nowhere.
It will be good if those messages have traces at the
default system.


Thank you! That's really great.

-- 
WBR, Boris Samorodov (bsam)
Research Engineer, http://www.ipt.ru Telephone & Internet SP
FreeBSD Committer, http://www.FreeBSD.org The Power To Serve
Received on Sun Sep 19 2010 - 15:34:26 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:07 UTC