5

How to create a bootable Ubuntu USB flash drive from terminal?

Why do guys here use umount first? I assume USB flash drive should be formatted first, so does umount format the disk, or just detach mounted device so it can be safely removed if another process isn't using it?

muru
  • 207,228
mk1024
  • 699

2 Answers2

10

umount un-mounts file systems.

This is needed here because it would be bad if you overwrote the partition while it is still mounted and possibly accessed by any application. You'd get errors.

See man umount for more information about the command.

Byte Commander
  • 110,243
7

Please correct me if I do not use the most appropriate terms here.

Within Linux/Ubuntu all devices are represented as files under the directory /dev. In the first answer of the linked question umount is used to detach certain device from the file-system in use, thus you can manipulate the entire device as pure file (/dev/sd?) without limitations. Then the command dd is used to copy the content of the input file image.iso file as content of the output file /dev/sd?.

Here I found a better explanation provided by Colin Ian King:

If you write data to the 'raw' block device while a filesystem on this device is still mounted then the kernel will have problems when updating the trashed file system. For example, the kernel will periodically flush dirty data back to the mounted device, or may do file lookups. If the underlying block device has been fundamentally changed then the kernel will find issues this can lead too kernel OOPs messages or even halt on BUG_ON() checks. So always unmount the filesystem before changing the underlying data on the block device.

pa4080
  • 30,621