[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Automatic LVM resizing during installation if the partitions get too full?



In Debian Edu, I've implemented code to automatically extend
partitions if they get too full during installation, to reduce the
chance of filling up the partitions during installation.  I was told
that this would be nice to have as part of the normal Debian Installer
setup, so this is an email to see if you agree with this.

The resize work is done by the debian-edu-fsautoresize script in
debian-edu-config, and the d-i part is stored in two files.  The first
is /usr/lib/base-installer.d/10debian-edu-profile-udeb and contain
this part to first make some unused space in LVM and then set up the
resize process:

# remove the debianfreespace logical volume.  Doing it before
# installing packages, to make it possible to resize volumes on the
# fly during installation.
VG=$(mount | sed -n 's@^/dev/mapper/\(.*\)-root on /target.*@\1@p')
if [ -e /dev/$VG/debianedufreespace ] ; then
    if mount | grep -q /debianedufreespace ; then
        umount /target/debianedufreespace
    fi
    lvremove -f /dev/$VG/debianedufreespace
    grep -v /debianedufreespace /target/etc/fstab > /target/etc/fstab.new && \
      mv /target/etc/fstab.new /target/etc/fstab

    rmdir /target/debianedufreespace
fi

# Expand overfull file systems during installation, until /target is umounted.
(
    # Make sure debian-edu-fsautoresize uses the same time zone as the
    # installer when running during installation (Solves Skolelinux
    # bug #1356), to avoid inconsistent time stamps in the
    # installation log.
    TZ=UTC
    export TZ

    # Workaround for in-target not accepting arguments as part of the command
    # to run.  Need to create a temporary script that can be executed without
    # arguments.  Can not create it in /target/tmp/, as it does not exist yet.
    # In Lenny, in-target handle arguments.  This workaround can be
    # removed and the code made simpler. [pere 2009-12-14]
    script=/debian-edu-extend-file-systems
    if [ ! -f $script ] ; then  # Avoid several loops running at the same time
        cat > /target$script <<EOF
#!/bin/sh
/usr/sbin/debian-edu-fsautoresize -n
EOF
        chmod a+rx /target$script
        while [ -x /target$script ]; do
            if [ -x /target/usr/sbin/debian-edu-fsautoresize ] && [ -x /target/usr/bin/perl ]; then
                # Avoid in-target, as it can not run in parallel with
                # apt-install or in-target
                chroot /target $script || true
            fi
            sleep 10
        done
        # $script is removed in finish-install.d script
    fi
    # Close as many file descriptors as possible, to reduce the chance
    # of message leaks to debconf
) < /dev/null > /dev/null 2>&1 3>&1 4>&1 5>&1 6>&1 7>&1 8>&1 9>&1 &

The second part is in
/usr/lib/finish-install.d/13debian-edu-profile-udeb and just tell the
first part to stop:

# Stop automatic lvm resize script
rm -f /target/debian-edu-extend-file-systems

Would it be useful to have something like this in the LVM part of d-i?
I doubt I have the spare time myself to integrate it, but thought it
best to bring it up here anyway. :)

Happy hacking,
-- 
Petter Reinholdtsen


Reply to: