A question about burning USB stick
Nils Kassube
kassube at gmx.net
Fri Jan 7 15:25:29 UTC 2011
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.
> 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?
> 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.
> 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.
Nils
More information about the ubuntu-users
mailing list