Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing to a Windows System Partition with ntfs-3g Until Full Breaks Windows #143

Open
x-hachiroku opened this issue Feb 15, 2025 · 0 comments

Comments

@x-hachiroku
Copy link

x-hachiroku commented Feb 15, 2025

Writing to a Windows system partition using ntfs-3g until No space left on device breaks Windows upon the next boot.

This happened on a physical machine running Win11, and was successfully reproduced on a Win11 QEMU VM with the following steps:

  1. Create a Windows VM. I used a 64G qcow2 vdisk and kept the reset libvirt default. Install Windows 11 with the official image.
  2. In Windows, create a file to fill up the disk (This is only to save time and disk writes, can be omitted).
    • Check the free space with fsutil volume diskfree C:, then create a file with fsutil file createnew C:\fillup <Total free bytes>.
    • At this stage fsutil volume diskfree C: already shows a negative free bytes, and also shows 7GB of space are reserved.
      Image
  3. Shutdown the VM. Connect and mount the vdisk with qemu-nbd and ntfs-3g. My mount options are:
    /dev/nbd0p3 /mnt/tmp ntfs-3g rw,nofail,prealloc,noatime,nodiratime,uid=1000,gid=1000,fmask=0133,dmask=0022,windows_names 0 0
    
  4. Now df shows there's still 7GB Avail, which seems to be the space Windows reserved. Fill the rest of the disk with dd if=/dev/zero of=/mnt/tmp/Users/user/foo bs=1G count=100, until it fails with No space left on device.
  5. Unmount and disconnect the vdisk. Boot VM. The first boot will stuck at the spinning circle until force shutdown. Your Windows is now broken. Boot again and the Automatic Repair screen will show up.

This cannot be fixed even after the disk is freed up.

I know this seems more like a Windows bug. Nothing will happen if you free up the disk after step 4 before booting, but I think it's meaningful if we can add mount options to reserve some space like
Windows does, or warn that the system might break if you boot it right now along with the No space left on device message, or at least mention this in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant