Score:0

dd Input/Output error trying to image an Ubuntu Mate USB flash image

ru flag

We are trying to make backup images of our Raspberry Pi test stations using the standard dd command but can not get past an IO error. dd has an IO error and ddrescue has a unaligned error but gparted does not see any issues with the USB drive. The system boots and runs normally so I'm thinking it has something to do with sector size definitions as suggested by this thread.

Misaligned partition

How can confirm this a sector size issue and how would I correct it with gparted?

  • Samsung USB 32Gb drive running Ubuntu Mate 21.10 on a Raspberry Pi4
  • Shut down the Pi and bring the stick over to a i386 machine running any Ubuntu 20x
fdisk -l

Disk /dev/sdb: 29.88 GiB, 32080200192 bytes, 62656641 sectors

Disk model: Flash Drive FIT 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc0f11707

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdb1  *      2048   524287   522240  255M  c W95 FAT32 (LBA)
/dev/sdb2       524288 62656607 62132320 29.6G 83 Linux
****************************************************************
sudo dd if=/dev/sdb of=server.img iflag=direct bs=16k status=progress

6248251392 bytes (6.2 GB, 5.8 GiB) copied, 363 s, 17.2 MB/s
dd: error reading '/dev/sdb': Input/output error
382013+0 records in
382013+0 records out
6258900992 bytes (6.3 GB, 5.8 GiB) copied, 416.203 s, 15.0 MB/s
****************************************************************
tester@OptiPlex-390:~/Downloads$ sudo ddrescue -d -f -r3 /dev/sdb test.img

 test.logfile
GNU ddrescue 1.23
Press Ctrl-C to interrupt
     ipos:    6259 MB, non-trimmed:    65536 B,  current rate:       0 B/s
     opos:    6259 MB, non-scraped:        0 B,  average rate:  18408 kB/s
non-tried:   25821 MB,  bad-sector:        0 B,    error rate:       0 B/s
  rescued:    6258 MB,   bad areas:        0,        run time:      5m 39s
pct rescued:   19.51%, read errors:        1,  remaining time:         19m
                              time since last successful read:          0s
Copying non-tried blocks... Pass 1 (forwards)
Unaligned read error. Is sector size correct?
lynnejohn avatar
ru flag
The original drive was made using balenaEtcher and a standard Ubuntu Mate image file. Is there a better way to take an image file and place it on a USB drive? Maybe use dd to take the image file and create the USB device with sector alignment?
lynnejohn avatar
ru flag
Looking at the USB drive with gparted the sectors seemed aligned as they are divisible by eight: Device Info: Samsung Flash Drive FIT Partition table: msdos Heads: 255 Sectors/track: 2 Cylinders: 122856 Total sectors: 62656641 Sector size: 512 -------------------------------------- MSDOS(fat16) /dev/sda1 First sector: 2048 Last sector: 524287 Total sectors: 522240 -------------------------------------- ext4 /dev/sda2 First sector: 524288 Last sector: 62656607 Total sectors: 62132320
lynnejohn avatar
ru flag
Attempting to format these comments is an exercise in futility, and then time runs out and you are no longer allowed to edit. For the comment above: If the sectors on the USB drive are aligned by eight, why is dd failing to create an image and ddrescue failing?
lynnejohn avatar
ru flag
Update: Using Ubuntu Disk Image Writer we took the Ubuntu Mate Pi image and wrote it to a different Samsung 32Gb USB drive. Brought up the Pi and loaded necessary packages to run the test station. We were able to back up that drive using dd on a VMWare virtual machine(Standard Ubuntu i386.) After running the Pi test station for a day we attempted to back it up. dd is failing with Input/output error again but in a different spot. The original USB failed @ the 6.3 GB mark but the new USB drive is consistently failing @ the 9.3 GB mark. The second USB shows no errors running a file system check.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.