You can’t format an LXC rootfs like a VM disk. It’s a mounted volume or ZFS dataset, not a block device. Stop trying to mkfs it — reset the container instead.

Why mkfs Fails on an LXC Rootfs
Proxmox stores LXC rootfs on directory storage, ZFS, LVM-thin, or BTRFS. In every case, the rootfs is a directory or dataset mounted into the container. It’s not /dev/sdX. Running mkfs on it either fails with “device is mounted” or corrupts the host filesystem. That’s a bad day.
Option 1: Destroy and Recreate the Container
If you don’t need the container’s config, this is the cleanest. Back up any data first, then:
pct stop 100
pct destroy 100
pct create 100 local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst
Adjust the template path. This wipes the rootfs entirely and gives you a fresh container in seconds.

Option 2: Wipe Data from Inside the Container
If you want to keep the container’s config but reset the filesystem, just delete everything inside. Start the container and run:
pct start 100
pct exec 100 -- bash -c 'rm -rf / --one-file-system'
That’s dangerous if you have bind mounts. Use --one-file-system to avoid crossing into mounted volumes. After that, the container is empty but still configured.
Option 3: Restore from Backup
If you have a vzdump backup, restore it to a new container ID. This gives you a known-good state without touching the old one:
pct restore 101 /var/lib/vz/dump/vzdump-lxc-100-2025_06_01-12_00_00.tar.zst
Then destroy the old container once you’re happy.
My Take
For a homelab, just destroy and recreate. It’s faster than trying to surgically clean a container. If you need the same IP or config, note it down first or use a backup. Don’t overthink it. And if you’re on ZFS, you can also roll back to a snapshot — ZFS snapshots make this painless.