Forest OS

A free and open source operating system, written from scratch. A Bluethefox project, hosted by Enclica.

← Back to Wiki

Remove / Uninstall Forest OS

How to remove Forest OS from an internal disk or USB stick and return the disk to normal use (Windows/Linux/other OS, or a plain FAT32 stick).

Related: Install on Real Hardware for how Forest OS got onto the disk, UEFI Boot and BIOS Boot for the boot pieces you are removing, Disk Tools for dd / fdisk / mkfs reference.

0. Back up first — there is no undo

Warning: every step below destroys data on the target disk. There is no undo for dd, fdisk delete/write, fixmbr, or mkfs. Copy what you want to keep before you start.

  1. Boot Forest OS (or any live Linux) and mount the partitions you care about:
    fdisk -l
    blkid
    mkdir -p /mnt/root /mnt/data
    mount -t ext2 /dev/sdY1 /mnt/root
    mount -t vfat /dev/sdY2 /mnt/data   # if present
  2. Copy /home, /etc (users, fstab, forebo.cfg edits), and any data partition contents to another disk:
    cp -r /mnt/root/home /backup/home
    cp -r /mnt/data /backup/forest-data
  3. If you plan to restore the old MBR, back it up now (before overwriting):
    dd if=/dev/sdY of=mbr-backup.bin bs=512 count=1
    # store mbr-backup.bin off-disk (another USB / network share)
    Replace /dev/sdY with the actual Forest OS disk from fdisk -l (size/model tells the installer USB apart from the internal disk).

Do not continue until your backups are on a different physical disk and verify they list correctly (ls /backup).

1. Restore the MBR (BIOS / Legacy boot)

Forest OS on BIOS installs occupies sector 0 (stage1 + partition table + 0xAA55) plus stages at sectors 1–38 and the kernel at sector 54+. Removing it means putting a standard MBR back.

1a. Linux — restore a saved MBR backup

Warning: dd with of= pointing at the wrong disk wipes that disk. Triple-check with lsblk -d -o NAME,SIZE,MODEL,TRAN and fdisk -l /dev/sdY before every write.

# sdY = the disk Forest OS is on. NOT a partition (sdY1), the whole disk (sdY).
lsblk -d -o NAME,SIZE,MODEL,TRAN
sudo fdisk -l /dev/sdY

# Restore only the 446-byte bootloader area, keep the current partition table:
sudo dd if=mbr-backup.bin of=/dev/sdY bs=446 count=1 oflag=sync
sync

# Or restore the full 512-byte sector (bootloader + partition table + 55aa)
# ONLY if the backup is from the layout you want back:
sudo dd if=mbr-backup.bin of=/dev/sdY bs=512 count=1 oflag=sync
sync

# Verify:
sudo dd if=/dev/sdY bs=512 count=1 2>/dev/null | xxd -s 510 -l 2
# expect: 55aa (valid MBR signature, whatever OS owns it now)
sudo fdisk -l /dev/sdY

Use the 446-byte form when you only want the boot code gone but want to keep the existing partitions. Use the 512-byte form only to roll the whole sector back to a pre-Forest backup.

No backup? Zero just the boot-code area instead (keeps partition table), then let Windows/Linux repair tools rewrite it:

# Clears bytes 0-445 (boot code), preserves partition table 446-511.
sudo dd if=/dev/zero of=/dev/sdY bs=446 count=1 oflag=sync
sync

1b. Windows — fixmbr / bootrec

Warning: pick the correct physical disk in diskpart / recovery. Fixing the wrong disk makes it unbootable until repaired again.

  1. Boot Windows install / recovery media → Repair → Command Prompt.
  2. Rewrite the MBR boot code:
    bootrec /fixmbr
    bootrec /fixboot
    bootrec /scanos
    bootrec /rebuildbcd
    On older BIOS Windows (XP recovery console): fixmbr, then fixboot.
  3. Reboot without the Forest USB. Windows (or your remaining bootloader) should load. If it drops to firmware, re-run bootrec /rebuildbcd and check boot order.

After either path, the ForeB stage1 is gone from sector 0. Stages 2/3 (sectors 1–38) and the kernel (sector 54+) are inert leftovers until you delete/reformat per §2 — they no longer execute.

2. Delete Forest partitions (fdisk)

Warning: deleting a partition destroys its filesystem label and makes recovery hard. Confirm the partition number, type, and size in fdisk -l output before deleting. Unplug every disk except the target + rescue media if you are unsure.

Forest layouts you may see:

PartitionTypeOrigin
ext2 root (/, type 0x83)Forest full installinstaller, sector 63+
FAT32 FOREST-DATA (type 0x0C)persistent USB datasee USB Persistence
FAT ESP (EFI System Partition)UEFI boot (EFI/BOOT/BOOTX64.EFI, forebo/)see ISO Creation
swapoptional manual installinstaller manual mode

Delete them with host fdisk (Linux live USB, or Forest fdisk to inspect):

lsblk
sudo fdisk -l /dev/sdY      # note which pN is Forest (size + type)

sudo fdisk /dev/sdY
# inside fdisk:
#   p          print table, confirm sdY is the Forest disk
#   d          delete a partition (repeat for each Forest partition)
#   p          confirm the table looks right
#   w          write and exit (nothing changes until you press w)

d + w only edits the table; the old sectors are still there until overwritten/reformatted, which is what §3 does.

3. Reclaim the space

