4 # Provides: FixPartitionTable
5 # RunBefore: FilesystemResizeUnmounted
6 # Short-Description: Resize filesystem to use all the available space
10 . "@commondir@/common.sh"
12 if [ ! -b "$SNF_IMAGE_DEV" ]; then
13 log_error "Device file:\`${SNF_IMAGE_DEV}' is not a block device"
16 if [ $(get_partition_count "$SNF_IMAGE_DEV") -eq 0 ]; then
17 log_error "Device: \`${SNF_IMAGE_DEV}' does not contain any partition"
20 retval=$(get_last_partition "$SNF_IMAGE_DEV")
22 id=$(echo $retval | cut -d: -f1)
23 pstart=$(echo $retval | cut -d: -f2)
24 pend=$(echo $retval | cut -d: -f3)
25 ptype=$(echo $retval | cut -d: -f5)
27 if [ $id -gt 4 ]; then
28 log_error "We don't support logical volumes"
31 if [ x"$ptype" = "x" ]; then
32 # Don't know how to handle this
33 warn "Last partition with id: \`$id' is empty or has unknown filesystem"
34 warn "I won't resize the partition"
38 new_pend=$(get_last_free_sector "$SNF_IMAGE_DEV")
40 if [ -z "$new_pend" ] ; then
45 # Extend the partition
47 $PARTED -s -m "$SNF_IMAGE_DEV" rm "$id"
48 $PARTED -s -m "$SNF_IMAGE_DEV" mkpart primary "$ptype" "$pstart" "$new_pend"
50 # Inform the kernel about the changes
51 partprobe "$SNF_IMAGE_DEV"
55 # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :