Booting Linux in single-user mode

In order to perform some partition rework on my main Debian box, I needed to boot the machine in single user mode. However, Debian's view of what single-user mode is, is, well, not mine. My expectation was formed by FreeBSD, in that single-user mode would leave me at a shell prompt, with no daemons running and no filesystems mounted (save root).

Debian's single user mode mounts all the disk partitions and starts the system daemons. However, no applications are started and no other users are allowed to login. While I know I can edit the partition table with fdisk while the system is active, I didn't feel comfortable in doing so. How could I get Debian into a more FreeBSDish single-user state?

It's not too hard. First, add init=/bin/sh to the kernel boot line (this is easier with grub as it allows you to edit the boot commands). The init option will cause the kernel to invoke /bin/sh rather than init when it hands over control to user-land. At this point, you will be faced with a naked bash prompt, at which you need to enter:

  mount -o remount,rw /

This will cause the root partition to be remounted in read/write mode, so that the files can be modified (/etc/fstab in my case). If you need to mount other filesystems at this point, you can do it with:

  # mount and preen all filesystems
  fsck -ARp # I think; this has not been tested.

Once your modifications are complete, you can halt or reboot the system with:

  sync;sync;sync;sync
  halt -f  # or, reboot -f