# FreeBSD 9 install -- Bootloader doesn't work?



## Carpetsmoker (Aug 1, 2012)

I installed FreeBSD 9 yesterday.

For some reason the graphical partition editor didn't work,  I tried it several times and kept getting strange errors. I longed for sysinstall 
In the end I reverted to the manual shell method to create my disk layout manually, and after this the installer worked fine.

However, when I boot my PC I get the FreeBSD boot loader and can select F1 for FreeBSD (as expected), but the bootloader only prints a "#" to the screen and does nothing.

The system works fine otherwise, I now boot the system from the installation CD-ROM, go to the boot loader prompt, set currdev to disk0s1a, load new kernel, after which FreeBSD boots and works fine (Typing this message from it)... But this is obviously far from ideal ...


Has the FreeBSD 9 procedure somehow changed? I manually created the disk layout with:
1) Created the MBR with fdisk.
2) Made a bunch of disklabels.
3) newfs.
4) boot0cfg -B to set the FreeBSD boot loader.

This has never failed me before ...

Some details about my system:


```
[b][~]# uname -a[/b]
FreeBSD martin-fbsd 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0:
Tue Jun 12 02:52:29 UTC 2012
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
```


```
[b][~]# mount[/b]
/dev/ada1s1a on / (ufs, local, soft-updates)
devfs on /dev (devfs, local, multilabel)
/dev/ada1s1d on /var (ufs, local, soft-updates)
/dev/ada1s1e on /usr (ufs, local, soft-updates)
/dev/ada1s1f on /home (ufs, local, soft-updates)
```


```
[b][~]% dmesg|grep ^ada[/b]
ada0 at ata3 bus 0 scbus3 target 0 lun 0
ada0: <STM3250318AS CC38> ATA-8 SATA 2.x device
ada0: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
ada0: 238475MB (488397168 512 byte sectors: 16H 63S/T 16383C)
ada0: Previously was known as ad6
ada1 at ata5 bus 0 scbus5 target 0 lun 0
ada1: <OCZ VERTEX-TURBO 1.4> ATA-8 SATA 2.x device
ada1: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 512bytes)
ada1: 30533MB (62533296 512 byte sectors: 16H 63S/T 16383C)
ada1: Previously was known as ad10
```
ada1 is the FreeBSD drive. ada0 is a Windows drive, it was disconnected during install and attempts to fix it afterwards.


```
[b][~]# fdisk /dev/ada0[/b]
******* Working on device /dev/ada0 *******
parameters extracted from in-core disklabel are:
cylinders=484521 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=484521 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
    start 2048, size 488392704 (238473 Meg), flag 0
        beg: cyl 0/ head 32/ sector 33;
        end: cyl 1023/ head 254/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
```


```
[b][~]# fdisk /dev/ada1[/b]
******* Working on device /dev/ada1 *******
parameters extracted from in-core disklabel are:
cylinders=62037 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=62037 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 62533233 (30533 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 596/ head 15/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
```


```
[b][~]# bsdlabel /dev/ada1s1[/b]
# /dev/ada1s1:
8 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:    2097152         16    4.2BSD        0     0     0
  c:   60817365          0    unused        0     0     # "raw" part, don't edit
  d:   12582912    2097168    4.2BSD        0     0     0
  e:   16777216   14680080    4.2BSD        0     0     0
  f:   29360069   31457296    4.2BSD        0     0     0
```


```
[b][~]# boot0cfg /dev/ada1[/b]
```
No error/output, meaning the loader is installed.


```
[b][~]# tunefs -p /dev/ada1s1a[/b]
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       disabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         enabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)                                 root
```

Can't imagine this has any influence ... It's just UFS2 with softupdates ...


----------



## kpa (Aug 1, 2012)

You're missing the 2nd stage bootloader on ada1s1.
Use gpart(8), it makes everything so much simpler.

Starting with a completely clean disk:
`# gpart create -s MBR ada1`

`# gpart add -t freebsd ada1`

`# gpart create -s BSD ada1s1`

This is the only part where the default options are not suitable, the first partition of ada1s1 needs to start from offset 16, hence the -b 16 option.
`# gpart add -b 16 -s 1G -t freebsd-ufs ada1s1`
The -b option no longer needed:
`# gpart add -s 8G -t freebsd-swap adas1`
`# gpart add -s 2G -t freebsd-ufs adas1`
...
These commands would create 1GB partition ada1s1a for root fs, a 8GB swap partition ada1s1b and 2GB partition ada1s1d for another ufs filesystem (maybe /var). Create as many partitions you need using the above as template. Partition naming will be the same as if the partitions were created with bsdlabel(8).

This installs the second stage boot loader:
`# gpart bootcode -b /boot/boot ada1s1`

This will set ada1s1 as the active slice:
`# gpart set -a active -i 1 ada1`

Then you can use boot0cfg(8) on the disk:
`# boot0cfg  -B /dev/ada1`

Then you can proceed to newfs(8) the newly created partitions.


----------

