# Cannot boot via SSD: gptboot: No /boot/loader on 0:ad(0p2)



## posix7 (Feb 22, 2021)

Hello,

I  have pfsense box (SG-5100) that no longer boots off the third party SSD drive. The underlying freebsd release is 11.3-STABLE@r357046.

The hardware is TS256GMTS430S M.2 SSD and is installed as the primary boot device.


```
gptboot: No /boot/loader on 0:ad(0p2)                                        
gptboot: No /boot/kernel/kernel on 0:ad(0p2)
                               
                                                                             
FreeBSD/x86 boot                                                            
Default: 0:ad(0p2)/boot/kernel/kernel                                        
boot:
```

I am still able to see the SSD if I boot off another drive.


```
geom disk list
Geom name: ada0
Providers:
1. Name: ada0
   Mediasize: 256060514304 (238G)
   Sectorsize: 512
   Mode: r0w0e0
   dscr: TS256GMTS430S
   lunid: 57c3548194bde727
   <omitted Line>
   rotationrate: 0
   fwsectors: 63
   fwheads: 16

gpart show
=>       40  500118112  ada0  GPT  (238G)
         40       1024     1  freebsd-boot  (512K)
       1064  490732544     2  freebsd-ufs  (234G)
  490733608    8388608     3  freebsd-swap  (4.0G)
  499122216     995936        - free -  (486M)
```

ada0p1 should boot the system if not mistaken?
The disk responds to queries so Hardware is not bad but rather this might be some corruption?

Appreciate any assistance in trying to get it to boot or confirming if SSD is faulty.


----------



## SirDice (Feb 22, 2021)

posix7 said:


> I have pfsense box (SG-5100) that no longer boots off the third party SSD drive. The underlying freebsd release is 11.3-STABLE@r357046.


pfSense is a derivative and is not supported here. FreeBSD 11.3 is end-of-life and not supported either. 

GhostBSD, pfSense, TrueNAS, and all other FreeBSD Derivatives
Topics about unsupported FreeBSD versions








						Unsupported FreeBSD Releases
					

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms.




					www.freebsd.org
				






posix7 said:


> ada0p1 should boot the system if not mistaken?


It contains gptboot(8), which should then boot /dev/ada0p2. Note the difference in drives, gptboot(8) is looking for ad0p2, while your UFS partition is ada0p2.


----------



## posix7 (Feb 22, 2021)

SirDice said:


> pfSense is a derivative and is not supported here. FreeBSD 11.3 is end-of-life and not supported either.
> 
> GhostBSD, pfSense, TrueNAS, and all other FreeBSD Derivatives
> Topics about unsupported FreeBSD versions
> ...


Thank you for the response, I see the difference. Is there a general reason for this difference to occur - software corruption or hardware related?

I attempted to boot by trying to point it to ada0p2 and others just for the sake of trying:


```
FreeBSD/x86 boot                                                               
Default: 0:ad(0p2)/boot/kernel/kernel                                           
boot: boot /dev/ada0p2/boot/kernelgptboot: No /dev/ada0p2/boot/kernel on 0:ad(0p
2)                                                                             
                                                                                
FreeBSD/x86 boot                                                               
Default: 0:ad(0p2)/dev/a
da0p2/boot/kernel                                       
boot: boot /dev/ada1/boot/kernelgptboot: No /dev/ada1/boot/kernel on 0:ad(0p2) 
                                                                                
FreeBSD/x86 boot                                                               
Default: 0:ad(0p2)/dev/ada1/boot/kernel                                         
boot: boot /dev/ada0/boot/kernelgptboot: No /dev/ada0/boot/kernel on 0:ad(0p2)
```

I understand pfsense is not supported. Did not know that freebsd 11.x is not either but that makes sense. But if you or any else can provide some final pointers would be appreciated.

My next steps are to try and pull the config file from the disk and then determine if I can use the SSD or replace it and then reinstall.


----------



## SirDice (Feb 22, 2021)

posix7 said:


> Is there a general reason for this difference to occur - software corruption or hardware related?


They're two types of disk. ada(4) is typically a SATA disk attached to an ATA (AHCI, IDE) controller, while ad(4) is a disk attached to a SCSI type controller (this includes SAS and USB disks). Unless you've been moving disks from one type of controller to another this 'name' change shouldn't happen. But even if the name changed gptboot(8) would still be smart enough to find it. So either you have an old/broken gptboot(8) on that disk or the freebsd-ufs partition has been flagged with a `failedboot` attribute.


