Page MenuHomePhabricator
Paste P11300

reuse-parts.sh
ArchivedPublic

Authored by Kormat on May 25 2020, 3:09 PM.
Project Tags
None
Referenced Files
F31844338: raw.txt
May 27 2020, 3:22 PM
F31841657: raw.txt
May 25 2020, 3:09 PM
Subscribers
None
#!/bin/sh
[ -e /tmp/reuse ] && exit 0;
touch /tmp/reuse
#export DEBIAN_FRONTEND=noninteractive
. /lib/partman/lib/base.sh
. /lib/partman/lib/recipes.sh
log() {
logger -t reuse "$@"
}
[ $(debconf-get partman-auto/method) = "reuse" ] || { log "Skipping, partman-auto/method != reuse"; exit 0; }
disk=$(debconf-get partman-auto/disk)
log "Disk: $disk"
dev="$DEVICES/$(echo $disk | sed 's:/:=:g')"
cd $dev || { log "ERROR: $disk doesn't exist"; exit 1; }
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
case "$num" in
1)
log "====> Reuse / partition (with format)"
[ "$fs" = "ext4" ] || { log "ERROR: expected fs ext4 for partition $num, got $fs instead"; break; }
echo format > $id/method
touch $id/format
touch $id/use_filesystem
echo "$fs" > $id/filesystem
mkdir -p $id/options
echo / > $id/mountpoint
touch $id/existing
touch $id/formatable
;;
esac
done
close_dialog
cd "$DEVICES"/=dev=mapper=* || { log "ERROR: wrong number of lvm logical volumes found: $(echo "$DEVICES"/=dev=mapper=*)"; exit 1; }
log "====> Reuse /srv lvm partition (retain data)"
open_dialog PARTITIONS
read_line num id size type fs path name
[ "$fs" = "xfs" ] || { log "ERROR: expected fs xfs for partition $num, got $fs instead"; break; }
echo keep > $id/method
touch $id/existing
echo "$fs" > $id/filesystem
echo /srv > $id/mountpoint
mkdir -p $id/options
touch $id/use_filesystem
close_dialog
log "Running update_all"
update_all
log "update_all result: $?"

Event Timeline

Requirements:

  • This script needs to be installed as /lib/partman/display.d/70reuse-parts within the running installer, and made executable.
    • partman/early_command is the simplest way to do this.
  • d-i partman-auto/method string reuse