Why must partition be unmounted before using dd? For example, for copying an iso to a flash drive, we have to unmount the drive before we use dd. I've seen many places tell me to do this but never understood why?
Asked
Active
Viewed 2,103 times
6
John Robins
- 181
- 2
-
3What if something is writing to the partition when you are `dd`ing it? The image will inconsistent. – muru Feb 25 '16 at 03:01
-
Can u explain what unmount does? – John Robins Feb 25 '16 at 03:05
-
2Before that, do you know what mounting a partition does? See, for example, http://askubuntu.com/q/20680/158442. – muru Feb 25 '16 at 03:07
1 Answers
9
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.
Colin Ian King
- 18,370
- 3
- 59
- 70