[arch-releng] [PATCH 1/1] double file size with sparse blocks

Gerardo Exequiel Pozzi vmlinuz386 at yahoo.com.ar
Thu Mar 20 18:36:10 EDT 2014


On 03/20/2014 05:24 AM, Christian Hesse wrote:
> Gerardo Exequiel Pozzi <vmlinuz386 at yahoo.com.ar> on Wed, 2014/03/19 22:21:
>> On 01/11/2014 08:35 AM, Christian Hesse wrote:
>>> Gerardo Exequiel Pozzi <vmlinuz386 at yahoo.com.ar> on Fri, 2014/01/10 23:53:
>>>> On 01/10/2014 11:47 PM, Gerardo Exequiel Pozzi wrote:
>>>>> On 01/09/2014 05:49 AM, Christian Hesse wrote:
>>>>>> Christian Hesse <list at eworm.de> on Mon, 2013/09/02 10:03:
>>>>>>> From: Christian Hesse <mail at eworm.de>
>>>>>>>
>>>>>>> This allows to grow the filesystem after system boot up. We have no
>>>>>>> additional cost as squashfs handles sparse files.
>>>>>>> ---
>>>>>>>  archiso/mkarchiso | 2 ++
>>>>>>>  1 file changed, 2 insertions(+)
>>>>>>>
>>>>>>> diff --git a/archiso/mkarchiso b/archiso/mkarchiso
>>>>>>> index 8f9ed42..563f624 100755
>>>>>>> --- a/archiso/mkarchiso
>>>>>>> +++ b/archiso/mkarchiso
>>>>>>> @@ -364,6 +364,8 @@ _mkfs () {
>>>>>>>      cp -aT "${_fs_src}/" "${work_dir}/mnt/${_src}/"
>>>>>>>      _msg_info "Done!"
>>>>>>>      _umount_fs "${work_dir}/mnt/${_src}"
>>>>>>> +    # double size with sparse blocks, will allow to grow the
>>>>>>> filesystem
>>>>>>> +    truncate -s$((_fs_size*2))M "${_fs_img}"
>>>>>>>  }
>>>>>>>  
>>>>>>>  command_checksum () {
>>>>>>
>>>>>> Currently I am maintaining this in a local package for myself. Any
>>>>>> chance to get this merged upstream?
>>>>>>
>>>>>
>>>>> No. This is a special case. If root-image.fs.sfs is copied to a
>>>>> filesystems that does not support sparse files (FAT commonly for
>>>>> USB-keys), this is waste of free space.
>>>>>
>>>>
>>>> brb, ignore me!! truncate is on root-image.fs not root-images.fs.sfs :P
>>>>
>>>> Yes, this can be safe by default and can be included for next release :)
>>>
>>> Great, thanks!
>>>
>>
>> I am still not changing this because, I am thinking in a different way
>> to do this, in a more "systemd-friendly-way" (because currently I need
>> to mount the squashfs, then fetch the size in blocks of the file inside
>> it...).
>> This is, for all cases, create a fixed size of the filesystem, (i.e 4G
>> or 8G), the overhead is minimal, really :)
>>
>>
>> $ truncate -s 1G coco.fs
>> $ mkfs.ext4 -q -O ^has_journal -E lazy_itable_init=0 -m 0 -F coco.fs
>> $ du -h coco.fs
>> 408K    coco.fs
>> $ truncate -s 16G pepe.fs
>> $ mkfs.ext4 -q -O ^has_journal -E lazy_itable_init=0 -m 0 -F pepe.fs
>> $ du -h pepe.fs
>> 4.3M    pepe.fs
> 
> Not sure if I got you right... With this solution you want the filesystem to
> always fill the whole file? Where is the size specified?
> 

Yes, just like now. The diference is, while now the size is specified at
aitab file using a percent of free space you want, I am now thinking in
always using a know big size for total space, since the basic structure
of a filesystem is small.

In this way I can write systemd.units with fixed values.

> I wonder why you need the filesystem size in a systemd setup. What is it good
> for?

Because this is what is done in archiso hook in the most basic boot:
(if you just copy and paste this in a new "archiso" hook, system will
boot fine)

mkdir -p /run/archiso/bootmnt
mount -r /dev/disk/by-label/ARCH_201403 /run/archiso/bootmnt
mkdir -p /run/archiso/cowspace
mount -t tmpfs -o size=75%,mode=0755 cowspace /run/archiso/cowspace
mkdir -p /run/archiso/cowspace/persistent_ARCH_201403/x86_64
losetup --find --read-only
/run/archiso/bootmnt/arch/x86_64/root-image.fs.sfs
mkdir -p /run/archiso/sfs/root-image
mount -r /dev/loop0 /run/archiso/sfs/root-image
losetup --find --read-only /run/archiso/sfs/root-image/root-image.fs
#blockdev --getsz /dev/loop1 # -> in my case says: 2080768 and is used
below
dd of=/run/archiso/cowspace/persistent_ARCH_201403/x86_64/root-image.cow
count=0 seek=2080768
losetup --find
/run/archiso/cowspace/persistent_ARCH_201403/x86_64/root-image.cow
dmsetup create arch_root-image --table "0 2080768 snapshot /dev/loop1
/dev/loop2 N 8"
mkdir -p /new_root
mount -w /dev/mapper/arch_root-image /new_root


> 
> You could create a filesystem that fits the needed size, truncate the
> file and have a fixed size nevertheless.
> 
> $ _fs_size=1024
> $ truncate -s ${_fs_size}M coco.fs
> $ mkfs.ext4 -q -O ^has_journal -E lazy_itable_init=0 -m 0 -F coco.fs
> $ du -h coco.fs
> 408K    coco.fs
> $ truncate -s 16G coco.fs
> $ du -h coco.fs
> 408K    coco.fs
> 
> And optionally later in live environment:
> 
> $ resize2fs coco.fs
> $ du -h coco.fs
> 4.3M    coco.fs
> 

As I said before, we can just create big FS without significant overhead.


-- 
Gerardo Exequiel Pozzi
\cos^2\alpha + \sin^2\alpha = 1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-releng/attachments/20140320/b5e0c38b/attachment.asc>


More information about the arch-releng mailing list