4

Since this question, I'm using:

dd if=/dev/zero of=/dev/sdb bs=1M                  # wipe the disk
fdisk /dev/sdb <<< $'n\np\n\n\n\nt\nb\np\nw\n'     # create a partition 
mkfs.fat /dev/sdb1                            # FAT format the partition

to wipe a USB flash drive and restore it to a state, so that it can be used on Linux, Windows, TV recorders, etc.

But usually, once rebooting on Windows, it asks me to format the disk once again (as if it wouldn't have been re-initialized correctly).

Is it correct or would you generally make a FAT directly on /dev/sdb:

mkfs.fat /dev/sdb

What is the standard for USB flash drives, in order to be accepted by all main OS?

  • I havent tested on TV, but works fine for Windows and linux. answer. – jc__ Oct 27 '17 at 13:39
2

Sadly there is no good answer to this question. Whether or not you need partitions on the flash drive depends on the computer's firmware, and on the particular implementation of the USB protocol on the drive's chip. Most combinations can cope with partitions these days, but not all.

For the same reason zero-ing the start of the stick with dd may not be a good idea. A subsequent fdisk on Linux or *BSD may detect a different logical geometry then the initial one, which is likely to be different from what Windows expects. This is the most probable cause for what you're seeing, and there is no universal way to solve this problem. Running newfs / mkfs on existing partitions should be relatively safe, but running fdisk probably isn't.

On a related note: the same is true for SD cards, especially the high-capacity ones. Running fdisk on a SDXC card may actually render it unusable these days.

  • This is new info for me on zeroing out the start of a USB or SD. Isnt the "logical geometry" of a MBR partition table listed in the table, which may or may not match the geometry in the firmware? – jc__ Oct 27 '17 at 13:46
  • Nope, the logical geometry is not stored in the MBR, but it does determine the physical location of the entries described by the MBR. For spinning disks the geometry is given by the controller (I'm simplifying, but without changing the outcome). Flash disks are just memories, they don't have any meaningful geometry. A logical one is made up in software however, for compatibility with higher-level utilities such as fdisk. There are, of course, many possible geometries, and they aren't compatible to one another. There is no standard way to pick one, but Windows does have some preferred ones. – Satō Katsura Oct 27 '17 at 14:11
  • Running fdisk on a SDXC card may actually render it unusable these days. do you have any example/source about this? A storing device shouldn't be destroyed by just filling other bytes in it, that's trange? (it's a different thing to overwrite the firmware, then it seems obvious that it could make it unusable) – Basj Oct 27 '17 at 15:05
  • The SDXC isn't destroyed, it's just that the open source tools are unable to bring it back to a usable state. That's a failure of the open source tools. Most of the time Windows tools can bring it back, but not always. When they can't that's typically a failure of the USB chip. – Satō Katsura Oct 27 '17 at 15:31
0

I normally have some USB pendrives lying around my desk to use between computers if needed, and most of them have the exFAT filesystem. Compared with FAT32, the exFAT filesystem have no file size limitation (upto 4GB) and/or partition size (upto 16TB).

They work like a charm between Linux, Mac Os X, Windows...

For Mac Os X and Windows they work out of the box. For some Linux distros you may need to install some packages to support them...For instance Ubuntu (Debian):

 sudo apt-get install exfat-fuse exfat-utils

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.