2

We have Beaglbone black based custom board with 256MB RAM and 4GB eMMC.

We have script to flash software on the board.
Script erases gpt partition table using following commands

#Delete primary gpt (first 17KiB)
dd if=/dev/zero of=/dev/mmcblk0 bs=1024 count=17
#Delete secondary gpt (last 17KiB)
dd if=/dev/zero of=/dev/mmcblk0 seek=3735535 bs=1024 count=17

Partitions gets deleted however script re-partitions eMMC again in the same number of partitions.
After that it tries to format each partition using mkfs.ext4 (e2fsprogs version 1.42.13).

Now while formatting a partition mkfs.ext4 complains that partition has filesystem on it and it was mounted at particular date in past and ask if it should proceed ?

/dev/mmcblk0p15 contains a ext4 file system labelled 'rootfs'
        last mounted on /mnt/rfs_src on Fri Feb 16 13:52:18 2018
Proceed anyway? (y,n)

This was not happening in past i.e. with e2fsprog version 1.42.8
same script used to work.

From release note of e2fsprog-1.42.13 I see that last mounted is added to some structure.

Now question is how can we remove this last mounted information from partition?

I tried wipfs -a but it has the same behavior. One way to zero while eMMC, however that will take lot of time.

Any suggestion/pointers ?

  • 1
    Does this help? unix.stackexchange.com/a/394999/30851 – frostschutz Feb 16 '18 at 22:51
  • Thank you for suggestion, that perfectly worked for me. I was trying wipefs -a /dev/mmcblk0 with wipfs -a /dev/mmcblk0p[0-9]* worked fine. That did what we wanted. – AnkurTank Feb 19 '18 at 15:38
  • @frostschutz can you add that as answer? – AnkurTank Feb 19 '18 at 16:35
2

From mkfs.ext4's man page:

   -F     Force mke2fs to create a filesystem, even if the specified
          device is not a partition on a block special device, or if
          other parameters do not make sense.  In order to force mke2fs
          to create a filesystem even if the filesystem appears to be in
          use or is mounted (a truly dangerous thing to do), this option
          must be specified twice.

you can just add the -F option to mkfs.ext4 in the script to bypass the question and have it continue unattended. It's not clear from the description that this is the "or if other parameters do not make sense" case. I double checked that only a single -F is needed, thus still protecting against accidentally formatting a mounted filesystem.

I don't think the last-mounted-directory is related to this. It's just more failsafe added. Likewise, some newer versions of the interactive fdisk or gdisk do the opposite: when they detect a previous filesystem was there when creating a new partition, they offer to wipe the signature.

  • Thank you for reply A.B. I referred seen -F option however I don't want to use that because from the same help snippet I see that "force mke2fs to create a filesystem" even if the specified device is not a partition on a block special device, or if other parameters do not make sense, I mkfs to error out when parameters do not make sense. Suggested answer from @frostschutz worked for me is wipefs -a on each partition to delete ext4 filesystem. And then running it on main eMMC partition to delete partition table. i.e. wipefs -a /dev/mmcblk0p[0-9]* followed by wipefs -a /dev/mmcblk0 – AnkurTank Feb 19 '18 at 15:33
0

Thanks to @frostschutz, his suggestion worked for.
Just for completeness I am adding that as an answer,

Using following commands did the trick for me.

wipefs -a /dev/mmcblk0p[0-9]*
wipefs -a /dev/mmcblk0

First command deleted filesystem information from each partitions.
second command deleted partition table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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