mkfs.ext2 on an already existing ext2 filesystem
by brancalessio from LinuxQuestions.org on (#5FVKC)
Hello everyone!
A couple of days ago I wanted to check the ext2 partition on a device (USB Stick) with the following command:
Code:fsck.ext2 -t -v -v -f /dev/sdb1but I made a mistake and I wrote:
Code:mkfs.ext2 -t -v -v -f /dev/sdb1So I gave mkfs.ext2 instead of fsck.ext2 (but with fsck.ext2 parameters...). In spite of the unusual messages on the terminal I went on... mkfs.ext2 created a ext2 filesystem on the device.
Here is my question. I feared to have lost all data on the device, but actually it is not the case (it seems nothing has been deleted). Even the filesystem creation date (quite a long time ago) is unchanged. Have I been lucky?
I guess (for example) that if I run mkfs.ext2 on some FAT32 partition, I will delete the data. Running mkfs.ext2 on an already ext2 formatted partition did not make any changes. I that always true? I also found these two threads (but there the filesystem was changed): https://www.linuxquestions.org/quest...r-mkfs-224270/ and https://www.linuxquestions.org/quest...-stick-715241/
So, the right way to recreate a ext2 partition (without preserving data) would be to wipe the partition (with something like dd, shred, wipefs, scrub) and then run mkfs.ext2?
Thank you for your answers!


A couple of days ago I wanted to check the ext2 partition on a device (USB Stick) with the following command:
Code:fsck.ext2 -t -v -v -f /dev/sdb1but I made a mistake and I wrote:
Code:mkfs.ext2 -t -v -v -f /dev/sdb1So I gave mkfs.ext2 instead of fsck.ext2 (but with fsck.ext2 parameters...). In spite of the unusual messages on the terminal I went on... mkfs.ext2 created a ext2 filesystem on the device.
Here is my question. I feared to have lost all data on the device, but actually it is not the case (it seems nothing has been deleted). Even the filesystem creation date (quite a long time ago) is unchanged. Have I been lucky?
I guess (for example) that if I run mkfs.ext2 on some FAT32 partition, I will delete the data. Running mkfs.ext2 on an already ext2 formatted partition did not make any changes. I that always true? I also found these two threads (but there the filesystem was changed): https://www.linuxquestions.org/quest...r-mkfs-224270/ and https://www.linuxquestions.org/quest...-stick-715241/
So, the right way to recreate a ext2 partition (without preserving data) would be to wipe the partition (with something like dd, shred, wipefs, scrub) and then run mkfs.ext2?
Thank you for your answers!