Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Knoppix question

Credits go to bamccaig and Chris Katko for helping out!
This thread is locked; no one can reply to it. rss feed Print
Knoppix question
Bob Keane
Member #7,342
June 2006

I tried writing a fedora iso to a usb stick using Knoppix using the dd command. The write failed saying "/media/sdb1 is a file or directory". Is it possible to use Knoppix to create the iso?

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

bamccaig
Member #7,536
July 2006
avatar

The distribution shouldn't matter. dd is dd. Typically I think you write directly to the device file though, not a partition (or a mount point of a partition). You may be instead looking for:

sudo dd if=/path/to/file.iso of=/dev/sdb

(Note: /dev not /media)
(Note: sudo is used to elevate to root; you can just use `su -` instead if your distribution doesn't use sudo)

Warning: this is a destructive command. It WILL overwrite whatever the contents of the device is. If you screw up the device it will gladly wipe out a hard drive. It will also gladly wipe out any data on the USB stick that you're using so make sure any data on the USB stick is backed up first.

There is an "enhanced" version of dd for this purpose too, but the name eludes me right now. I've only used it once. It just adds some bells and whistles. It's not really needed though.

There are some additional options you can use to potentially speed things up, but this bare command should suffice.

If you Google how to write an ISO to a USB stick in Linux you'll find tons of guides that may offer better advice.

Append:

After writing a USB device like this you can verify that it succeeded (poor man's check) by reading the exact length of the ISO file from the device and calculating a cryptographic hash for it (e.g., sha1sum). You can then compare that with the hash of the actual ISO. They should match if you've done it correctly.

sha1sum /path/to/file.iso
length="$(stat -c '%s' /path/to/file.iso)"
head -c "$length" /dev/sdb | sha1sum

If those hashes match you should be good. If they do not I would be suspicious that I did something wrong.

Chris Katko
Member #1,881
January 2002
avatar

bam nailed it.

You don't write to a file system because the ISO has a filesystem too. You write to the raw device.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Bob Keane
Member #7,342
June 2006

Thanks for the info. I used /media/sda1 because that is how the drive showed in file manager. There is nothing on the stick I cannot live without so dd should be okay.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

bamccaig
Member #7,536
July 2006
avatar

Most likely your distro automatically mounted the USB's partition to that directory. Often that is done automatically, but back in the day we used to have to manually mount it:

su -
mkdir /mnt/usb
mount /dev/sdb1 /mnt/usb

/dev/sdb is a "special" file that represents your USB device itself. /dev/sdb1 is a special file that represents the first partition on the USB device. If the kernel is asked to read or write to it then it translates that to reading or writing data from the memory space addressable on it. /mnt/usb in this case, which is a random directory that I made up, is a "mount point" for the partition. Once the mount command succeeds a listing of that directory will match the contents of the USB device, and can be manipulated as such. If you `umount /mnt/usb` to unmount the file system on the USB partition then it will go back to being an empty directory again.

Instead, that sort of happens automatically by some systems either part of systemd or perhaps the file manager itself (or both). I'm kind of fuzzy on what does it. Usually it's annoying so I wish you could tell the system NOT to do it automatically. And it's Linux so of course you can, but I just haven't cared to find out how. I digress. I think you're on your way now.

Gideon Weems
Member #3,925
October 2003

Add bs=100M status=progress to the dd command to be a pro. 8-)

Go to: