# How to tell gptboot which slice to boot from?



## vanessa (Jul 13, 2013)

Hello, forum!

After the second day of reading and googling I finally gave up on this and must ask for assistance. 

I have a GUID partition table on a SATA disk and a BIOS machine with this partitioning:

`# gpart show`


```
ada0	GPT	(40G)	
1		freebsd-boot	(64k)
2		freebsd-ufs	(19G)
3		freebsd-ufs	(19G)
4		freebsd-swap	(2G)
...
```

The two UFS slices are intended for placing root filesystems onto. What I am trying to do is to tell the bootstrapping code which slice to boot from.

I install the boot code by:
`# gpart bootcode -p /boot/gptboot -i 1 ada0`

The problem is that the system always boots from the first freebsd-ufs slice (with a loader and kernel on it). Both freebsd-ufs slices do have a loader, a kernel and a complete FreeBSD installation.

How could I tell gptboot to go to the second (or another) slice when handing off to the loader?

Thanks in advance for each and every hint or solution!


----------



## wblock@ (Jul 13, 2013)

Good news!  There is a very new gptboot(8) man page in head and 9-STABLE. If you are not using either 9-STABLE or -CURRENT, the file is here: http://svnweb.freebsd.org/base/head/sys/boot/i386/gptboot/gptboot.8?revision=252586&view=markup. Click the (download) link to download the file, then use man(1) with a full path to the file: `man /tmp/gptboot.8`

Now, back to the point: see that man page about the bootonce and bootme attributes, which should do exactly what you want.


----------



## vanessa (Jul 13, 2013)

This is really helpful, as I read about those attributes before posting, but the gpart man page don't tell us how to set them. 

The gpart man page leaves however one open question: how could one clear the attributes? The bootme flag would do exactly what I need, but there should be only one slice set to bootme. If both slices are set to bootme, then the first one in order would be always booted.


----------



## cpm@ (Jul 13, 2013)

See the gpart(8)() man page. Also, take a look at: http://lists.freebsd.org/pipermail/freebsd-arch/2010-September/010606.html. 

Hope that helps


----------



## wblock@ (Jul 13, 2013)

unset is used to clear an attribute.


----------



## vanessa (Jul 13, 2013)

Yes, indeed! For all interested:

`gpart unset -a bootme -i <n> <device>`
`gpart unset -a bootonce -i <n> <device>`

Actually, I am an idiot - this info is written in the gpart man page, but somehow I managed to overlook it.


----------



## wblock@ (Jul 13, 2013)

Yes, it is--or was--in gpart(8), but that's really not the right place.  I had added it there earlier, then realized only afterwards that it really ought to be part of gptboot(8), which was on my list of man pages that were missing.  At the same time as adding gptboot(8), I factored most of the redundant information out, and added references to the new man page instead.


----------



## vanessa (Jul 15, 2013)

Warren, the man pages are good, it was my fault not reading them thoroughly. I usually first read the examples at the end, and there were none with 'unset'. 

Thanks again for the help!


----------

