[arch-releng] [PATCH 1/1] allow to grow devices

Christian Hesse list at eworm.de
Fri Aug 30 05:12:23 EDT 2013


Gerardo Exequiel Pozzi <vmlinuz386 at yahoo.com.ar> on Thu, 2013/08/29 20:01:
> On 08/29/2013 07:31 PM, Gerardo Exequiel Pozzi wrote:
> > On 08/29/2013 10:55 AM, Christian Hesse wrote:
> >> From: Christian Hesse <mail at eworm.de>
> >>
> >> actually cowfile_size is limited to values smaller or equal to 100. That
> >> way you have to decide at iso build time what size your filesystems
> >> should have.
> >>
> >> I have added a feature to allow values bigger than 100: In this case the
> >> read only device is linearly assembled with a sparse file (we do not have
> >> to care about size on disk as no write go to this file), this device is
> >> used for read only device then. After chroot (or when the system has
> >> bootet up) you can grow your filesystem to the new size.
> >>
> >> Growing the filesystem in initramfs would be possible, but we would have
> >> to add userspace utilities (resize2fs, xfs_growfs, ...) there...
> >> ---
> >>  archiso/initcpio/hooks/archiso | 17 ++++++++++++++++-
> >>  1 file changed, 16 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/archiso/initcpio/hooks/archiso
> >> b/archiso/initcpio/hooks/archiso index 66a6273..94d5a99 100644
> >> --- a/archiso/initcpio/hooks/archiso
> >> +++ b/archiso/initcpio/hooks/archiso
> >> @@ -6,13 +6,28 @@ _mnt_fs() {
> >>      local img_fullname="${img##*/}";
> >>      local img_name="${img_fullname%%.*}"
> >>      local dm_snap_name="${dm_snap_prefix}_${img_name}"
> >> -    local ro_dev ro_dev_size rw_dev
> >> +    local ro_dev ro_dev_size rw_dev rw_dev_size pad_dev pad_dev_size
> >>  
> >>      ro_dev=$(losetup --find --show --read-only "${img}")
> >>      echo ${ro_dev} >> /run/archiso/used_block_devices
> >>      ro_dev_size=$(blockdev --getsz ${ro_dev})
> >> +
> >>      if [[ "${cowfile_size}" == "100" ]]; then
> >>          rw_dev_size=${ro_dev_size}
> >> +    elif [[ "${cowfile_size}" -gt 100 ]]; then
> >> +        pad_dev_size=$((ro_dev_size/100*cowfile_size - ro_dev_size))
> >> +        dd of="/run/archiso/cowspace/${cow_directory}/${img_name}.pad"
> >> count=0 seek=${pad_dev_size} &> /dev/null
> >> +        pad_dev=$(losetup --find --show --read-only
> >> "/run/archiso/cowspace/${cow_directory}/${img_name}.pad")
> >> +        echo ${pad_dev} >> /run/archiso/used_block_devices
> >> +        # this is just a sparse file that never gets written to, so
> >> just delete it
> >> +        rm "/run/archiso/cowspace/${cow_directory}/${img_name}.pad"
> >> +        echo -e "0 ${ro_dev_size} linear ${ro_dev} 0\n${ro_dev_size}
> >> ${pad_dev_size} linear ${pad_dev} 0" | dmsetup create
> >> "ro_${dm_snap_name}" +
> >> +        ro_dev="/dev/mapper/ro_${dm_snap_name}"
> >> +        ro_dev_size="$((ro_dev_size + pad_dev_size))"
> >> +        rw_dev_size="${ro_dev_size}"
> >> +
> >> +        msg ":: Device ${dm_snap_name} has been grown, remember to grow
> >> your filesystem!" else
> >>          # size calculation done in this way to avoid integer overflow
> >> when ro_dev_size is > 10.2G rw_dev_size=$((ro_dev_size/100*cowfile_size))
> >>
> > 
> > Too much complex, and some sematics broken (for example, you are mixing
> > terms for setting non-cowdevices or storing non-cow file inside
> > cowspace, missing proper device shutdown, ...)
> > 
> > Why not just use a value above 100%? ;)
> > 
> > Thanks for your interest on improving archiso :)
> > 
> 
> Ignore me, was a bad smart answer, since you want to increse the size of
> the device!
> 
> In any case, the semantics of cowfile_size should not be changed. You
> can add another parameter like grow_ro_dev_size=,

I add a use case for what was completely useless before. (In fact the cow
files got bigger, but the resulting device size stayed the same.) Do you
really want an new parameter for that?
I do not mind, I can change that if desired.

> also should be ensure
> the proper device shutdown and persistence.

systemd should disassemble the devices, no? What is needed more?

And what do you refer with persistance? Everything should work just fine
given a persistant system is booted with the same parameters.

> We are reaching 3.11 and still no "overlayfs" :( (was promised for 3.10,
> 3.2, ...)

Well, yes...
On the other hand I really like the idea to solve this with device mapper. ;)

Just thinking about how to integrate the userspace tools and handling for
this. I would like to add a new hook that adds the binary files (resize2fs,
xfs_growfs, btrfs), so anybody can decide whether or not to include.
But where do we call this?
-- 
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Chris           get my mail address:    */=0;b=c[a++];)
putchar(b-1/(/*               gcc -o sig sig.c && ./sig    */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://mailman.archlinux.org/pipermail/arch-releng/attachments/20130830/a2ba044f/attachment.asc>


More information about the arch-releng mailing list