2

I have a partition called sdb1 formatted as ext4. The partition is currently mounted.

If I do the following:

dd if=/dev/zero of=/dev/sdb1
  1. What are the consequences (beyond all data on the being lost)?
  2. Are there any risks associated with keeping the partition mounted while I do it?
  3. Must I reformat the partition with a filesystem in order to use it?

Thanks.

1 Answer 1

3
  1. None. But be careful when specifying block device name, you can accidently wipe another partition.
  2. Kernel should not allow that. If it does, you will likely have a kernel panic: kernel filesystem code does not expect someone else (userspace dd) to make changes to the block device simultaneously.
  3. After dd, there's no filesystem in the partition and you must reformat (remkfs) before using/mounting the partition.
4
  • Regarding your answer to #1, this seems very true. I ran dd on /dev/sdb1 and it only stopped when running out of space: "dd: writing to `/dev/sdb1': No space left on device". I can foresee situations where this might not error out so smoothly.
    – eitan27
    May 5, 2013 at 11:47
  • What is remkfs? Could not find the man entry for it.
    – eitan27
    May 5, 2013 at 11:49
  • It's called mke2fs, mkfs.ext3, mkdosfs, mkfs.btrfs etc. I've meant "remake filesystem" (just wrote in compact form). May 5, 2013 at 12:57
  • 2
    An extension to #3: There are ways to use a partition without a filesystem. A swap partition is the most familiar example, but there are others, such as a BIOS Boot Partition or LVM (although in the case of LVM, you'll normally create logical volumes that themselves hold filesystems, so this just pushes them down one level). Both swap space and BIOS Boot Partitions are normally smaller than most filesystem partitions, so you probably wouldn't convert a filesystem to one of these. It could be done, though.
    – Rod Smith
    May 5, 2013 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .