Subject: parted miscalculates size of USB disk that has been written a raw ISO image

From: Bjørn Forsman <[email-masked]>
Date: Wed, 22 Mar 2017 09:28:23 +0100

Hi parted developers,

After having written an ISO image to my USB disk, parted gets really
confused. The USB disk is 64 GB, but parted thinks it's 257 GB! And
worse, when I try to reset the disk with "mklabel gpt" it throws
errors.

This issue is very much related to
http://lists.gnu.org/archive/html/bug-parted/2016-12/msg00016.html.

You can find the log of my parted session below my signature.

-- 
Best regards,
Bjørn Forsman

$ sudo dd if=ubuntu.iso of=/dev/sdb bs=1M

$ sudo parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Warning: The driver descriptor says the physical block size is 2048
bytes, but Linux says it is 512 bytes.
Ignore/Cancel? I
Model: Samsung Flash Drive (scsi)
Disk /dev/sdb: 257GB
Sector size (logical/physical): 2048B/512B
Partition Table: mac
Disk Flags:

Number  Start   End     Size    File system  Name   Flags
 1      2048B   6143B   4096B                Apple
 2      1479MB  1481MB  2425kB               EFI

(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all
data on this disk will be lost. Do you want to continue?
Yes/No? y
Error: Invalid argument during seek for write on /dev/sdb
Retry/Ignore/Cancel? I
Error: Invalid argument during seek for write on /dev/sdb
Retry/Ignore/Cancel? ^C
(parted) q

$ sudo parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/sdb: unrecognised disk label
Model: Samsung Flash Drive (scsi)
Disk /dev/sdb: 64.2GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted)

So in the end it seemed like parted managed to reset the drive, but
why make it so difficult?