Warning: formatting (mkfs) destroys everything on that partition. Double-check /dev/sdYN (partition) vs /dev/sdY (whole disk) — formatting the wrong one wipes the wrong filesystem.

Pick one:

  • Give space back to an existing OS: boot that OS's installer / disk manager (Windows Disk Management, gparted, fdisk + mkfs) and either extend the neighboring partition into the freed space or create a new partition there. No Forest command needed.
  • Create a fresh data partition from Linux:
    # Example: one new partition in the freed space, then format it.
    sudo fdisk /dev/sdY
    #   n  new partition, accept defaults for start/end (uses free space)
    #   w  write
    
    # FAT32 for a shared/data partition (Forest + Linux + Windows readable):
    sudo mkfs.vfat -F 32 -n DATA /dev/sdYN
    # Forest equivalent (fat32 + ext2 only):
    mkfs -t fat32 -L DATA /dev/sdYN
    
    # ext2 for a Linux-only partition:
    mkfs -t ext2 -L LINUX-DATA /dev/sdYN
    
    blkid /dev/sdYN
    fsck -n /dev/sdYN
  • Hand the whole disk to another OS installer: just leave the freed space unallocated — Windows/Linux installers offer "use unallocated space" directly.

Verify with fdisk -l /dev/sdY and blkid: no 0x83 Forest root, no FOREST-DATA, and sizes match what you expect.

4. Remove the UEFI boot entry (ESP file + NVRAM)

Skip this section on BIOS-only machines. On UEFI, Forest may exist in two places: files on the ESP and a firmware NVRAM boot entry. Remove both.

4a. Delete the ESP files

Warning: the ESP is shared with other OSes. Delete only the Forest directory/files, never format the whole ESP unless the disk is yours alone.

# Identify the ESP (FAT, ~48-550 MiB, type EF00 / "EFI System"):
lsblk -f
sudo fdisk -l /dev/sdY
sudo blkid | grep -i vfat

mkdir -p /mnt/esp
sudo mount /dev/sdYN /mnt/esp     # sdYN = the ESP partition
ls /mnt/esp/EFI/BOOT/
ls /mnt/esp/forebo/

# Remove Forest loader + kernel/config (keeps Microsoft/Boot dirs intact):
sudo rm -rf /mnt/esp/forebo
sudo rm -f /mnt/esp/EFI/BOOT/BOOTX64.EFI
# Only if BOOTX64.EFI was Forest's copy and nothing else uses it.
# If Windows Boot Manager lives in EFI/Microsoft, leave EFI/Microsoft alone.

sync
sudo umount /mnt/esp

If the machine booted Forest via \EFI\BOOT\BOOTX64.EFI fallback only (no NVRAM entry), deleting these files is the complete UEFI removal.

4b. Delete the NVRAM boot entry

Warning: efibootmgr -b NNNN -B deletes a firmware boot entry immediately. Deleting the wrong number removes another OS's entry (re-add it with your OS installer / efibootmgr -c). List twice before deleting.

# From Linux (efibootmgr package) on the UEFI machine:
efibootmgr -v
# Example output:
# Boot0001* Forest OS  HD(...)/File(\EFI\BOOT\BOOTX64.EFI)
# Boot0000* Windows Boot Manager  HD(...)/File(\EFI\Microsoft\Boot\bootmgfw.efi)

# Delete ONLY the Forest entry number:
sudo efibootmgr -b 0001 -B

# Confirm, and fix order so the wanted OS is first:
efibootmgr -v
sudo efibootmgr -o 0000

Alternative without Linux: enter firmware setup (Del/F2/F10) → Boot section → delete the Forest OS / BOOTX64.EFI-on-that-disk entry, and move your remaining OS to first priority. Re-enable Secure Boot if you had disabled it for Forest (see Install on Real Hardware §2) — unsigned-loader machines can turn it back on now.

5. Reuse the USB stick as a normal stick

Warning: this erases the entire stick — live image, persistence partition, full-install root, everything. Confirm the stick device with lsblk (size/model) so you do not wipe the internal disk.

Forest USBs are raw sector installs (MBR stages + kernel sectors + ext2/FAT partitions), so normal file-delete is not enough — rewrite the front and reformat:

# sdX = the USB STICK (whole disk, e.g. /dev/sdb). NOT sda, NOT sdX1.
lsblk -d -o NAME,SIZE,MODEL,TRAN
sudo umount /dev/sdX* 2>/dev/null; true

# 1. Wipe the ForeB front (MBR + stages + kernel area, first ~16 MiB):
sudo dd if=/dev/zero of=/dev/sdX bs=1M count=16 oflag=sync
sync

# 2. Fresh MBR table + one FAT32 partition for normal use:
sudo fdisk /dev/sdX
#   o          new empty DOS partition table (discards Forest table)
#   n p 1      new primary partition 1, accept defaults (whole stick)
#   t c        type c (W95 FAT32 LBA) — or 0c
#   a          toggle bootable off (no boot flag needed for a data stick)
#   p          confirm one partition covering the stick
#   w          write

sudo mkfs.vfat -F 32 -n USB /dev/sdX1
# Forest-side equivalent if no host mkfs.vfat: mkfs -t fat32 -L USB /dev/sdX1

# 3. Verify it is a plain data stick:
sudo fdisk -l /dev/sdX
sudo blkid /dev/sdX1

Unplug/replug: the stick should appear as one empty FAT32 volume on Linux/Windows/macOS. Copy a test file, unmount, remount, and confirm it is there — that proves no Forest sector layout remains.

Further reading

← Back to Wiki