added make persistence script, ext3 fs
authorstack <stack@inventati.org>
Mon, 18 Mar 2013 18:05:01 +0000 (19:05 +0100)
committerstack <stack@inventati.org>
Mon, 18 Mar 2013 18:21:40 +0000 (19:21 +0100)
make-persistence.sh [new file with mode: 0755]
password [new file with mode: 0644]

diff --git a/make-persistence.sh b/make-persistence.sh
new file mode 100755 (executable)
index 0000000..533b3e7
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+if [ $# != 2 ];then
+       echo "$0, Wrong argument number"
+       echo "    launch with $0 <devicename> <binary.img>"
+       exit 1
+fi
+if [ ! -f ./password ]; then
+       echo "Create a file ./password that is needed for encrypting luks persistence"
+       exit 1
+fi
+if [ $(id -u) != 0 ];then
+       echo "Must run as root"
+       exit 1
+fi
+if [ ! -x $(which parted) ];then
+       echo "parted executable must be in search path and persmission garanted"
+       exit 1
+fi
+if [ ! -x $(which cryptsetup) ];then
+       echo "cryptsetup executable must be in search path and persmission garanted"
+       exit 1
+fi
+device=$1
+
+echo "Creating on device $device"
+sleep 3
+
+# Check for bad block on the device:
+###badblocks -c 10240 -s -w -t random -v "${devicel}" || exit 1
+
+
+# Random data on the device:
+###dd if=/dev/urandom of="${devicel}" || exit 1
+
+
+# DD THE binary.img to a usb
+#dd if=binary.img of="${device}" || exit 1
+
+# Make the partition
+img_bytes=$(stat -c %s $2)
+img_bytes=$((img_bytes+1))
+
+parted "${device}" -- mkpart primary "${img_bytes}B" -1 || exit 1
+
+# Ecnrypt partition
+cryptsetup --verbose --batch-mode luksFormat "${device}2" <<<password || exit 1
+
+# Open partition
+cryptsetup luksOpen "${device}2" my_usb <<<password || exit 1
+
+# Make FS with label: "persistence"
+mkfs.ext3 -L persistence /dev/mapper/my_usb || exit 1
+
+# Make a mount point
+if [ ! -d "/mnt/my_usb" ];then
+       mkdir -p /mnt/my_usb || exit 1
+fi
+
+# Mount the partition
+mount /dev/mapper/my_usb /mnt/my_usb/ -o noatime,nodiratime || exit 1
+
+# Make the persistence.conf file
+echo "/ union" > /mnt/persistence.conf  || exit 1
+
+# Umount
+umount /dev/mapper/my_usb || exit 1
+
+# Close LUKS
+cryptsetup luksClose /dev/mapper/my_usb || exit 1
+
+echo "All done."
diff --git a/password b/password
new file mode 100644 (file)
index 0000000..f1b4b17
--- /dev/null
+++ b/password
@@ -0,0 +1 @@
+monetine