# M.2 SATA randomly detached only on FreeBSD



## Young (Oct 9, 2021)

Hi folks,

This is my last resource, hope that someone can help me. I bought a new Samsung EVO 860 M.2 SATA to my home server. Everything looked good at the first boot on Windows, and tests with CrystalDiskInfo and CrystalDiskMark were all fine. The problems started when I tried to do an FreeBSD fresh install. Installation ran ok, but before the first reboot I quickly saw the "detached" message on the white bold text. System booted up, and I started to install the packages and make the configs. When I ran bonnie++ the "detached" message were show again and the system crashed. Tried to make a new installation, but the message keeps showing up randomly before, during or after the install. Back to Windows with the reparted and formated disk, it worked fine even with file transfers, beenchmarks and so.


```
Oct  8 15:31:17  kernel: ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
Oct  8 15:31:17  kernel: ada1: <Samsung SSD 860 EVO M.2 250GB RVT24B6Q> s/n S413NS0R904336X detached
Oct  8 15:31:17  kernel: (ada1:ahcich1:0:0:0): Periph destroyed
Oct  8 15:31:19  kernel: ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
Oct  8 15:31:19  kernel: ada1: <Samsung SSD 860 EVO M.2 250GB RVT24B6Q> ACS-4 ATA SATA 3.x device
Oct  8 15:31:19  kernel: ada1: Serial Number S413NS0R904336X
Oct  8 15:31:19  kernel: ada1: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 512bytes)
Oct  8 15:31:19  kernel: ada1: Command Queueing enabled
Oct  8 15:31:19  kernel: ada1: 238475MB (488397168 512 byte sectors)
```

I had tried everything I could: UFS/ZFS, new RAM modules, newer FreeBSD  versions (13 and 14) and so. The problem happens only on FreeBSD! Windows and Linux works normally, with full device throughput (550MB/s). My SSD is begining to wear out because of many repartitions/reformats I tried.

Thanks.


----------



## sidetone (Oct 9, 2021)

The SATA controller or SSD technology may be new enough, that an additional setting may be needed for it to work. The mailing list may be more helpful for the specific setting. If they don't have a readily available solution, they would be able to tell you if a bug report is needed.

Thread usb-3-0-issues-with-pine-rock64.82354 is related, but it's about an SSD harddisk using the USB 3.0 xhci port (rather than a SATA 3.x one). It took adding an argument to /boot/loader.conf for the newer USB hardware to function.


----------



## mark_j (Oct 9, 2021)

Are they the only messages you're getting regarding the drive, especially before detach. I reckon there has to be more messages being output.

