Running `sudo nix-store --gc` results in making my drive "read-only"

I just updated from nixos channel 24.05 to 24.11.

When I run sudo nix-store --gc, the result is sending my drive into “read-only” mode.

Is this something I should report on github?
Has anyone else experienced this issue?

What filesystem is this? btrfs?

Check dmesg.

The filesystem only turns itself readonly if there is irreparable damage or a sudden hardware defect.

What filesystem is this? btrfs?

Yes, I’m using BTRFS.

This only started happening whenever I ran the nix-store --gc command. Hasn’t happened for any other reason thus far.

I’ll check dmesg.

I ran dmesg, and instantly got this output:
dmesg dmesg: read kernel buffer failed: Operation not permitted

Needs to be run as root.

Oh my gosh, you’re right, haha! Totally forgot.

dmesg seems to output a bunch of i/o errors:

[  553.808335] xhci_hcd 0000:01:00.0: Transfer event 26 for unknown stream ring slot 2 ep 7
[  556.436187] sd 11:0:0:0: [sda] tag#21 uas_eh_abort_handler 0 uas-tag 26 inflight: CMD IN 
[  556.436201] sd 11:0:0:0: [sda] tag#21 CDB: Read(10) 28 00 0b fa fd 00 00 00 20 00
[  580.170978] sd 11:0:0:0: [sda] tag#24 uas_eh_abort_handler 0 uas-tag 27 inflight: CMD IN 
[  580.170999] sd 11:0:0:0: [sda] tag#24 CDB: Read(10) 28 00 00 23 c8 20 00 00 20 00
[  580.181010] scsi host11: uas_eh_device_reset_handler start
[  580.315251] usb 3-2: reset SuperSpeed Plus Gen 2x1 USB device number 2 using xhci_hcd
[  580.338354] scsi host11: uas_eh_device_reset_handler success
[  582.086184] sd 11:0:0:0: [sda] tag#23 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=59s
[  582.086200] sd 11:0:0:0: [sda] tag#23 CDB: Read(10) 28 00 56 9e cc 00 00 04 00 00
[  582.086205] I/O error, dev sda, sector 1453247488 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0
[  582.086253] sd 11:0:0:0: [sda] tag#22 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=59s
[  582.086260] sd 11:0:0:0: [sda] tag#22 CDB: Read(10) 28 00 56 9e c8 00 00 04 00 00
[  582.086264] I/O error, dev sda, sector 1453246464 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0
[  582.086290] sd 11:0:0:0: [sda] tag#20 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=59s
[  582.086296] sd 11:0:0:0: [sda] tag#20 CDB: Read(10) 28 00 56 9e d0 00 00 01 38 00
[  582.086300] I/O error, dev sda, sector 1453248512 op 0x0:(READ) flags 0x80700 phys_seg 39 prio class 0
[  582.885439] amd_iommu_report_page_fault: 1013 callbacks suppressed
[  582.885461] xhci_hcd 0000:01:00.0: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 6 comp_code 1
[  582.885472] xhci_hcd 0000:01:00.0: Looking for event-dma 00000000ffe6f790 trb-start 00000000ffe6f7a0 trb-end 00000000ffe6f810 seg-start 00000000ffe6f000 seg-end 00000000ffe6fff0
[  582.885479] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a70040 flags=0x0020]
[  582.885489] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a702c0 flags=0x0020]
[  582.885498] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a70200 flags=0x0020]
[  582.885506] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a70240 flags=0x0020]
[  582.885515] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a70000 flags=0x0020]
[  582.885523] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a70080 flags=0x0020]
[  582.885532] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a70100 flags=0x0020]
[  582.885540] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a70180 flags=0x0020]
[  582.885548] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a70280 flags=0x0020]
[  582.885556] xhci_hcd 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xe0a700c0 flags=0x0020]
[  612.938735] sd 11:0:0:0: [sda] tag#23 uas_eh_abort_handler 0 uas-tag 1 inflight: IN 
[  612.938748] sd 11:0:0:0: [sda] tag#23 CDB: Read(10) 28 00 02 08 38 98 00 04 00 00
[  612.948712] scsi host11: uas_eh_device_reset_handler start
[  613.069484] usb 3-2: reset SuperSpeed Plus Gen 2x1 USB device number 2 using xhci_hcd
[  613.092234] scsi host11: uas_eh_device_reset_handler success
[  613.092347] sd 11:0:0:0: [sda] tag#23 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=30s
[  613.092356] sd 11:0:0:0: [sda] tag#23 CDB: Read(10) 28 00 02 08 38 98 00 04 00 00
[  613.092361] I/O error, dev sda, sector 34093208 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0

