summaryrefslogtreecommitdiffstats
path: root/rescue/restore-image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'rescue/restore-image.sh')
-rwxr-xr-xrescue/restore-image.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/rescue/restore-image.sh b/rescue/restore-image.sh
index 49d5f59c1..dfe173fa7 100755
--- a/rescue/restore-image.sh
+++ b/rescue/restore-image.sh
@@ -152,9 +152,22 @@ function expand_fs()
dialog --backtitle "$BACKTITLE" --title "$TITLE" --infobox "Installing... Finishing Install..." 3 40
disk=/dev/$root
main_part=/dev/${root}1
- sfdisk -d $disk | sed -e "\|$main_part| s/size=.*,/size= ,/" | sfdisk -f $disk
+ swap_part=/dev/${root}2
+ total_blocks=$(sfdisk -s $disk)
+ #part_sectors=$(sfdisk -d $disk | perl -lne 'm|^'$main_part'\b.*,\s*size\s*=\s*(\d+)\b| and print($1), exit')
+ #part_blocks=$((part_sectors/2))
+ SWAP_BLOCKS=150000
+ if [ -n "$SWAP_BLOCKS" ]; then
+ max_part_blocks=$((total_blocks-SWAP_BLOCKS))
+ max_part_sectors=$((max_part_blocks*2))
+ else
+ max_part_sectors=
+ fi
+ sfdisk -d $disk | sed -e "\|$main_part| s/size=.*,/size= $max_part_sectors,/" | sfdisk -f $disk
e2fsck -fy $main_part
resize2fs $main_part
+ parted $disk -- mkpartfs primary linux-swap ${max_part_sectors}s -1s yes
+ mkswap -L swap $swap_part
fi
}