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)
24 if [ $id -gt 4 ]; then
25 log_error "We don't support logical volumes"
28 pstart=$(echo $retval | cut -d: -f2)
29 pend=$(echo $retval | cut -d: -f3)
30 ptype=$(echo $retval | cut -d: -f5)
32 if [ x"$ptype" = "x" ]; then
33 # Don't know how to handle this
34 echo "Warning: Last partition with id: \`$id' is empty" \
35 "or has unknown filesystem"
40 new_pend=$(get_last_free_sector "$SNF_IMAGE_DEV")
44 $PARTED -s -m "$SNF_IMAGE_DEV" rm $id
45 $PARTED -s -m "$SNF_IMAGE_DEV" mkpart primary "$ptype" "$pstart" "$new_pend"
47 #inform the kernel about the changes
48 partprobe "$SNF_IMAGE_DEV"
52 # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :