Skip to content

Commit

Permalink
coreos-growpart: fix handling of fs in kpartx on multipath
Browse files Browse the repository at this point in the history
The idea is to call growpart with a naming scheme that allows it to work
with its internal assumptions about a device name concatenated with a
parition number (potentially with a separator string such as 'p' inbetween).

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
  • Loading branch information
steffen-maier committed Mar 11, 2020
1 parent d8b5921 commit 67716fd
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@ shift
src=$(findmnt -nvr -o SOURCE "$path" | tail -n1)
majmin=$(findmnt -nvr -o MAJ:MIN "$path" | tail -n1)
devpath=$(realpath "/sys/dev/block/$majmin")
partition=$(cat "$devpath/partition")
parent_path=$(dirname "$devpath")
parent_device=/dev/$(basename "${parent_path}")
devname=${devpath##*/}

if [[ "${devname:0:3}" = "dm-" ]]; then
# we assume and only support file system in kpartx partition on
# device-mapper multipath device
dmname=$(cat "$devpath/dm/name")
partition=$(echo "$dmname" | sed 's/^.*[^[:digit:]]\([[:digit:]\+]\)$/\1/')
parent_dmdev=$(ls "$devpath/slaves/")
parent_device=/dev/mapper/$(cat "/sys/block/$parent_dmdev/dm/name")
else
partition=$(cat "$devpath/partition")
parent_path=$(dirname "$devpath")
parent_device=/dev/$(basename "${parent_path}")
fi


# TODO: make this idempotent, and don't error out if
# we can't resize.
Expand Down

0 comments on commit 67716fd

Please sign in to comment.