]> gitweb.fluxo.info Git - hydra.git/commitdiff
Size of swap partition; option to create lv with all available space
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 29 Jan 2013 01:11:46 +0000 (23:11 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 29 Jan 2013 01:11:46 +0000 (23:11 -0200)
share/hydractl/provision

index 51ed478c4fcbfecac1c7caff7bc14f804350a273..8ef4319a362b1e63888b102752daa021d3824beb 100755 (executable)
@@ -24,6 +24,7 @@ hydra_config_load
 function hydra_lvcreate {
   local volume="$1"
   local size="$2"
+  local space
 
   if [ -z "$volume" ] || [ "$size" == "0" ]; then
     return
@@ -34,7 +35,14 @@ function hydra_lvcreate {
     # 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
 }
 
@@ -69,8 +77,8 @@ function hydra_create_volume {
 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"
@@ -95,10 +103,12 @@ read answer
 
 # 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