My question is as stated above, on a FreeBSD system, what is the use of the kern.geom.debugflags ?

I see it written before the command to write on to a disk.

sysctl kern.geom.debugflags=16

What does it do and is there any Linux equivalent of the following command?


Out from the box you cannot write to MBR of disk, which is the one FreeBSD boots from. After setting sysctl kern.geom.debugflags=16 (or kern.geom.debugflags=0x10, which is all the same) you get allowed to shoot in the foot and write to MBR.

It's useful to backup and restore MBR or bootcode using dd: backup and restore MBR via dd

The only way to write into MBR without touching this sysctl is to boot your FreeBSD in single-user mode and work with MBR while root filesystem is mounted read-only. If boot in single-user mode and then remount root filesystem in rw-mode, you will need to set this sysctl to write into MBR. If normally boot in multi-user mode and then go to single-user mode (by typing shutdown now without -r or -h arguments), you would still need to deal with this sysctl to write into MBR.

  • This example is only related to systems with MBR partition table, not with GPT.
    – AntonioK
    Apr 9 '15 at 7:43
  • Got badblocks: Operation not permitted while trying to open /dev/ada1 running badblocks -ws -b 4096 /dev/ada1 (on FreeNAS), this solved and explained it.
    – Qtax
    Feb 2 '20 at 19:59

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.