Error creating bootable USB using "cat file.iso > /dev/sdb"
Olivia Zamora
At first, I had this USB flash drive with a Ubuntu 14.04 LTS bootable in it. But now, I want to remove/wipe it and create a new bootable of another OS.
First, I tried directly:
sudo cat file.iso > /dev/sdb; syncAs suggested in this thread. It didn't worked, returned
bash: /dev/sdb: Permission denied
So, I thought that this was happening because of it already containing a bootable and decide to wipe it. So I just shreded it
sudo shred -v /dev/sdb
After it, It wasn't appearing on the nautilus vertical nav as I sticked it into PC. So I made a file system for it sudo mkfs.ext3 /dev/sdb (I don't know if it's the right type of fs to make it but I was just testing anyway, if it isn't, please warn me about this)
Now, I access it through nautilus and I see that it is indeed empty. I'm trying to make that command I was doing in the beginning sudo cat file.iso > /dev/sdb; sync but still having the same "permission denied" again.
So, two questions on that, did this mkfs was applied correctly or I shouldn't do that? And, how do I solve my problem of making my bootable iso finally? (I don't want to use unetbootin, couldn't install it and I read that it could be done using cat/sync) Thanks in advance.
4 Answers
I have noticed that the other answers all seem to be questioning why you're using cat in this context, and then go on to suggest you use dd.
There's no need. The original command you posted is basically right, it just won't work with sudo (because direction is done by the shell, not by cat, so you don't have permission to do it), so get yourself initially to a root shell.
sudo -iWhen you drop to the root prompt, issue your first command.
cat file.iso > /dev/sdb; syncIt'll do exactly what you think, and write the ISO directly to the USB stick, and is probably the quicker and more sensible way to do this than using dd
Don't forget to type
exitWhen you've finished with the root shell.
3The command you try
sudo cat file.iso > /dev/sdb; syncwould, if it does what you expect, completly overwrite the usb drive. So there is no need / no sense to create a ext3 filesystem on it before.
Your mkfs.ext3 command in a sense is fine.
The actually cat command will not work because the sudo command runs as root but the redirection of the output does not. A simple way to get it working is
sudo dd if=file.iso of=/dev/sdb bs=16k; syncAs this doesn't use output redirection there is no problem with sudo.
This is mentioned as the "retro way" in the question you linked to.
Powerful but dangerous commands
cat and dd can do the trick, to clone from an iso file to a mass storage device, for example a USB flash drive or a memory card.
When you write to a device like this, you will overwrite what was there before, including the partition table and file systems. These commands do what you tell them to do without any questions. So if you tell them to wipe your family pictures, they will do it. And it is a minor typing error away.
Since dd has been used traditionally for this purpose, it has deserved the nicknames 'Disk Destroyer' and 'Data Destroyer', but the same risks apply to cat, when used in this context.
Tools that identify the target device, and have a final checkpoint
For this reason it is better to use tools with help functions to identify the target device, and a final checkpoint, where you have an opportunity to check that you have selected the correct target device, the USB flash drive. This way you can avoid overwriting the internal drive with the operating system and various personal data files or an external drive with personal data files or backup.
Cloning tools that produce the same result as
catandddfor this purpose,- Startup Disk Creator in Ubuntu 16.04 LTS and newer versions
- Disks alias
gnome-disks - mkusb
Extracting tools that produce working USB boot drives, that are different (not cloned copies),
- Rufus (only in Windows)
- Unetbootin (in Linux, Windows and MacOS)
See this link and links from it for more details,
There is Etcher too to do this...
1