Wipe linux system remotely to make it unbootable

How would you remotely wipe a linux system so that on the next boot it will not attempt to boot from the hard drive, instead it will prefer booting from the network?

Reasoning

I am setting up an environment where servers will pxe boot. I have one working example, however it installs the OS to the drive. When I want to run another test, I need to walk over to the machine, restart it, and boot off of a live disk and format the drive. On the next boot it will attempt to network boot again.

What I've tried

I am able to ssh to the machine, and have tried the following:

  • fdisk
  • rm -rf / --no-preserve-root

Both fail because the device is in use. I've tried to unmount the device with no luck.

  • umount /dev/sda

Is there a way to remotely make a machine unbootable so I can more quickly test pxe configs?


Solution 1:

Have your computer's boot sequence configured as hard disk first, network second. In this case, if you erase the boot sector of your hard disk, making it unbootable, the computer will resort to PXE boot, because no valid boot devices are present.

Simply zero the beginning of the hard disk:

dd if=/dev/zero of=/dev/sda bs=512 count=1

Although, as @yagmoth555 suggested, having a DRAC or something equivalent is probably the better idea.