Bug 245348

Summary: [loader] does not detect the memstick device it was loaded from
Product: Base System Reporter: Bertrand Petit <bsdpr>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me CC: bsdpr, martin.cyril0213, maurizio1018, proliant, stable
Priority: --- Keywords: regression
Version: 12.1-RELEASE   
Hardware: Any   
OS: Any   

Description Bertrand Petit 2020-04-04 16:44:46 UTC
The loader provided on FreeBSD-12.1-RELEASE-amd64-mini-memstick.img loads and boots an unexpected kernel when the host has a bootable zpool on another disk. I expected that booting from the memstick would bring me the installer but I got the main OS instead. This is extremely inconvenient since I use these USB sticks as a troubleshooting or disaster recovery tool.
The currdev and loaddev variables are equal and point to the HDD pool but not to the USB thumb drive from which the loader was read.

OK lsdev                                                                        
disk devices:                                                                   
    disk0:   BIOS drive C (78165360 X 512):                                     
      disk0p1: FreeBSD boot                                                     
      disk0p2: FreeBSD ZFS                                                      
    disk1:   BIOS drive D (7814037168 X 512):                                   
      disk1p1: FreeBSD boot                                                     
      disk1p2: FreeBSD swap                                                     
      disk1p3: FreeBSD ZFS                                                      
    disk2:   BIOS drive E (7814037168 X 512):                                   
      disk2p1: FreeBSD boot                                                     
      disk2p2: FreeBSD swap                                                     
      disk2p3: FreeBSD ZFS                                                      
zfs devices:                                                                    
    zfs:asroot                  

The thumb drive is not listed, asroot is pulled from disk0.

11.3 memstick correctly load and boot the kernel from the thumb drive.

The host is an HP ML10 v2 server with firmware revision J10 in BIOS mode.
Comment 1 Bertrand Petit 2020-04-21 10:01:20 UTC
If it may help, the affected host boot in BIOS mode.
Comment 2 cyril 2020-04-24 01:54:37 UTC
Hello there Bertrand.
Did you take into acount this particularity of v12 loader.conf:


Lualoader's kernel autodetection, disabled on install media.
As documented in loader.conf(5), kernels_autodetect="YES" will cause the Lua scripts to effectively scan /boot for directories with a "kernel" file inside, to be listed in the loader menu.

https://svnweb.freebsd.org/base?view=revision&revision=339308

You can also check Section 9 'bootloader changes' at this page: 
https://www.freebsd.org/releases/12.0R/relnotes.html#boot

