8

I found these Debian EeePC HowToInstallUsingStandardInstaller instructions at the Debian Wiki, stating that I can install an ISO to a USB using this:

dd if=debian-*-netinst.iso of=/dev/sdX
  • Do I need to delete the contents of the USB prior to running this so that nothing is left at the end of the USB?
  • Does it matter what filesystem is already present on the USB prior to running this command?
11

Writing to the device (/dev/sdX) instead of to a file system (/mount/point) deletes the file system on the device anyway so there's no need for mkfs before.

There is also no need to erase data in the non-written area. It is not visible anyway. Linux file systems can without problems be smaller than the block device they live on.

| improve this answer | |
5

The dd command overwrites everything on the USB device. No preparaton is required.

| improve this answer | |
2

You don't need to erase the old data first. But you can if you want to. Sometimes it's a good idea. Particularly if you're giving it to someone.

This should do the trick:

Linux:

dd if=/dev/zero of=/dev/sdx

Macintosh:

dd if=/dev/zero of=/dev/diskx
diskutil zeroDisk /dev/diskx

Where sdx or diskx is the target disk. Usually, sda/disk0 is the first disk, containing the main OS, etc. (i.e. SCSI/SATA Disk A), followed by sdb/disk1, sdc/disk2, and so on.
If you have one internal disk (/dev/sda or /dev/disk0), and you connect an external drive via USB; the external drive will be /dev/sdb or /dev/disk1. You get the idea. SD cards are designated names like /dev/mmcblk0 and so on, in a similar fashion.

Some refer to this as zeroing or low-level formatting. The pseudo-file /dev/zero can be thought of as being similar to /dev/null; but designed to be read from, rather than written to. It will supply a steady stream of ASCII NUL (0x00) bytes to whatever process tries to read from it.

The original filesystem will be overwritten.


Some additional options that people commonly like to use with dd, to manipulate block size & data read/write speeds follow the syntax:

bs=512kB count=1 

Also, I personally like to have a running status/progress report so I can tell what's going on; to do this, just add the following to the tail end of the command:

status=progress

Take care to specify the correct disk. Especially if copying/pasting commands like this directly into a shell. It takes milliseconds to bork the wrong partition table. To list your storage devices, begin with:

Linux:

lsblk

Macintosh:

diskutil list

The output will look something like this:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            499.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
| improve this answer | |

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.