when you mount a file as a drive as shown in Loopback_device will it expand as needed or will it only be able to store what size I make it?
Thank you for your time.
[SOLVED] Loopback Device and file expansion
[SOLVED] Loopback Device and file expansion
Last edited by kammce on Thu Apr 26, 2012 8:11 pm, edited 1 time in total.
- Kazinsal
- Member
- Posts: 559
- Joined: Wed Jul 13, 2011 7:38 pm
- Libera.chat IRC: Kazinsal
- Location: Vancouver
- Contact:
Re: Loopback Device and file expansion
It'll be what size you make it, minus whatever the filesystem you format the "disk" with takes up.
Re: Loopback Device and file expansion
Thank you for your answer!
Re: [SOLVED] Loopback Device and file expansion
The file, in its current size, will be mounted as if it were a block device.
Some emulators allow having "sparse" image files, i.e. an image of 1 GiB but being 99% unused can be only a couple of megabytes. But that is a completely different mechanism from what loopback does.
Some emulators allow having "sparse" image files, i.e. an image of 1 GiB but being 99% unused can be only a couple of megabytes. But that is a completely different mechanism from what loopback does.
Every good solution is obvious once you've found it.
- AndrewAPrice
- Member
- Posts: 2303
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: [SOLVED] Loopback Device and file expansion
Some file systems (ext3/4) have the option of supporting sparse files. That means you can write to the very last byte of the file at the size you want it to be, and it'll allocate the space of the last inode, but skip allocating the inodes where nothing has been written to (and if you read from there it'll return all 0s).
Of course, unless you have an API to differentiate between "File size" and "Size on disk" (such as Windows provides) then you have no way of finding out exactly how much space a file takes up.
Also interesting, is with sparse files, you could have a 1GB hard drive claiming to have a directory containing 1TB of files.
Alternatively, you could let your loop back device write past the end of the file and extend it - and design a file system for endless expanding mediums.
Of course, unless you have an API to differentiate between "File size" and "Size on disk" (such as Windows provides) then you have no way of finding out exactly how much space a file takes up.
Also interesting, is with sparse files, you could have a 1GB hard drive claiming to have a directory containing 1TB of files.
Alternatively, you could let your loop back device write past the end of the file and extend it - and design a file system for endless expanding mediums.
My OS is Perception.