Hope it can help
Comment 3 Bertrand Petit 2020-04-25 17:16:00 UTC
(In reply to cyril from comment #2)
Thank you Cyril for your comment, setting kernels_autodetect to YES in loader.conf has no positive effect. I think the trouble is elsewhere as the device from which is loader is loaded is not visible from the loader prompt. Please compare the list of devices shown in the first message to the one bellow which I obtained from an 11.3-RELEASE memstick.

OK lsdev                                                                        
disk devices:                                                                   
    disk0:   BIOS drive C (1986558 X 512):                                      
      disk0s1: Unknown                                                          
      disk0s2: FreeBSD                                                          
        disk0s2a: FreeBSD UFS                                                   
    disk1:   BIOS drive D (78165360 X 512):                                     
      disk1p1: FreeBSD boot                                                     
      disk1p2: FreeBSD ZFS                                                      
    disk2:   BIOS drive E (7814037168 X 512):                                   
      disk2p1: FreeBSD boot                                                     
      disk2p2: FreeBSD swap                                                     
      disk2p3: FreeBSD ZFS                                                      
    disk3:   BIOS drive F (7814037168 X 512):                                   
      disk3p1: FreeBSD boot                                                     
      disk3p2: FreeBSD swap                                                     
      disk3p3: FreeBSD ZFS                                                      
zfs devices:                                                                    
    zfs:asroot                                                                  
    zfs:cask

Here we have four devices which is correct, the memstick is disk0. With a 12.1-RELEASE memstick only three devices are listed and none of them is the memstick. There looks to be a regression in devices detection.
Comment 4 cyril 2020-04-25 18:59:14 UTC
What are the results given by the following commands:
 camcontrol
and:
 pciconf -l -v
?

Also can you do a 'dmesg | grep, usb' and print the output?
And also, have you got the line 'vfs.usermount=1' in your /etc/sysctl.conf file?
Comment 5 Bertrand Petit 2020-04-25 20:16:10 UTC
(In reply to cyril from comment #4)

Here are the requested probes.

# camcontrol devlist
<INTEL SSDSA2M040G2GC 2CV102M3>    at scbus2 target 0 lun 0 (pass0,ada0)
<WDC WD4005FZBX-00K5WB0 01.01A01>  at scbus4 target 0 lun 0 (pass1,ada1)
<TOSHIBA HDWQ140 FJ1M>             at scbus5 target 0 lun 0 (pass2,ada2)
<HL-DT-ST DVDRAM GH24NSD1 LG00>    at scbus7 target 0 lun 0 (pass3,cd0)
<AHCI SGPIO Enclosure 2.00 0001>   at scbus8 target 0 lun 0 (pass4,ses0)
<Kingston DataTraveler 2.0 1.00>   at scbus10 target 0 lun 0 (da0,pass5)

The 12.1-RELEASE memstick is shown as da0.


# pciconf -lv
hostb0@pci0:0:0:0:	class=0x060000 card=0x00000000 chip=0x0c008086 rev=0x06 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '4th Gen Core Processor DRAM Controller'
    class      = bridge
    subclass   = HOST-PCI
pcib1@pci0:0:1:0:	class=0x060400 card=0x330b103c chip=0x0c018086 rev=0x06 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller'
    class      = bridge
    subclass   = PCI-PCI
pcib2@pci0:0:1:1:	class=0x060400 card=0x330b103c chip=0x0c058086 rev=0x06 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Xeon E3-1200 v3/4th Gen Core Processor PCI Express x8 Controller'
    class      = bridge
    subclass   = PCI-PCI
xhci0@pci0:0:20:0:	class=0x0c0330 card=0x330d103c chip=0x8c318086 rev=0x04 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family USB xHCI'
    class      = serial bus
    subclass   = USB
ehci0@pci0:0:26:0:	class=0x0c0320 card=0x330d103c chip=0x8c2d8086 rev=0x04 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family USB EHCI'
    class      = serial bus
    subclass   = USB
pcib3@pci0:0:28:0:	class=0x060400 card=0x330d103c chip=0x8c108086 rev=0xd4 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib4@pci0:0:28:4:	class=0x060400 card=0x330d103c chip=0x8c188086 rev=0xd4 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib5@pci0:0:28:5:	class=0x060400 card=0x330d103c chip=0x8c1a8086 rev=0xd4 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib6@pci0:0:28:6:	class=0x060400 card=0x330d103c chip=0x8c1c8086 rev=0xd4 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib7@pci0:0:28:7:	class=0x060400 card=0x330d103c chip=0x8c1e8086 rev=0xd4 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
ehci1@pci0:0:29:0:	class=0x0c0320 card=0x330d103c chip=0x8c268086 rev=0x04 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family USB EHCI'
    class      = serial bus
    subclass   = USB
isab0@pci0:0:31:0:	class=0x060100 card=0x00000000 chip=0x8c528086 rev=0x04 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'C222 Series Chipset Family Server Essential SKU LPC Controller'
    class      = bridge
    subclass   = PCI-ISA
ahci1@pci0:0:31:2:	class=0x010601 card=0x330d103c chip=0x8c028086 rev=0x04 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]'
    class      = mass storage
    subclass   = SATA
xhci1@pci0:10:0:0:	class=0x0c0330 card=0x34831106 chip=0x34831106 rev=0x01 hdr=0x00
    vendor     = 'VIA Technologies, Inc.'
    device     = 'VL805 USB 3.0 Host Controller'
    class      = serial bus
    subclass   = USB
bge0@pci0:3:0:0:	class=0x020000 card=0x2133103c chip=0x165f14e4 rev=0x00 hdr=0x00
    vendor     = 'Broadcom Inc. and subsidiaries'
    device     = 'NetXtreme BCM5720 2-port Gigabit Ethernet PCIe'
    class      = network
    subclass   = ethernet
bge1@pci0:3:0:1:	class=0x020000 card=0x2133103c chip=0x165f14e4 rev=0x00 hdr=0x00
    vendor     = 'Broadcom Inc. and subsidiaries'
    device     = 'NetXtreme BCM5720 2-port Gigabit Ethernet PCIe'
    class      = network
    subclass   = ethernet
ahci0@pci0:13:0:0:	class=0x010601 card=0x10601b21 chip=0x06121b21 rev=0x02 hdr=0x00
    vendor     = 'ASMedia Technology Inc.'
    device     = 'ASM1062 Serial ATA Controller'
    class      = mass storage
    subclass   = SATA
none0@pci0:1:0:0:	class=0x088000 card=0x3381103c chip=0x3306103c rev=0x05 hdr=0x00
    vendor     = 'Hewlett-Packard Company'
    device     = 'Integrated Lights-Out Standard Slave Instrumentation & System Support'
    class      = base peripheral
vgapci0@pci0:1:0:1:	class=0x030000 card=0x3381103c chip=0x0533102b rev=0x00 hdr=0x00
    vendor     = 'Matrox Electronics Systems Ltd.'
    device     = 'MGA G200EH'
    class      = display
    subclass   = VGA
none1@pci0:1:0:2:	class=0x088000 card=0x3381103c chip=0x3307103c rev=0x05 hdr=0x00
    vendor     = 'Hewlett-Packard Company'
    device     = 'Integrated Lights-Out Standard Management Processor Support and Messaging'
    class      = base peripheral
uhci0@pci0:1:0:4:	class=0x0c0300 card=0x3381103c chip=0x3300103c rev=0x02 hdr=0x00
    vendor     = 'Hewlett-Packard Company'
    device     = 'Integrated Lights-Out Standard Virtual USB Controller'
    class      = serial bus
    subclass   = USB

The memstick is seen through ehci0.


$ dmesg | grep usb
usbus0 on xhci0
usbus0: 5.0Gbps Super Speed USB v3.0
usbus1: EHCI version 1.0
usbus1 on ehci0
usbus1: 480Mbps High Speed USB v2.0
usbus2 on xhci1
usbus2: 5.0Gbps Super Speed USB v3.0
usbus3 on uhci0
usbus3: 12Mbps Full Speed USB v1.0
usbus4: EHCI version 1.0
usbus4 on ehci1
usbus4: 480Mbps High Speed USB v2.0
ugen4.1: <Intel EHCI root HUB> at usbus4
ugen3.1: <HP UHCI root HUB> at usbus3
uhub0: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus4
uhub1: <HP UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus3
ugen2.1: <0x1106 XHCI root HUB> at usbus2
ugen1.1: <Intel EHCI root HUB> at usbus1
uhub2: <0x1106 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus2
uhub3: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
ugen0.1: <0x8086 XHCI root HUB> at usbus0
Root mount waiting for: usbus0 usbus1 usbus2 CAM usbus3 usbus4
uhub4: <0x8086 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0
ugen2.2: <vendor 0x2109 USB2.0 Hub> at usbus2
uhub5: <vendor 0x2109 USB2.0 Hub, class 9/0, rev 2.10/4.20, addr 1> on usbus2
ugen3.2: <HP Virtual Keyboard> at usbus3
ukbd0: <Virtual Keyboard > on usbus3
Root mount waiting for: usbus0 usbus1 usbus2 usbus4
ugen0.2: <JetFlash Mass Storage Device> at usbus0
umass0: <JetFlash Mass Storage Device, class 0/0, rev 2.00/1.41, addr 1> on usbus0
ugen1.2: <vendor 0x8087 product 0x8008> at usbus1
uhub6: <vendor 0x8087 product 0x8008, class 9/0, rev 2.00/0.04, addr 2> on usbus1
ugen4.2: <vendor 0x8087 product 0x8000> at usbus4
uhub7: <vendor 0x8087 product 0x8000, class 9/0, rev 2.00/0.04, addr 2> on usbus4
ugen2.3: <VIA Labs, Inc. USB2.0 Hub> at usbus2
uhub8: <VIA Labs, Inc. USB2.0 Hub, class 9/0, rev 2.10/90.90, addr 2> on usbus2
Root mount waiting for: usbus2
ugen2.4: <C-Media Electronics Inc. USB Audio Device> at usbus2
uaudio0: <C-Media Electronics Inc. USB Audio Device, class 0/0, rev 1.10/1.00, addr 3> on usbus2
Root mount waiting for: usbus2
ugen2.5: <VIA Labs, Inc. USB3.0 Hub> at usbus2
uhub9: <VIA Labs, Inc. USB3.0 Hub, class 9/0, rev 3.00/90.91, addr 4> on usbus2
Root mount waiting for: usbus2
ums0: <Virtual Mouse> on usbus3
ugen0.2: <JetFlash Mass Storage Device> at usbus0 (disconnected)
ugen3.2: <HP Virtual Keyboard> at usbus3 (disconnected)
ugen0.2: <Kingston DataTraveler 2.0> at usbus0
umass0: <Kingston DataTraveler 2.0, class 0/0, rev 2.00/2.00, addr 2> on usbus0


vfs.usermount is left to its default value, ie. 0. (How could this affect the loader behavior?)
Comment 6 Bertrand Petit 2020-05-21 18:12:03 UTC
How could I help to solve this issue?