```
gptboot first reads the partition table.  All freebsd-ufs partitions with
     only the bootonce attribute set, indicating a failed boot, are set to
     bootfailed.  gptboot then scans through all of the freebsd-ufs
     partitions.  Boot behavior depends on the combination of bootme and
     bootonce attributes set on those partitions.

     bootonce + bootme          Highest priority: booting is attempted from
                                each of the freebsd-ufs partitions with both
                                of these attributes.  On each partition, the
                                bootme attribute is removed and the boot
                                attempted.

     bootme                     Middle priority: booting is attempted from
                                each of the freebsd-ufs partitions with the
                                bootme attribute.

     If neither bootonce nor bootme attributes are found on any partitions,
     booting is attempted from the first freebsd-ufs partition on the disk.
```


----------



## posix7 (Feb 22, 2021)

Thanks for the response, and reading more of the MAN page it does not really say the reasons that bootfailed attribute can get set. Only that it is an option if the system failed to boot a partition. At least that is my understanding. Based on the section above and reading a little more below I  need to mark the ada0p2 partition with bootonce + bootme attribute.


```
POST-BOOT ACTIONS
     The startup script    /etc/rc.d/gptboot checks the attributes    of freebsd-ufs
     partitions    on all GPT disks.  Partitions with the bootfailed attribute
     generate a    "boot from X failed" system log    message.  Partitions with only
     the bootonce attribute, indicating    a partition that successfully booted,
     generate a    "boot from X succeeded"    system log message.  The bootfailed
     attributes    are cleared from all the partitions.  The bootonce attribute
     is    cleared    from the partition that    successfully booted.  There is nor-
     mally only    one of these.

FILES
     /boot/gptboot  bootcode binary
     /boot.config   parameters for the boot blocks (optional)

EXAMPLES
     gptboot is    installed in a freebsd-boot partition, usually the first par-
     tition on the disk.  A "protective    MBR" (see gpart(8)) is typically in-
     stalled in    combination with gptboot.

     Install gptboot on    the ada0 drive:

       gpart bootcode -b /boot/pmbr    -p /boot/gptboot -i 1 ada0

     gptboot can also be installed without the PMBR:

       gpart bootcode -p /boot/gptboot -i 1    ada0

     Set the bootme attribute for partition 2:

       gpart set -a    bootme -i 2 ada0

     Set the bootonce attribute    for partition 2, automatically also setting
     the bootme    attribute:

       gpart set -a    bootonce -i 2 ada0
```

If understand this output correctly I need to do with under a system running freebsd with the utility or LIVEUSB.

Do I need to rebuild the MBR on freebsd-boot parition as well? Or just set the bootme attribute for partition 2?


----------



## SirDice (Feb 22, 2021)

posix7 said:


> Do I need to rebuild the MBR on freebsd-boot parition as well? Or just set the bootme attribute for partition 2?


I'd try both. You can't really make it worse, it's not booting now in any case (make sure you write the gptboot(8) to the correct partition, you don't want to overwrite the freebsd-ufs partition). Make sure to use a comparable FreeBSD version, a recent 11.4 or 12.2 should be fine. Don't use anything older like 9 or 10.


----------



## posix7 (Feb 22, 2021)

SirDice said:


> I'd try both. You can't really make it worse, it's not booting now in any case (make sure you write the gptboot(8) to the correct partition, you don't want to overwrite the freebsd-ufs partition). Make sure to use a comparable FreeBSD version, a recent 11.4 or 12.2 should be fine. Don't use anything older like 9 or 10.


I just tried rebuilding the MBR and setting the boot me/boot once attribute. No change:


```
/root:  gpart bootcode -b /boot/pmbr    -p /boot/gptboot -i 1 ada0
partcode written to ada0p1
bootcode written to ada0
/root: gpart set -a    bootonce -i 2 ada0
bootonce set on ada0p2
```

result


```
gptboot: No /boot/loader on 0:ad(0p2)                                           
gptboot: No /boot/kernel/kernel on 0:ad(0p2)                                   
                                                                                
FreeBSD/x86 boot                                                               
Default: 0:ad(0p2)/boot/kernel/kernel                                           
boot:
```


----------



## posix7 (Feb 23, 2021)

I ended up reinstalling the OS the partition 2 seemed to get constantly marked 
	
	



```
FAILED BOOT
```
doing fsck -y checks on the disk I saw errors reported. The SSD has gone bad.

Thanks for the responses and pointers really appreciate the help.


----------



## SirDice (Feb 23, 2021)

posix7 said:


> The SSD has gone bad.


That certainly won't help it boot.


----------

