]> gitweb.fluxo.info Git - hydra.git/commitdiff
Using parted for bootless
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 10 Apr 2012 16:04:23 +0000 (13:04 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 10 Apr 2012 16:04:23 +0000 (13:04 -0300)
share/hydra/bootless
share/hydractl/provision

index efc4b052819ba5ce18f36c6ba943608bfa2921ea..98c6d58941b0bcca780a9774c73ef30f1aca15f7 100755 (executable)
@@ -69,6 +69,8 @@ EOF
   else
     device=$1
   fi
+
+  usbdevice=`echo ${device} | sed -e s/[0-9]\$//g`
   
   # Target device consistency check
   if [ ! -b ${device} ]; then
@@ -104,6 +106,15 @@ EOF
     echo "Error: device \"${device}\" not found."
     exit 1
   fi
+
+  # Remove old partitions
+  for partition in `parted -s -- ${usbdevice} print | awk '/^ / {print $1}'`; do
+    parted -s -- ${usbdevice} rm $partition
+  done
+
+  # Create a single partition
+  parted -s -- ${usbdevice} mkpart primary ext2 0 -1
+  parted -s -- ${usbdevice} set 1 boot on
   
   # Format and mount
   $sudo mke2fs ${device}
@@ -141,7 +152,6 @@ EOF
   #quit" | grub --device-map=${devicemap} --batch
   
   # Grub 2
-  usbdevice=`echo ${device} | sed -e s/[0-9]\$//`
   $sudo grub-install --root-directory=${tmpdir} ${usbdevice} --force
   
   # Finalize
@@ -235,6 +245,11 @@ function hydra_bootless_usage {
   exit 1
 }
 
+# Check for requirements.
+for req in parted; do
+  hydra_install_package $req
+done
+
 # Parameter verification
 if [ -z "$1" ]; then
   hydra_bootless_usage
index 26abd8ef7afa053be909ba7fa93e2e1f4044d42e..3e4613441113f1e24e233efd4051852cf8d71b13 100755 (executable)
@@ -50,8 +50,8 @@ if [ "$swap" == "y" ]; then
   parted -s -- $device unit MB mkpart primary linux-swap 0     2000
   parted -s -- $device unit MB mkpart primary ext2       2000  2200
   parted -s -- $device unit MB mkpart primary ext2       2200 -1
-  parted -s -- set 2 boot on
-  parted -s -- set 3 lvm  on
+  parted -s -- $device set 2 boot on
+  parted -s -- $device set 3 lvm  on
 
   # Change devices to absolute path names.
   swap_device="$device"1
@@ -60,8 +60,8 @@ if [ "$swap" == "y" ]; then
 else
   parted -s -- $device unit MB mkpart primary ext2 0    200
   parted -s -- $device unit MB mkpart primary ext2 200 -1
-  parted -s -- set 1 boot on
-  parted -s -- set 2 lvm  on
+  parted -s -- $device set 1 boot on
+  parted -s -- $device set 2 lvm  on
 
   # Change devices to absolute path names.
   boot_device="$device"1