2016-05-02 2:44 UTC+02:00, Celelibi <celel...@gmail.com>:
> 2016-05-01 5:50 UTC+02:00, Theodore Ts'o <ty...@mit.edu>:
>> On Sun, Nov 01, 2015 at 08:41:05AM +0100, Celelibi wrote:
>>>
>>> When the file system size is not given, mke2fs determine the appropriate
>>> size by using the size of the support device. However, when the extended
>>> option "offset" is given, it doesn't seem to reduce the fs size to take
>>> the offset into account.
>>>
>>> An actual case of this bug can be when the support "device" is a regular
>>> file and the size of the file system is not given because it's the last
>>> partition in the virtual disk.
>>
>> So this is tricky.  I will grant that if this is a physical disk, and
>> you specify an offset, and mke2fs tries to figure out the size of the
>> physical disk, it shouldn't make a file system which won't work ---
>> and we know the physical device is 10M, and you have specified an
>> offset of 4M, then the file system length should be 6M or the
>> resulting file system will have some real problems.
>>
>> There are two problems with just always reducing the fs size to take
>> the offset into account.
>
> Well, this is not what I suggested. I suggested that the automatic
> determination of the filesystem size (when it's not explicit) should
> subtract the offset from the size of the device or file.

Sorry, this mail was sent unfinished by mistake.

>> No mattter what, it's going to do the wrong thing, because it can't
>> really "automatically figure out the file system size".  (For one
>> thing, mke2fs has no idea whether you are using GPT, or the FAT
>> partition table, or LVM for that matter.)

Obviously. My in my case it was only for the last partition.
I think I will (some day) make a fuse module to mount partitions as a
user and create some "virtual files" mapped to some parts of an actual
file, which would reduce the need for the -E option in mke2fs. But as
of today, specifying an offset is the only "offline" (without running
a VM) way to create a file system in a partition supported by a file.

Some methods exists to mount partitions from a "disk-file" ("raw" VM
image) but I think all of them require root privileges at some point.

>> Only if the file system size is not specified.
That's indeed the scope of my proposed improvement.

>>
>>> 2) Emit a warning when the offset option is given without a file system
>>> size and the support file is a regular file instead of a block device as
>>> it may overwrite subsequent partitions if it's not the last one.
>>
>> Sure, although I think I'll do it *all* the time.  If you are using
>> the offset, you're doing something weird, even if you are using a block
>> device.

*Especially* when using a block device. I have a use case for an
offset with a regular file, but I doubt there's a use case for block
device (although there might).


Celelibi

Reply via email to