function hydra_lvcreate {
local volume="$1"
local size="$2"
+ local space
if [ -z "$volume" ] || [ "$size" == "0" ]; then
return
# See http://forums.funtoo.org/viewtopic.php?id=1206
# https://bbs.archlinux.org/viewtopic.php?id=124615
#hydra_safe_run lvcreate -Z n -L$size -n $volume $vg
- hydra_safe_run lvcreate -L$size -n $volume $vg
+
+ if [ "$size" == "-1" ]; then
+ space="-l %FREE"
+ else
+ space="-L $size"
+ fi
+
+ hydra_safe_run lvcreate $space -n $volume $vg
fi
}
hydra_user_input device /dev/sdb "Destination device"
hydra_user_input root_size 20G "Size of root partition"
hydra_user_input swap y "Use swap? (y/n)"
-hydra_user_input home_size 0 "Size of home partition (0 to not create it)"
-hydra_user_input var_size 0 "Size of var partition (0 to not create it)"
+hydra_user_input home_size 0 "Size of home partition (0 to not create it, -1 for all free space)"
+hydra_user_input var_size 0 "Size of var partition (0 to not create it, -1 for all free space)"
hydra_user_input encrypt y "Encrypt volumes? (y/n)"
hydra_user_input garbage y "Pre-fill volumes with garbage? (y/n)"
hydra_user_input hostname $HOSTNAME "Hostname"
# Disk partitioning.
if [ "$swap" == "y" ]; then
+ hydra_user_input swap_size 2000 "Swap size (MB)"
+ boot_end=$(($swap_size + 200))
hydra_safe_run parted -s -- $device mklabel msdos
- hydra_safe_run parted -s -- $device unit MB mkpart primary linux-swap 2 2000
- hydra_safe_run parted -s -- $device unit MB mkpart primary ext2 2000 2200
- hydra_safe_run parted -s -- $device unit MB mkpart primary ext2 2200 -1
+ hydra_safe_run parted -s -- $device unit MB mkpart primary linux-swap 2 $swap_size
+ hydra_safe_run parted -s -- $device unit MB mkpart primary ext2 $swap_size $boot_end
+ hydra_safe_run parted -s -- $device unit MB mkpart primary ext2 $boot_end -1
hydra_safe_run parted -s -- $device set 2 boot on
hydra_safe_run parted -s -- $device set 3 lvm on