The command you're probably thinking of is sync.
I recall reading somewhere how to send cached writes to disk using a
shell command before unplugging a usb flash drive but now I'm failing to
find it. Below follows why I think I need that:
Today I installed trixie, everything worked great except for a problem I
ran into preparing the installer media. I usually run:
default@debian:~$ sudo dd if=/home/default/debian-trixie-DI-rc2-amd64- netinst.iso of=/dev/sdf status=progress bs=1M
[sudo] password for default:
778+0 records in
778+0 records out
815792128 bytes (816 MB, 778 MiB) copied, 242.327 s, 3.4 MB/s default@debian:~$ cat /etc/debian_version
12.11
default@debian:~$ dd --version
dd (coreutils) 9.1
Strangely, it did not display status updates like it used to until after
it completed. The disk did not even show up in thunar until after I
unplugged then plugged it back into the usb port. Next strange thing was
when I mounted the finished boot media, the directory contents looked
normal, but the text files - readme, changelog, etc contents were garbled.
Attempted boot, grub came up with the usual options, I selected
graphical install (the default) then kernel panic, with something like "initrd contained junk"
SHA512SUM on debian-trixie-DI-rc2-amd64-netinst.iso matched so the
problem lies somewhere in my writing the media
retried with:
sudo dd if=/home/default/debian-trixie-DI-rc2-amd64-netinst.iso of=/dev/
sdf status=progress bs=1M conv=sync
same result
Next I performed some tests on my brand new very cheap usb 8GB flash
drive = all ok.
Finally, I wrote my iso file to this flash drive using "Disk Image
Writer" and everything worked like a charm. So now I wonder, what am I
doing wrong with dd? I recall having a similar failure maybe two years
ago. The rest of the time it just worked.
uh-oh here I found a clue... so I think this makes it seem like
something wasn't finished writing when I pulled it from the usb.
sudo dmesg
[ snip ]
[40798.311928] usb 2-1.2: new high-speed USB device number 27 using
xhci_hcd
[40798.416473] usb 2-1.2: New USB device found, idVendor=abcd, idProduct=1234, bcdDevice= 1.00
[40798.416491] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[40798.416500] usb 2-1.2: Product: UDisk
[40798.416508] usb 2-1.2: Manufacturer: General
[40798.416515] usb 2-1.2: SerialNumber: 2312182347284409360901
[40798.417989] usb-storage 2-1.2:1.0: USB Mass Storage device detected [40798.418491] scsi host7: usb-storage 2-1.2:1.0
[40799.444551] scsi 7:0:0:0: Direct-Access General UDisk 5.00 PQ: 0 ANSI: 2
[40799.444763] sd 7:0:0:0: Attached scsi generic sg5 type 0
[40799.445225] sd 7:0:0:0: [sdf] 15728640 512-byte logical blocks: (8.05 GB/7.50 GiB)
[40799.445333] sd 7:0:0:0: [sdf] Write Protect is off
[40799.445335] sd 7:0:0:0: [sdf] Mode Sense: 0b 00 00 08
[40799.445453] sd 7:0:0:0: [sdf] No Caching mode page found
[40799.445455] sd 7:0:0:0: [sdf] Assuming drive cache: write through [40799.446941] sdf: sdf1 sdf2
[40799.447110] sd 7:0:0:0: [sdf] Attached SCSI removable disk
[41167.136643] usb 2-1.2: reset high-speed USB device number 27 using xhci_hcd
[41167.236475] usb 2-1.2: device firmware changed
[41167.236574] usb 2-1.2: USB disconnect, device number 27
[41167.252396] blk_print_req_error: 1324 callbacks suppressed
[41167.252405] device offline error, dev sdf, sector 1384200 op 0x1:
(WRITE) flags 0x800 phys_seg 1 prio class 2
[41167.252423] buffer_io_error: 36796 callbacks suppressed
[41167.252426] Buffer I/O error on dev sdf, logical block 173025, lost
async page write
[41167.252625] device offline error, dev sdf, sector 1384216 op 0x1:
(WRITE) flags 0x104000 phys_seg 30 prio class 2
[41167.252635] Buffer I/O error on dev sdf, logical block 173027, lost
async page write
[ deleted 7 similar lines ]
[41167.252669] Buffer I/O error on dev sdf, logical block 173035, lost
async page write
[41167.252707] device offline error, dev sdf, sector 1384456 op 0x1:
(WRITE) flags 0x100000 phys_seg 1 prio class 2
[ deleted 6 similar lines ]
[41167.253272] device offline error, dev sdf, sector 1385296 op 0x1:
(WRITE) flags 0x100000 phys_seg 19 prio class 2
[41167.348915] ldm_validate_partition_table(): Disk read failed. [41167.348941] Dev sdf: unable to read RDB block 0
[41167.348961] sdf: unable to read partition table
[41167.536322] usb 2-1.2: new high-speed USB device number 28 using
xhci_hcd
[41172.740486] usb 2-1.2: device descriptor read/64, error -110 [41172.948721] usb 2-1.2: New USB device found, idVendor=1e3d, idProduct=198a, bcdDevice= 1.00
[41172.948739] usb 2-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[41172.950112] usb-storage 2-1.2:1.0: USB Mass Storage device detected [41172.950452] scsi host7: usb-storage 2-1.2:1.0
[41194.784951] usb 2-1.2: reset high-speed USB device number 28 using xhci_hcd
[41480.585883] usb 2-1.2: USB disconnect, device number 28
5. Verify the computed SHA256 checksum appears in the downloaded
SHA512SUMS file:
On 8/2/25 20:53, Nate Bargmann wrote:
The command you're probably thinking of is sync.
Strangely, it did not display status updates like it used to until after it completed.
I've been meaning to learn how to sha512sum after it is written to disk.
Now I've got it. Here are my results:
on the older usb disk that worked, sha512sum matched
on the new faulty disk, after writing with dd, sha512sum did not match
on the same faulty disk, after writing with "Disk Image Writer" and I successfully installed trixie on a machine, I checked the usb disk and sha512sum did not match 🙁 I thought I was finished with that server.
Now I need to decide if I will start over or just leave it and hope for
the best. Considering it is a mini pc used as a headless print server to connect a little used usb only printer to my network, I think I will
just place a note in /etc/motd like:
This copy of Debian was installed with a broken installer, expect anything!
I always recommend to add "oflag=sync" to dd itself: this way it
syncs as it goes and you don't have to wait for a (potentially
long) time for sync to "come back".
Together with "status=progress" you get a visual feedback on how
things are going (without having to kill -USR1 the thing all the
time :)
As Tomas pointed, with dd specifically you can use oflag=sync to have it
sync explicitly between each block, to get a better progress estimate.
Be sure to use a large block size or you will ruin performances.
On Sun Aug 3, 2025 at 6:52 AM BST, tomas wrote:
I always recommend to add "oflag=sync" to dd itself: this way it
syncs as it goes and you don't have to wait for a (potentially
long) time for sync to "come back".
Together with "status=progress" you get a visual feedback on how
things are going (without having to kill -USR1 the thing all the
time :)
A bugbear of mine is people recommending `dd` and using it without
any customisation e.g. `dd if=iso of=/device`, which is harder to
type than `cp iso /device`, and runs slower.
Your suggested `dd` flags demonstrate why it can be a better choice
than simple `cp` for this use-case. Thanks!
Meanwhile "dd" has always worked for me. I'll have to remember Tomas' recommendation for "oflag=sync" for the next time I write an image,
though that might be a while.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 146:03:49 |
Calls: | 10,383 |
Calls today: | 8 |
Files: | 14,054 |
D/L today: |
2 files (1,861K bytes) |
Messages: | 6,417,699 |