Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

A lot of discussions exist here on making a bootable USB stick. Debian manual on installing Wheezy suggest the following:

# cp debian.iso /dev/sdX
# sync

Making sure the USB device is first unmounted.

Debian manual page.

I have done this in preparation to install wheezy. It seem to work, because the ISO image is all that is seen on the USB and usable size is that of the image. Remains to see if it will boot and so on.

Now, can somebody elaborate why this work. I thought a cp command like this is similar to a drag and drop, (apart from the USB being unmounted).

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Devices in Linux are files. /dev/sda or /dev/sdb are files as well. So what you do is replace the /dev/sdX file with the dot-ISO file, which you can then mount and use as a device.

What sync does, is it forces the changed blocks on the virtual device (/dev/sda file) to be updated on the actual disk.

share|improve this answer
2  
So the magic part of this is to perform the cp command on an unmounted device (file). It's like it was common knowledge when reading debian manual, and maybe it is? Anyway, it did work, my new machine booted the USB and wheezy installed, thanks. –  Tompa Jul 18 '13 at 10:09

A possibly better way of doing it is with dd. which does byte copy. the syntax would be

dd if=debian.iso of=/dev/sdX

and the command will need to be run as root. dd allows you to have more control if you want it. check out it's man page here.

share|improve this answer
    
And this command I guess is to be performed with a mounted device? –  Tompa Jul 18 '13 at 10:09
    
@Tompa, actually it doesn't matter. It would probably be better to use an unmounted device because you are overwriting the entire partition structure that is formatted in say fat or ext3 or ntfs and replacing it with the cdrom or dvd format (usually UDF). If the operating system is writing to the filesystem while it gets overwritten it could be a bad thing. the block device /dev/sdx basically is a virtual file allowing binary access to the entire harddrive. –  Mobius Jul 18 '13 at 14:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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