# BSD boot config on changing disk names



## AndySchmid (Aug 19, 2012)

I have installed FreeBSD 9 on a HP Microserver. The system has 4 bays which I'll use for data disk and i have moved an operating system disk into the optical bay from which I am booting. 

The layout of the disk is that the 4 bays are ada0 to ada3 and the optical drive bay is ada4. I can't change this as this is a BIOS assignment. I can chose to boot from the optical drive bay via the BIOS.

So everything boots and works except if I change the configuration of the 4 drive bays, eg take out one disk:

If i take out one disk ada4 becomes ada3 so what happens the BSD Boot Loader still boots but it than can't find the root file system because it assumes it's on /dev/ada4p2 (p1 is boot loader) but it's now on /dev/ada3p2.

Is there a way that I can tell the boot loader to boot from partition 2 instead of the full path so it wouldn't matter what disk naming the boot disk has?

Any other way I could solve this problem?

NOTE: Of course I won't constantly swapping disk but i am worried in an event that one disk fails the last thing I need is dealing with a system that won't boot anymore because the boot partition has move to /dev/ada?

Thanks for any advise!


----------



## vermaden (Aug 19, 2012)

Use *glabel *to mark partitions/disks with labels or GPT names if You use GPT partitions when working with UFS, or use zpool name when using ZFS.

That way You are nit 'hit' with disk name changes.


----------



## SirDice (Aug 19, 2012)

+1 on labels. Pick some consistent names, you might want to move some disks to another machine for example.


```
root@molly:~# mount
/dev/ufs/mollyroot on / (ufs, local)
devfs on /dev (devfs, local, multilabel)
tmpfs on /tmp (tmpfs, local)
procfs on /proc (procfs, local)
fdescfs on /dev/fd (fdescfs)
/dev/ufs/mollyvar on /var (ufs, local, soft-updates)
/dev/ufs/mollyusr on /usr (ufs, local, soft-updates)
/dev/ufs/mollyusrhome on /usr/home (ufs, local, soft-updates)
```


----------



## gkontos (Aug 19, 2012)

Besides the *+2* on labels I would also recommend that you boot these servers from USB sticks.

We have quite a few of those configures as ZFS storage servers, booting from a UFS USB stick and they work flawlessly.


----------



## wblock@ (Aug 19, 2012)

Filesystem labels and GPT labels can be added without repartitioning.  glabel(8) generic labels need one block of metadata at the end of the space, requiring partition re-sizing to use correctly.


----------



## AndySchmid (Aug 20, 2012)

gkontos said:
			
		

> Besides the *+2* on labels I would also recommend that you boot these servers from USB sticks.
> 
> We have quite a few of those configures as ZFS storage servers, booting from a UFS USB stick and they work flawlessly.



So yes I did that before and it worked I was only worried that USB 2.0 speed being 480Mbs is much slower than disk at 3Gbs hence I moved it to a disk. Also considering ZFS writes some cache and log files /boot/zfs/.

Any impact on performance doing this to a USB stick at 480Mbs?

Regarding the labels, that's fine I can do that. Can somebody point me in the right direction what file I need to update to tell FreeBSD to boot from the "label" instead of the physical device?


----------



## jb_fvwm2 (Aug 20, 2012)

/etc/fstab
I usually tunefs -L  or one of the other ways, boot to single-user, check that the labels are in a subdir in /dev (/dev/ufs, /dev/label, or... mount them manually, then write it to fstab and backup the fstab.  Howsoever, I am only usually doing it from experience and not reliably enough to even detail precisely how it is accomplished.


----------



## wblock@ (Aug 20, 2012)

The first link in post #5 shows how to do it with UFS.  ZFS should be very similar.


----------



## gkontos (Aug 20, 2012)

AndySchmid said:
			
		

> So yes I did that before and it worked i was only worried that USB 2.0 speed being 480Mbs is much slower than disk at 3Gbs hence I moved it to a disk. Also considering ZFS writes some cache and log files /boot/zfs/
> 
> Any impact on performance doing this to a USB stick at 480Mbs?



Actually /boot/zfs is being used only if you boot from ZFS. What we do is to boot from a minimal USB UFS installation. We only have the necessary software installed like samba & afp. Then we have 2 ZVOLS, 1 for swap and 1 for /var/log.


----------



## AndySchmid (Aug 21, 2012)

I have been playing a bit more and tried PC-BSD. Decided I don't like it but I found it did some interesting thing when installing.

Apparently PC-BSD does that partition labelling automatically on install and it creates a fstab like this:

```
/dev/label/rootfs0         /
/dev/labal/swap0          none
/dev/label/var0             /var
/dev/label/usr0             /usr
```
I'll try to copy this onto a plain vanilla FreeBSD Server install to make it work the same.

Not sure if this is the right place but maybe this is something to consider for the FreeBSD install process as well so hardware changes on the server won't trip over FreeBSD from booting?


----------