[  329.461933] sd 11:0:0:0: [sda] tag#25 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.461942] sd 11:0:0:0: [sda] tag#25 CDB: Read(10) 28 00 1d a7 9f c8 00 00 68 00
[  329.461946] I/O error, dev sda, sector 497524680 op 0x0:(READ) flags 0x80700 phys_seg 13 prio class 0
[  329.461980] sd 11:0:0:0: [sda] tag#24 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.461986] sd 11:0:0:0: [sda] tag#24 CDB: Read(10) 28 00 00 cf 3f 28 00 00 50 00
[  329.461990] I/O error, dev sda, sector 13582120 op 0x0:(READ) flags 0x80700 phys_seg 10 prio class 0
[  329.462010] sd 11:0:0:0: [sda] tag#23 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.462016] sd 11:0:0:0: [sda] tag#23 CDB: Read(10) 28 00 00 cf 33 28 00 04 00 00
[  329.462019] I/O error, dev sda, sector 13579048 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0
[  329.462042] sd 11:0:0:0: [sda] tag#22 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.462047] sd 11:0:0:0: [sda] tag#22 CDB: Read(10) 28 00 00 cf 2f 28 00 04 00 00
[  329.462051] I/O error, dev sda, sector 13578024 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0
[  329.462072] sd 11:0:0:0: [sda] tag#21 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.462077] sd 11:0:0:0: [sda] tag#21 CDB: Read(10) 28 00 00 cf 3b 28 00 04 00 00
[  329.462080] I/O error, dev sda, sector 13581096 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0
[  329.462101] sd 11:0:0:0: [sda] tag#20 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.462106] sd 11:0:0:0: [sda] tag#20 CDB: Read(10) 28 00 00 cf 37 28 00 04 00 00
[  329.462109] I/O error, dev sda, sector 13580072 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0
[  329.462134] sd 11:0:0:0: [sda] tag#19 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.462140] sd 11:0:0:0: [sda] tag#19 CDB: Read(10) 28 00 49 c3 bb 08 00 03 e0 00
[  329.462143] I/O error, dev sda, sector 1237564168 op 0x0:(READ) flags 0x80700 phys_seg 124 prio class 0
[  329.462164] sd 11:0:0:0: [sda] tag#18 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.462170] sd 11:0:0:0: [sda] tag#18 CDB: Read(10) 28 00 49 c3 af 08 00 04 00 00
[  329.462173] I/O error, dev sda, sector 1237561096 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0
[  329.462194] sd 11:0:0:0: [sda] tag#17 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.462199] sd 11:0:0:0: [sda] tag#17 CDB: Read(10) 28 00 49 c3 b7 08 00 04 00 00
[  329.462203] I/O error, dev sda, sector 1237563144 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0
[  329.462221] sd 11:0:0:0: [sda] tag#16 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=40s
[  329.462226] sd 11:0:0:0: [sda] tag#16 CDB: Read(10) 28 00 49 c3 b3 08 00 04 00 00
[  329.462230] I/O error, dev sda, sector 1237562120 op 0x0:(READ) flags 0x84700 phys_seg 128 prio class 0

Seems not-usual. Is this an external drive, or how is it connected to the machine?

It is an external drive. I seem to experiencing more issues while trying to connect the drive via USB C. I’m using a USB 3.2 cable that came with the external portable drive.

I’ve heard of this happening when there’s power delivery issues; though you might be using a USB 3.2 cable, I would also verify what port you’ve got it plugged into and whether it can (stably) supply the power needed, especially under high I/O (which could explain why GC triggered this scenario in the first place).

Checking the revision (via motherboard manual) of that port would be one route, or potentially even inserting a cheap usb power meter (although it’d need to permit data passthrough, since that’s the whole point of having a drive, and it must support USB 3.x of course - not sure if you’d need something more restrictive beyond that, I forget offhand how differing spec versions downgrade on interaction beyond just dropping to the lowest common denominator in the chain). Alternatively you could try to rule that out by connecting the drive via SATA if possible.

Failing the above, also check the SMART data and verify if the drive itself is experiencing issues.

1 Like