A question about burning USB stick

Colin Law clanlaw at googlemail.com
Fri Jan 7 17:29:48 UTC 2011


On 7 January 2011 15:25, Nils Kassube <kassube at gmx.net> wrote:
> Colin Law wrote:
>> I have an image that I wish to burn to a USB stick using dd.  When I
>> insert the stick it is mounted (it already has valid partitions on
>> it) and
>> sudo fdisk -l
>> shows that it is mounted as sdb.
>
> I think you mean that the command shows it is the device /dev/sdb - the
> fdisk command doesn't show what is mounted.

Quite right, of course, sloppy thinking on my part.

>
>> The command I am going to use to
>> burn it is sudo dd if=myfile.bin of=/dev/sdb bs=10M
>> but it does not seem right to burn it while it is mounted.  However
>> if I eject it then it is no longer /dev/sdb and the dd command
>> fails.
>
> If you eject a USB device, it is disabled, which is the same as if you
> unplug it. After that operation you have to unplug it because it is no
> longer accessible.
>
>> So the first question is, is it correct just to go ahead and run dd
>> with the stick mounted?
>
> It depends if it is really mounted. It is unlikely that /dev/sdb is
> mounted if there are valid partitions on it. The partition(s) can be
> mounted though and if that is the case you should unmount them (don't
> use eject). That would be a command like
>
> sudo umount /dev/sdb?

Great, that is what I was looking for, that lets me unmount it without
disabling it.

>
>> Once the burn is complete then there is a similar question, should I
>> 'eject' it before unplugging it?  The reason I ask is that I am
>> concerned that the system may be confused about whether it is
>> unmounting and ejecting the original image or the one I have
>> re-written.
>
> If you used the umount command above, there is nothing for the system to
> be confused. OTOH, I'm not so sure if the eject command would work if
> the partition table has changed due to the new image. Until now I have
> never used eject after writing a disk image but I have always used the
> command
>
> sync
>
> after the write command to make sure that all data are written to the
> device.

Once again, just what I was looking for.  Thanks.

>
>> The reason I am asking the questions in the first place is that I
>> have some problems and am not sure whether it is what I am doing
>> that is wrong or if the stick is faulty.
>> The symptom is that when I burn it then success is reported and it
>> says it has written 4022337024 bytes (which is the size of the image
>> file).  If I immediately (without ejecting) dump it back again using
>> sudo dd if=/dev/sdb of=dumpfile.bin bs=10M
>> it again reports success with the same number of bytes transferred.
>> However if I diff the original file and the dumped one the contents
>> are different (they are the same size).
>>
>> If I 'eject' the stick and re-insert it and then dump it again using
>> dd then I get an I/O error at about 3.6GB of the 4GB stick.
>
> Could that be the difference between GB and GiB? At 4GB the difference
> would be about 7%, so it might fit depending on what "at about 3.6GB"
> means.

No, it is not that, the number of bytes written is reduced also, and
it is not always 3.6GB.  The fact that I also get an I/O error seemed
to point to a problem of some sort also.

Armed with my new found knowledge, thanks to yourself, I tried again,
unmounting before burning, and syncing after burning.  Unfortunately
when I then try to dump from the stick I again get an IO error, but
this time it is even earlier, at 3.1GB.  So I suspect it is time to
send the stick to the bin.  I have ordered a new one.

Many thanks for the help.

Colin




More information about the ubuntu-users mailing list