Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted
  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.
share|improve this answer
    
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 '13 at 11:47
    
What is remkfs? Could not find the man entry for it. –  eitan27 May 5 '13 at 11:49
    
It's called mke2fs, mkfs.ext3, mkdosfs, mkfs.btrfs etc. I've meant "remake filesystem" (just wrote in compact form). –  Mikhail Kupchik May 5 '13 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 '13 at 13:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.