Galactic_Dominator said:
I'm really struggling to imagine any use for a 1 GB file that accepts writes but always reads zero. Can you explain what your true goal is? Perhaps there is a better way to achieve it.
Reading the linked sparse file site more carefully, it looks like this may actually serve my needs. When I first read it, it looked like it was saying that a 16gb file of all zeros would still take up 1gb of space, but reading it again, it appears that it would take up almost no space.
I've been trying to boot a Windows slice that resides on the same disk as FreeBSD in a virtual machine running from within FreeBSD, and unfortunately, the virtual machine needs to think it has read/write access to the entire disk to do this, even though (as far as I am aware) it only uses the access to read/write to the specific partition.
Ideally, what I would do is copy the MBR to a file (and modify it appropriately), create a character device with md backed by the file, then use gconcat to glue it together with the windows slice. However, it is my understanding that Windows gets unhappy if the starting location of its slice changes, so I need to put ~100gb (1gb in the previous posts was just an example) of padding between the end of the MBR and beginning of the Windows slice that I could use with gconcat.
I wanted to have something backed by /dev/zero because it would take up no space (and it won't be written to so it doesn't need to save writes), but since it appears that sparse files also take up a negligible amount of space, they should work fine.
I'm open to other suggestions on how to accomplish this, though. Also, the virtual machine software I'm using is VirtualBox, but if anyone knows of software with better raw partition access support that runs on FreeBSD, I'd probably just use that instead.