It is certainly possible FreeBSD has a lower thermal threshold for SSDs and it's detaching. Not likely, though.
I would install smartmontools and see if it gives some clue. Yes, I know it works on Linux/Windows but they're maybe not as "touchy" about drives?
(I have an SSD 870 as my boot disk, it works fine with FreeBSD - though it's not M.2)


----------



## grahamperrin@ (Oct 9, 2021)

Young said:


> … tried everything I could: UFS/ZFS, new RAM modules, newer FreeBSD versions (13 and 14) and so.



Consider the possibility of a faulty drive. 

I recently dealt with a new drive (a new notebook) where Windows installed, repeatedly, without error but failed during use for the end user. Sustained writes with sysutils/stressdisk helped to reveal that the drive was faulty. I might have written about this a few weeks/months ago. 



Young said:


> Windows and Linux works normally, with full device throughput (550MB/s).



If that's the operating system installed to the suspect drive, then you can't perform a sustained write test of the entire drive.


----------



## Argentum (Oct 9, 2021)

Young said:


> I had tried everything I could: UFS/ZFS, new RAM modules, newer FreeBSD  versions (13 and 14) and so. The problem happens only on FreeBSD! Windows and Linux works normally, with full device throughput (550MB/s). My SSD is begining to wear out because of many repartitions/reformats I tried.


It was already mentioned here that one more tool is sysutils/smartmontools . Suggest to install it and see smartctl(8). In your case you can run `smartctl -a /dev/ada1` or `smartctl -x /dev/ada1`


----------



## Young (Oct 9, 2021)

sidetone said:


> The SATA controller or SSD technology may be new enough, that an additional setting may be needed for it to work. The mailing list may be more helpful for the specific setting. If they don't have a readily available solution, they would be able to tell you if a bug report is needed.
> 
> Thread usb-3-0-issues-with-pine-rock64.82354 is related, but it's about an SSD harddisk using the USB 3.0 xhci port (rather than a SATA 3.x one). It took adding an argument to /boot/loader.conf for the newer USB hardware to function.


That's make sense. I will subscribe to the mailing list today. Thanks!


----------



## Young (Oct 9, 2021)

mark_j said:


> Are they the only messages you're getting regarding the drive, especially before detach. I reckon there has to be more messages being output.
> 
> It is certainly possible FreeBSD has a lower thermal threshold for SSDs and it's detaching. Not likely, though.
> I would install smartmontools and see if it gives some clue. Yes, I know it works on Linux/Windows but they're maybe not as "touchy" about drives?
> (I have an SSD 870 as my boot disk, it works fine with FreeBSD - though it's not M.2)


Yup, no error precede it. Follow the full message log from the Live CD boot. The device was not even mounted when the detach occurred.


```
Oct  8 15:31:12  newsyslog[813]: logfile first created
Oct  8 15:31:12  syslogd: kernel boot file is /boot/kernel/kernel
Oct  8 15:31:12  kernel: ---<<BOOT>>---
Oct  8 15:31:12  kernel: Copyright (c) 1992-2020 The FreeBSD Project.
Oct  8 15:31:12  kernel: Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
Oct  8 15:31:12  kernel:     The Regents of the University of California. All rights reserved.
Oct  8 15:31:12  kernel: FreeBSD is a registered trademark of The FreeBSD Foundation.
Oct  8 15:31:12  kernel: FreeBSD 12.2-RELEASE r366954 GENERIC amd64
Oct  8 15:31:12  kernel: FreeBSD clang version 10.0.1 (git@github.com:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)
Oct  8 15:31:12  kernel: VT(efifb): resolution 800x600
Oct  8 15:31:12  kernel: CPU: Intel(R) Celeron(R) J4125 CPU @ 2.00GHz (1996.90-MHz K8-class CPU)
Oct  8 15:31:12  kernel:   Origin="GenuineIntel"  Id=0x706a8  Family=0x6  Model=0x7a  Stepping=8
Oct  8 15:31:12  kernel:   Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
Oct  8 15:31:12  kernel:   Features2=0x4ff8ebbf<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,SDBG,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,RDRAND>
Oct  8 15:31:12  kernel:   AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
Oct  8 15:31:12  kernel:   AMD Features2=0x101<LAHF,Prefetch>
Oct  8 15:31:12  kernel:   Structured Extended Features=0x2294e287<FSGSBASE,TSCADJ,SGX,SMEP,ERMS,NFPUSG,MPX,PQE,RDSEED,SMAP,CLFLUSHOPT,PROCTRACE,SHA>
Oct  8 15:31:12  kernel:   Structured Extended Features2=0x40400004<UMIP,RDPID,SGXLC>
Oct  8 15:31:12  kernel:   Structured Extended Features3=0xac000400<MD_CLEAR,IBPB,STIBP,ARCH_CAP,SSBD>
Oct  8 15:31:12  kernel:   XSAVE Features=0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>
Oct  8 15:31:12  kernel:   IA32_ARCH_CAPS=0x6b<RDCL_NO,IBRS_ALL,SKIP_L1DFL_VME>
Oct  8 15:31:12  kernel:   VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID,VID,PostIntr
Oct  8 15:31:12  kernel:   TSC: P-state invariant, performance statistics
Oct  8 15:31:12  kernel: real memory  = 8589934592 (8192 MB)
Oct  8 15:31:12  kernel: avail memory = 8062386176 (7688 MB)
Oct  8 15:31:12  kernel: Event timer "LAPIC" quality 600
Oct  8 15:31:12  kernel: ACPI APIC Table: <INTEL  GLK-SOC >
Oct  8 15:31:12  kernel: WARNING: L1 data cache covers fewer APIC IDs than a core (0 < 1)
Oct  8 15:31:12  kernel: FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
Oct  8 15:31:12  kernel: FreeBSD/SMP: 1 package(s) x 4 core(s)
Oct  8 15:31:12  kernel: arc4random: no preloaded entropy cache
Oct  8 15:31:12  kernel: ioapic0 <Version 2.0> irqs 0-119 on motherboard
Oct  8 15:31:12  kernel: Launching APs: 3 2 1
Oct  8 15:31:12  kernel: Timecounter "TSC" frequency 1996897292 Hz quality 1000
Oct  8 15:31:12  kernel: random: entropy device external interface
Oct  8 15:31:12  kernel: kbd0 at kbdmux0
Oct  8 15:31:12  kernel: 000.000023 [4336] netmap_init               netmap: loaded module
Oct  8 15:31:12  kernel: [ath_hal] loaded
Oct  8 15:31:12  kernel: module_register_init: MOD_LOAD (vesa, 0xffffffff81115e40, 0) error 19
Oct  8 15:31:12  kernel: random: registering fast source Intel Secure Key RNG
Oct  8 15:31:12  kernel: random: fast provider: "Intel Secure Key RNG"
Oct  8 15:31:12  kernel: nexus0
Oct  8 15:31:12  kernel: efirtc0: <EFI Realtime Clock> on motherboard
Oct  8 15:31:12  kernel: efirtc0: registered as a time-of-day clock, resolution 1.000000s
Oct  8 15:31:12  kernel: cryptosoft0: <software crypto> on motherboard
Oct  8 15:31:12  kernel: acpi0: <ALASKA A M I > on motherboard
Oct  8 15:31:12  kernel: acpi0: Power Button (fixed)
Oct  8 15:31:12  kernel: unknown: I/O range not supported
Oct  8 15:31:12  kernel: cpu0: <ACPI CPU> on acpi0
Oct  8 15:31:12  kernel: attimer0: <AT timer> port 0x40-0x43,0x50-0x53 irq 0 on acpi0
Oct  8 15:31:12  kernel: Timecounter "i8254" frequency 1193182 Hz quality 0
Oct  8 15:31:12  kernel: Event timer "i8254" frequency 1193182 Hz quality 100
Oct  8 15:31:12  kernel: atrtc0: <AT realtime clock> port 0x70-0x77 on acpi0
Oct  8 15:31:12  kernel: atrtc0: Warning: Couldn't map I/O.
Oct  8 15:31:12  kernel: atrtc0: registered as a time-of-day clock, resolution 1.000000s
Oct  8 15:31:12  kernel: Event timer "RTC" frequency 32768 Hz quality 0
Oct  8 15:31:12  kernel: hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff irq 8 on acpi0
Oct  8 15:31:12  kernel: Timecounter "HPET" frequency 19200000 Hz quality 950
Oct  8 15:31:12  kernel: Event timer "HPET" frequency 19200000 Hz quality 550
Oct  8 15:31:12  kernel: Event timer "HPET1" frequency 19200000 Hz quality 440
Oct  8 15:31:12  kernel: Event timer "HPET2" frequency 19200000 Hz quality 440
Oct  8 15:31:12  kernel: Event timer "HPET3" frequency 19200000 Hz quality 440
Oct  8 15:31:12  kernel: Event timer "HPET4" frequency 19200000 Hz quality 440
Oct  8 15:31:12  kernel: Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
Oct  8 15:31:12  kernel: acpi_timer0: <32-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
Oct  8 15:31:12  kernel: pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
Oct  8 15:31:12  kernel: pci0: <ACPI PCI bus> on pcib0
Oct  8 15:31:12  kernel: vgapci0: <VGA-compatible display> port 0xf000-0xf03f mem 0xf8000000-0xf8ffffff,0xf0000000-0xf7ffffff at device 2.0 on pci0
Oct  8 15:31:12  kernel: vgapci0: Boot video device
Oct  8 15:31:12  kernel: pci0: <simple comms> at device 15.0 (no driver attached)
Oct  8 15:31:12  kernel: ahci0: <AHCI SATA controller> port 0xf090-0xf097,0xf080-0xf083,0xf060-0xf07f mem 0xf9210000-0xf9211fff,0xf9215000-0xf92150ff,0xf9214000-0xf92147ff at device 18.0 on pci0
Oct  8 15:31:12  kernel: ahci0: AHCI v1.31 with 2 6Gbps ports, Port Multiplier supported
Oct  8 15:31:12  kernel: ahcich0: <AHCI channel> at channel 0 on ahci0
Oct  8 15:31:12  kernel: ahcich1: <AHCI channel> at channel 1 on ahci0
Oct  8 15:31:12  kernel: pcib1: <ACPI PCI-PCI bridge> at device 19.0 on pci0
Oct  8 15:31:12  kernel: pci1: <ACPI PCI bus> on pcib1
Oct  8 15:31:12  kernel: pci1: <network> at device 0.0 (no driver attached)
Oct  8 15:31:12  kernel: pcib2: <ACPI PCI-PCI bridge> at device 19.1 on pci0
Oct  8 15:31:12  kernel: pci2: <ACPI PCI bus> on pcib2
Oct  8 15:31:12  kernel: re0: <RealTek 8168/8111 B/C/CP/D/DP/E/F/G PCIe Gigabit Ethernet> port 0xe000-0xe0ff mem 0xf9000000-0xf9000fff,0x7fffe00000-0x7fffe03fff at device 0.0 on pci2
Oct  8 15:31:12  kernel: re0: Using 1 MSI-X message
Oct  8 15:31:12  kernel: re0: turning off MSI enable bit.
Oct  8 15:31:12  kernel: re0: ASPM disabled
Oct  8 15:31:12  kernel: re0: Chip rev. 0x4c000000
Oct  8 15:31:12  kernel: re0: MAC rev. 0x00000000
Oct  8 15:31:12  kernel: miibus0: <MII bus> on re0
Oct  8 15:31:12  kernel: rgephy0: <RTL8251/8153 1000BASE-T media interface> PHY 1 on miibus0
Oct  8 15:31:12  kernel: rgephy0:  none, 10baseT, 10baseT-FDX, 10baseT-FDX-flow, 100baseTX, 100baseTX-FDX, 100baseTX-FDX-flow, 1000baseT-FDX, 1000baseT-FDX-master, 1000baseT-FDX-flow, 1000baseT-FDX-flow-master, auto, auto-flow
Oct  8 15:31:12  kernel: re0: Using defaults for TSO: 65518/35/2048
Oct  8 15:31:12  kernel: re0: Ethernet address: 84:47:09:00:71:27
Oct  8 15:31:12  kernel: re0: netmap queues/slots: TX 1/256, RX 1/256
Oct  8 15:31:12  kernel: pcib3: <ACPI PCI-PCI bridge> at device 19.2 on pci0
Oct  8 15:31:12  kernel: pci3: <ACPI PCI bus> on pcib3
Oct  8 15:31:12  kernel: pcib4: <ACPI PCI-PCI bridge> at device 20.0 on pci0
Oct  8 15:31:12  kernel: pci4: <ACPI PCI bus> on pcib4
Oct  8 15:31:12  kernel: pcib5: <ACPI PCI-PCI bridge> at device 20.1 on pci0
Oct  8 15:31:12  kernel: pci5: <ACPI PCI bus> on pcib5
Oct  8 15:31:12  kernel: xhci0: <XHCI (generic) USB 3.0 controller> mem 0xf9200000-0xf920ffff irq 17 at device 21.0 on pci0
Oct  8 15:31:12  kernel: xhci0: 32 bytes context size, 64-bit DMA
Oct  8 15:31:12  kernel: usbus0 on xhci0
Oct  8 15:31:12  kernel: usbus0: 5.0Gbps Super Speed USB v3.0
Oct  8 15:31:12  kernel: isab0: <PCI-ISA bridge> at device 31.0 on pci0
Oct  8 15:31:12  kernel: isa0: <ISA bus> on isab0
Oct  8 15:31:12  kernel: acpi_button0: <Power Button> on acpi0
Oct  8 15:31:12  kernel: acpi_tz0: <Thermal Zone> on acpi0
Oct  8 15:31:12  kernel: est0: <Enhanced SpeedStep Frequency Control> on cpu0
Oct  8 15:31:12  kernel: Timecounters tick every 1.000 msec
Oct  8 15:31:12  kernel: arc4random: no preloaded entropy cache
Oct  8 15:31:12  kernel: Trying to mount root from cd9660:/dev/iso9660/12_2_RELEASE_AMD64_CD [ro]...
Oct  8 15:31:12  kernel: Root mount waiting for: CAM usbus0
Oct  8 15:31:12  kernel: ugen0.1: <0x8086 XHCI root HUB> at usbus0
Oct  8 15:31:12  kernel: uhub0: <0x8086 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0
Oct  8 15:31:12  kernel: ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
Oct  8 15:31:12  kernel: ada0: <ST1000LM048-2E7172 0001> ACS-3 ATA SATA 3.x device
Oct  8 15:31:12  kernel: ada0: Serial Number ZDEMH5A4
Oct  8 15:31:12  kernel: ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 8192bytes)
Oct  8 15:31:12  kernel: ada0: Command Queueing enabled
Oct  8 15:31:12  kernel: ada0: 953869MB (1953525168 512 byte sectors)
Oct  8 15:31:12  kernel: ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
Oct  8 15:31:12  kernel: ada1: <Samsung SSD 860 EVO M.2 250GB RVT24B6Q> ACS-4 ATA SATA 3.x device
Oct  8 15:31:12  kernel: ada1: Serial Number S413NS0R904336X
Oct  8 15:31:12  kernel: ada1: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 512bytes)
Oct  8 15:31:12  kernel: ada1: Command Queueing enabled
Oct  8 15:31:12  kernel: ada1: 238475MB (488397168 512 byte sectors)
Oct  8 15:31:12  kernel: uhub0: 16 ports with 16 removable, self powered
Oct  8 15:31:12  kernel: Root mount waiting for: usbus0
Oct  8 15:31:12  kernel: ugen0.2: <Microsoft Microsoft 2.4GHz Transceiver v7.0> at usbus0
Oct  8 15:31:12  kernel: ukbd0 on uhub0
Oct  8 15:31:12  kernel: ukbd0: <Microsoft Microsoft 2.4GHz Transceiver v7.0, class 0/0, rev 2.00/6.73, addr 1> on usbus0
Oct  8 15:31:12  kernel: kbd1 at ukbd0
Oct  8 15:31:12  kernel: ugen0.3: <vendor 0x8087 product 0x0a2a> at usbus0
Oct  8 15:31:12  kernel: Root mount waiting for: usbus0
Oct  8 15:31:12  syslogd: last message repeated 1 times
Oct  8 15:31:12  kernel: ugen0.4: <SanDisk Ultra> at usbus0
Oct  8 15:31:12  kernel: umass0 on uhub0
Oct  8 15:31:12  kernel: umass0: <SanDisk Ultra, class 0/0, rev 3.00/1.00, addr 3> on usbus0
Oct  8 15:31:12  kernel: umass0:  SCSI over Bulk-Only; quirks = 0xc100
Oct  8 15:31:12  kernel: umass0:2:0: Attached to scbus2
Oct  8 15:31:12  kernel: da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
Oct  8 15:31:12  kernel: da0: <SanDisk Ultra 1.00> Removable Direct Access SPC-4 SCSI device
Oct  8 15:31:12  kernel: da0: Serial Number 4C530000020801105114
Oct  8 15:31:12  kernel: da0: 400.000MB/s transfers
Oct  8 15:31:12  kernel: da0: 29328MB (60063744 512 byte sectors)
Oct  8 15:31:12  kernel: da0: quirks=0x2<NO_6_BYTE>
Oct  8 15:31:12  kernel: mountroot: waiting for device /dev/iso9660/12_2_RELEASE_AMD64_CD...
Oct  8 15:31:12  kernel: random: unblocking device.
Oct  8 15:31:12  kernel: arc4random: no preloaded entropy cache
Oct  8 15:31:12  syslogd: last message repeated 1 times
Oct  8 15:31:12  kernel: iwm0: <Intel(R) Dual Band Wireless AC 3165> mem 0xf9100000-0xf9101fff at device 0.0 on pci1
Oct  8 15:31:12  kernel: iwm0: hw rev 0x210, fw ver 22.361476.0, address 50:2f:9b:5d:da:86
Oct  8 15:31:12  kernel: lo0: link state changed to UP
Oct  8 15:31:12  kernel: re0: link state changed to UP
Oct  8 15:31:12  kernel: ums0 on uhub0
Oct  8 15:31:12  kernel: ums0: <Microsoft Microsoft 2.4GHz Transceiver v7.0, class 0/0, rev 2.00/6.73, addr 1> on usbus0
Oct  8 15:31:12  kernel: ums0: 5 buttons and [XYZT] coordinates ID=26
Oct  8 15:31:12  kernel: ums0: 0 buttons and [T] coordinates ID=0
Oct  8 15:31:12  kernel: uhid0 on uhub0
Oct  8 15:31:12  kernel: uhid0: <Microsoft Microsoft 2.4GHz Transceiver v7.0, class 0/0, rev 2.00/6.73, addr 1> on usbus0
Oct  8 15:31:12  kernel: ubt0 on uhub0
Oct  8 15:31:12  kernel: ubt0: <vendor 0x8087 product 0x0a2a, class 224/1, rev 2.00/0.01, addr 2> on usbus0
Oct  8 15:31:12  kernel: WARNING: attempt to domain_add(bluetooth) after domainfinalize()
Oct  8 15:31:12  kernel: WARNING: attempt to domain_add(netgraph) after domainfinalize()
Oct  8 15:31:12  kernel: ubt0: ubt_ctrl_write_callback:908: control transfer failed: USB_ERR_TIMEOUT
Oct  8 15:31:12  kernel: ng_hci_process_command_timeout: ubt0hci - unable to complete HCI command OGF=0x3, OCF=0x3. Timeout
Oct  8 15:31:13  kernel: [1;37r[m[4l[?1h=[?1000h[39;49m[?1h=[39;49m[m[H[2J[22B[36m[44m[1m[J[H FreeBSD Installer[K
Oct  8 15:31:14  kernel: [30m[47m<[31m[47mI[30m[47m[1mnstall[m[30m[47m> [37m[44m[1m<[33m[44m [37m[44mS[33m[44mhell [37m[44m>[7D[39;49m[m[30m[47m<[1m [m[31m[47mS[30m[47m[1mhell [m[30m[47m> [37m[44m[1m<L[33m[44mive CD[37m[44m>[20;55H[39;49m[m
Oct  8 15:31:14  kernel: [22;68H[?1000l[37;1H[?1l>Updating motd: /etc/motd is not writable, update failed.
Oct  8 15:31:17  kernel: ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
Oct  8 15:31:17  kernel: ada1: <Samsung SSD 860 EVO M.2 250GB RVT24B6Q> s/n S413NS0R904336X detached
Oct  8 15:31:17  kernel: (ada1:ahcich1:0:0:0): Periph destroyed
Oct  8 15:31:19  kernel: ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
Oct  8 15:31:19  kernel: ada1: <Samsung SSD 860 EVO M.2 250GB RVT24B6Q> ACS-4 ATA SATA 3.x device
Oct  8 15:31:19  kernel: ada1: Serial Number S413NS0R904336X
Oct  8 15:31:19  kernel: ada1: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 512bytes)
Oct  8 15:31:19  kernel: ada1: Command Queueing enabled
Oct  8 15:31:19  kernel: ada1: 238475MB (488397168 512 byte sectors)
```


----------



## Young (Oct 9, 2021)

grahamperrin said:


> Consider the possibility of a faulty drive.
> 
> I recently dealt with a new drive (a new notebook) where Windows installed, repeatedly, without error but failed during use for the end user. Sustained writes with sysutils/stressdisk helped to reveal that the drive was faulty. I might have written about this a few weeks/months ago.
> 
> ...


I don't think so. The detach occur even with the device not mounted. I made several tests before open this thread, so I'm pretty sure that the problem is not related to the disk itself.

Windows (Booted up from a external Kingston SSD on USB3 Port):
- Full S.M.A.R.T. Test OK
- Samguns Magician Extentend Surface Test OK
- Sustained Write Test (moving large files to the drive until it get full) OK

PartedMagic (Slackware Linux) (Booted up from a USB3 SanDisk Ultra Stick):
- Full S.M.A.R.T. Test OK
- DD Write Zeros OK
- Military Grade Wipe OK

The problem only happen on FreeBSD!


----------



## mer (Oct 9, 2021)

Just for grins, try to reset your BIOS settings to factory defaults.


----------



## Young (Oct 9, 2021)

mer said:


> Just for grins, try to reset your BIOS settings to factory defaults.


Already made it 2 times.


----------



## sidetone (Oct 9, 2021)

Can you paste the code into a code or quote tag. You can edit it above. It makes me download a file in order to view it.

```
[code]example text[/ code]
# without the space between / and code
[quote]sample text[/quote]
# these tags are case insensitive, so uppercase and lowercase or a combination can be used
```
On the computer, there's a button shortcut for code and quotes at the top of the dialog box. It may be inaccessible on a mobile. Code is the right tag, but the quote may be more convenient to use. As long as it can be seen on here.


This is for harddisks on USB:


deanj said:


> I reached-out to both the FreeBSD-USB & FreeBSD-arm mailing lists


Then, they gave a specific answer for that issue:


deanj said:


> /boot/loader.conf needs:
> fdt_overlays="rk3328-dwc3"
> 
> Once I added that overlay and rebooted - all worked as expected.


The answer could come from the /usr/src/ directory as well. Below is a more recent answer to that thread:


JohnnySorocil said:


> include that fdt overlay (devicetree overlay) because without it your system doesn't know that it have USB3 HW.
> Device tree is hardware description language and many HW things are not enumerable (USB controllers, I2C controllers and devices, SPI controllers and devices) - unlike things like USB devices which are enumerable (you can plug it and system will recognize it automatically).
> On PC side ACPI tables (forget which one exactly) are doing similar thing.
> You can find source of your overlay at /usr/src/sys/dts/arm64/overlays/rk3328-dwc3.dtso and full device trees at /usr/src/sys/contrib/device-tree/src/arm64/rockchip


Searching the source directory could be difficult.
/usr/src/README:

```
share           Shared resources.
stand           Boot loader sources.
sys             Kernel sources.
```
It's possible that someone on the forums would know the exact answer. It's more likely on a mailing list though, perhaps freebsd-hardware. It likely needs a specific argument in /boot/loader.conf because it seems like newer hardware. Please update us on if this is it, and if applicable, the config setting that works.


----------



## Young (Oct 9, 2021)

Argentum said:


> It was already mentioned here that one more tool is sysutils/smartmontools . Suggest to install it and see smartctl(8). In your case you can run `smartctl -a /dev/ada1` or `smartctl -x /dev/ada1`


`smartctl -a /dev/ada1`

```
smartctl 7.2 2020-12-30 r5155 [FreeBSD 12.2-RELEASE-p7 amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Samsung based SSDs
Device Model:     Samsung SSD 860 EVO M.2 250GB
Serial Number:    S413NS0R904336X
LU WWN Device Id: 5 002538 e31905b7f
Firmware Version: RVT24B6Q
User Capacity:    250,059,350,016 bytes [250 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      M.2
TRIM Command:     Available, deterministic, zeroed
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-4 T13/BSR INCITS 529 revision 5
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sat Oct  9 15:28:15 2021 -03
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00)    Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0)    The previous self-test routine completed
                    without error or no self-test has ever
                    been run.
Total time to complete Offline
data collection:         (    0) seconds.
Offline data collection
capabilities:              (0x53) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    No Offline surface scan supported.
                    Self-test supported.
                    No Conveyance Self-test supported.
                    Selective Self-test supported.
SMART capabilities:            (0x0003)    Saves SMART data before entering
                    power-saving mode.
                    Supports SMART auto save timer.
Error logging capability:        (0x01)    Error logging supported.
                    General Purpose Logging supported.
Short self-test routine
recommended polling time:      (   2) minutes.
Extended self-test routine
recommended polling time:      (  85) minutes.
SCT capabilities:            (0x003d)    SCT Status supported.
                    SCT Error Recovery Control supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
  9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       12
 12 Power_Cycle_Count       0x0032   099   099   000    Old_age   Always       -       159
177 Wear_Leveling_Count     0x0013   099   099   000    Pre-fail  Always       -       2
179 Used_Rsvd_Blk_Cnt_Tot   0x0013   100   100   010    Pre-fail  Always       -       0
181 Program_Fail_Cnt_Total  0x0032   100   100   010    Old_age   Always       -       0
182 Erase_Fail_Count_Total  0x0032   100   100   010    Old_age   Always       -       0
183 Runtime_Bad_Block       0x0013   100   100   010    Pre-fail  Always       -       0
187 Uncorrectable_Error_Cnt 0x0032   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0032   059   040   000    Old_age   Always       -       41
195 ECC_Error_Rate          0x001a   200   200   000    Old_age   Always       -       0
199 CRC_Error_Count         0x003e   100   100   000    Old_age   Always       -       0
235 POR_Recovery_Count      0x0012   099   099   000    Old_age   Always       -       143
241 Total_LBAs_Written      0x0032   099   099   000    Old_age   Always       -       348887624

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%         2         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
```

`smartctl -x /dev/ada1`

```
smartctl 7.2 2020-12-30 r5155 [FreeBSD 12.2-RELEASE-p7 amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Samsung based SSDs
Device Model:     Samsung SSD 860 EVO M.2 250GB
Serial Number:    S413NS0R904336X
LU WWN Device Id: 5 002538 e31905b7f
Firmware Version: RVT24B6Q
User Capacity:    250,059,350,016 bytes [250 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      M.2
TRIM Command:     Available, deterministic, zeroed
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-4 T13/BSR INCITS 529 revision 5
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sat Oct  9 15:28:47 2021 -03
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
AAM feature is:   Unavailable
APM feature is:   Unavailable
Rd look-ahead is: Enabled
Write cache is:   Enabled
DSN feature is:   Unavailable
ATA Security is:  Disabled, frozen [SEC2]
Wt Cache Reorder: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00)    Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0)    The previous self-test routine completed
                    without error or no self-test has ever
                    been run.
Total time to complete Offline
data collection:         (    0) seconds.
Offline data collection
capabilities:              (0x53) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    No Offline surface scan supported.
                    Self-test supported.
                    No Conveyance Self-test supported.
                    Selective Self-test supported.
SMART capabilities:            (0x0003)    Saves SMART data before entering
                    power-saving mode.
                    Supports SMART auto save timer.
Error logging capability:        (0x01)    Error logging supported.
                    General Purpose Logging supported.
Short self-test routine
recommended polling time:      (   2) minutes.
Extended self-test routine
recommended polling time:      (  85) minutes.
SCT capabilities:            (0x003d)    SCT Status supported.
                    SCT Error Recovery Control supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAGS    VALUE WORST THRESH FAIL RAW_VALUE
  5 Reallocated_Sector_Ct   PO--CK   100   100   010    -    0
  9 Power_On_Hours          -O--CK   099   099   000    -    12
 12 Power_Cycle_Count       -O--CK   099   099   000    -    159
177 Wear_Leveling_Count     PO--C-   099   099   000    -    2
179 Used_Rsvd_Blk_Cnt_Tot   PO--C-   100   100   010    -    0
181 Program_Fail_Cnt_Total  -O--CK   100   100   010    -    0
182 Erase_Fail_Count_Total  -O--CK   100   100   010    -    0
183 Runtime_Bad_Block       PO--C-   100   100   010    -    0
187 Uncorrectable_Error_Cnt -O--CK   100   100   000    -    0
190 Airflow_Temperature_Cel -O--CK   060   040   000    -    40
195 ECC_Error_Rate          -O-RC-   200   200   000    -    0
199 CRC_Error_Count         -OSRCK   100   100   000    -    0
235 POR_Recovery_Count      -O--C-   099   099   000    -    143
241 Total_LBAs_Written      -O--CK   099   099   000    -    348900681
                            ||||||_ K auto-keep
                            |||||__ C event count
                            ||||___ R error rate
                            |||____ S speed/performance
                            ||_____ O updated online
                            |______ P prefailure warning

General Purpose Log Directory Version 1
SMART           Log Directory Version 1 [multi-sector log support]
Address    Access  R/W   Size  Description
0x00       GPL,SL  R/O      1  Log Directory
0x01           SL  R/O      1  Summary SMART error log
0x02           SL  R/O      1  Comprehensive SMART error log
0x03       GPL     R/O      1  Ext. Comprehensive SMART error log
0x04       GPL,SL  R/O      8  Device Statistics log
0x06           SL  R/O      1  SMART self-test log
0x07       GPL     R/O      1  Extended self-test log
0x09           SL  R/W      1  Selective self-test log
0x10       GPL     R/O      1  NCQ Command Error log
0x11       GPL     R/O      1  SATA Phy Event Counters log
0x13       GPL     R/O      1  SATA NCQ Send and Receive log
0x30       GPL,SL  R/O      9  IDENTIFY DEVICE data log
0x80-0x9f  GPL,SL  R/W     16  Host vendor specific log
0xa1           SL  VS      16  Device vendor specific log
0xa5           SL  VS      16  Device vendor specific log
0xce           SL  VS      16  Device vendor specific log
0xe0       GPL,SL  R/W      1  SCT Command/Status
0xe1       GPL,SL  R/W      1  SCT Data Transfer

SMART Extended Comprehensive Error Log Version: 1 (1 sectors)
No Errors Logged

SMART Extended Self-test Log Version: 1 (1 sectors)
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%         2         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

SCT Status Version:                  3
SCT Version (vendor specific):       256 (0x0100)
Device State:                        Active (0)
Current Temperature:                    40 Celsius
Power Cycle Min/Max Temperature:     40/40 Celsius
Lifetime    Min/Max Temperature:     22/50 Celsius
Specified Max Operating Temperature:    70 Celsius
Under/Over Temperature Limit Count:   0/0
SMART Status:                        0xc24f (PASSED)

SCT Temperature History Version:     2
Temperature Sampling Period:         1 minute
Temperature Logging Interval:        10 minutes
Min/Max recommended Temperature:      0/70 Celsius
Min/Max Temperature Limit:            0/70 Celsius
Temperature History Size (Index):    128 (110)

Index    Estimated Time   Temperature Celsius
 111    2021-10-08 18:10     ?  -
 ...    ..( 10 skipped).    ..  -
 122    2021-10-08 20:00     ?  -
 123    2021-10-08 20:10    35  ****************
 ...    ..(  6 skipped).    ..  ****************
   2    2021-10-08 21:20    35  ****************
   3    2021-10-08 21:30    36  *****************
   4    2021-10-08 21:40    37  ******************
 ...    ..(  3 skipped).    ..  ******************
   8    2021-10-08 22:20    37  ******************
   9    2021-10-08 22:30     ?  -
 ...    ..( 25 skipped).    ..  -
  35    2021-10-09 02:50     ?  -
  36    2021-10-09 03:00    43  ************************
  37    2021-10-09 03:10     ?  -
  38    2021-10-09 03:20     ?  -
  39    2021-10-09 03:30     ?  -
  40    2021-10-09 03:40    44  *************************
  41    2021-10-09 03:50     ?  -
 ...    ..( 46 skipped).    ..  -
  88    2021-10-09 11:40     ?  -
  89    2021-10-09 11:50    32  *************
  90    2021-10-09 12:00     ?  -
 ...    ..( 19 skipped).    ..  -
 110    2021-10-09 15:20     ?  -

SCT Error Recovery Control:
           Read: Disabled
          Write: Disabled

Device Statistics (GP Log 0x04)
Page  Offset Size        Value Flags Description
0x01  =====  =               =  ===  == General Statistics (rev 1) ==
0x01  0x008  4             159  ---  Lifetime Power-On Resets
0x01  0x010  4              12  ---  Power-on Hours
0x01  0x018  6       348900681  ---  Logical Sectors Written
0x01  0x020  6         8107293  ---  Number of Write Commands
0x01  0x028  6       814215278  ---  Logical Sectors Read
0x01  0x030  6         9020126  ---  Number of Read Commands
0x01  0x038  6         2870000  ---  Date and Time TimeStamp
0x04  =====  =               =  ===  == General Errors Statistics (rev 1) ==
0x04  0x008  4               0  ---  Number of Reported Uncorrectable Errors
0x04  0x010  4               7  ---  Resets Between Cmd Acceptance and Completion
0x05  =====  =               =  ===  == Temperature Statistics (rev 1) ==
0x05  0x008  1              40  ---  Current Temperature
0x05  0x020  1              50  ---  Highest Temperature
0x05  0x028  1              22  ---  Lowest Temperature
0x05  0x058  1              70  ---  Specified Maximum Operating Temperature
0x06  =====  =               =  ===  == Transport Statistics (rev 1) ==
0x06  0x008  4              83  ---  Number of Hardware Resets
0x06  0x010  4               0  ---  Number of ASR Events
0x06  0x018  4               0  ---  Number of Interface CRC Errors
0x07  =====  =               =  ===  == Solid State Device Statistics (rev 1) ==
0x07  0x008  1               0  N--  Percentage Used Endurance Indicator
                                |||_ C monitored condition met
                                ||__ D supports DSN
                                |___ N normalized value

Pending Defects log (GP Log 0x0c) not supported

SATA Phy Event Counters (GP Log 0x11)
ID      Size     Value  Description
0x0001  2            0  Command failed due to ICRC error
0x0002  2            0  R_ERR response for data FIS
0x0003  2            0  R_ERR response for device-to-host data FIS
0x0004  2            0  R_ERR response for host-to-device data FIS
0x0005  2            0  R_ERR response for non-data FIS
0x0006  2            0  R_ERR response for device-to-host non-data FIS
0x0007  2            0  R_ERR response for host-to-device non-data FIS
0x0008  2            0  Device-to-host non-data FIS retries
0x0009  2            2  Transition from drive PhyRdy to drive PhyNRdy
0x000a  2            2  Device-to-host register FISes sent due to a COMRESET
0x000b  2            0  CRC errors within host-to-device FIS
0x000d  2            0  Non-CRC errors within host-to-device FIS
0x000f  2            0  R_ERR response for host-to-device data FIS, CRC
0x0010  2            0  R_ERR response for host-to-device data FIS, non-CRC
0x0012  2            0  R_ERR response for host-to-device non-data FIS, CRC
0x0013  2            0  R_ERR response for host-to-device non-data FIS, non-CRC
```


----------



## Argentum (Oct 9, 2021)

Young said:


> `smartctl -a /dev/ada1`
> 
> ```
> smartctl 7.2 2020-12-30 r5155 [FreeBSD 12.2-RELEASE-p7 amd64] (local build)
> ...


Looks all good. Can you try this drive on another platform with different controller model or can you test with different drive model on this platform?


----------



## Young (Oct 9, 2021)

Argentum said:


> Looks all good. Can you try this drive on another platform with different controller model or can you test with different drive model on this platform?


Unfortunately I don't have another system with M.2 SATA slot available. The DRAM-Less SSD that comes with this Mini PC work like a charm (slower, but at least without any issue). I really don't get it why I don't have any issues with Windows and Linux...


----------



## sidetone (Oct 9, 2021)

Young said:


> I really don't get it why I don't have any issues with Windows and Linux...


My theory is that, Windows and Linux already have the settings configured for the newer harddware. FreeBSD likely has it available, but it needs to be turned on manually, through a configuration file. It was the case in the other thread.


Young said:


> The DRAM-Less ... SSD that comes with this Mini PC work like a charm (slower, but at least without any issue).


It could be specific to DRAM functionality on the harddisk as well. There's a possibility that FreeBSD doesn't have specific support for that part on that hardware. If FreeBSD or BIOS can turn harddisk DRAM or other advanced harrdisk settings off, it may work with the right configuration adjustments.


----------



## mark_j (Oct 9, 2021)

I was going to suggest checking the firmware version of the m.2 but I see you've installed samsung magician previously and that would have said if you needed updated firmware.

So, I'm thinking out loud here, but from your  kernel boot mesg output it looks as if FreeBSD detects it being removed just as if it was hot-pluggable and then 'destroys' the device. I wonder if there is some setting in your bios/uefi?

You also said it happens after boot, yes? So it  seems almost electrical, in it's not making permanent contact because there's no other messages like CAM timeouts or CCB errors to indicate a detach and destroy. Maybe give it wiggle to ensure it's seated properly?


----------



## sidetone (Oct 10, 2021)

Young said:


> ahci0: <AHCI SATA controller> port 0xf090-0xf097,0xf080-0xf083,0xf060-0xf07f mem 0xf9210000-0xf9211fff,0xf9215000-0xf92150ff,0xf9214000-0xf92147ff at device 18.0 on pci0
> ahci0: AHCI v1.31 with 2 6Gbps ports, Port Multiplier supported
> ahcich0: <AHCI channel> at channel 0 on ahci0
> ahcich1: <AHCI channel> at channel 1 on ahci0











						FreeBSD 13.0-RELEASE Hardware Notes
					

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




					www.freebsd.org
				





> The  ahci(4) driver supports AHCI compatible controllers having PCI class 1 (mass storage), subclass 6 (SATA) and programming interface 1 (AHCI).


Was USB3.0 used to boot the computer for testing, and not have to do with the SATA connected to M.2?

On the mailing list, sometimes it takes a day for a response, but likely there'll be a response. If there's no mailing list response, IRC at Libera for FreeBSD or another FreeBSD channel can be tried. It takes time for them to answer, but not as long as a mailing list. Sometimes they'll answer immediately, to 30 minutes, to a few hours.


----------

