diff options
author | Lucas Affonso Xavier de Morais | 2014-08-11 17:00:53 +0200 |
---|---|---|
committer | Michael Pereira Neves | 2014-10-28 14:14:49 +0100 |
commit | 9793f89411092cdf1edf8fe05a7187cfe89f5329 (patch) | |
tree | 26b08e3e6ef27708ba6eeca234cd028969644734 | |
parent | [partitioner]implementing the detection of existing partitions. (diff) | |
download | tm-scripts-9793f89411092cdf1edf8fe05a7187cfe89f5329.tar.gz tm-scripts-9793f89411092cdf1edf8fe05a7187cfe89f5329.tar.xz tm-scripts-9793f89411092cdf1edf8fe05a7187cfe89f5329.zip |
[partitioner] fixing the fetch of existent GPT partitions.
-rw-r--r-- | remote/modules/partitioner/config | 6 | ||||
-rwxr-xr-x | remote/modules/partitioner/partitioner.sh | 56 |
2 files changed, 36 insertions, 26 deletions
diff --git a/remote/modules/partitioner/config b/remote/modules/partitioner/config index f2e20ca8..bf34dcca 100644 --- a/remote/modules/partitioner/config +++ b/remote/modules/partitioner/config @@ -1,8 +1,8 @@ #Partitions -#SLX_PARTITION_TYPE='GPT' -#SLX_CHOOSEN_DISK='sda' +SLX_PARTITION_TYPE='GPT' +# SLX_CHOOSEN_DISK='sda' SLX_AUTOMATIC_PARTITIONING='no' -SLX_OVERRIDE_PARTITIONS='no' +SLX_DELETE_PARTITION_TABLE='no' SLX_PARTITION_TABLE=' 44,10G,/tmp 43,10G,/boot,bootable diff --git a/remote/modules/partitioner/partitioner.sh b/remote/modules/partitioner/partitioner.sh index 05160630..5822851a 100755 --- a/remote/modules/partitioner/partitioner.sh +++ b/remote/modules/partitioner/partitioner.sh @@ -172,25 +172,29 @@ if [ $SLX_DELETE_PARTITION_TABLE = "yes" ]; then fi done sfdisk -q -f /dev/$SLX_CHOOSEN_DISK < /tmp/partitiontable.tmp > /dev/null - rm -f /tmp/partitiontable.tmp -# stopped here!!! -elif [ $(sfdisk -d /dev/$SLX_CHOOSEN_DISK | grep $SLX_CHOOSEN_DISK'1' | tr -s ' ' | cut -d ' ' -f7 | cut -d '=' -f2) = 'ee' ]; then + # rm -f /tmp/partitiontable.tmp +elif [ $(sfdisk -d /dev/$SLX_CHOOSEN_DISK 2> /dev/null | grep $SLX_CHOOSEN_DISK'1' | tr -s ' ' | cut -d ' ' -f7 | cut -d '=' -f2) = 'ee' ]; then + # finding existent partitions in GPT - for PART in $PARTS; do - for (( i = 1; i < $(($COUNTER-1)); i++ )); do - if [ $i -ne 4 ]; then - if [ ${PARTTBL["$SLX_CHOOSEN_DISK$i/exists?"]} -ne 1 ]; then - sgdisk /dev/$SLX_CHOOSEN_DISK -i $i | grep "unique GUID" | cut -d ' ' -f4 | grep '${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}000000-0000-0000-0000-000000000000' - if [ $? -eq 0 ]; then - echo "the partition $PART is the ${PARTTBL["$SLX_CHOOSEN_DISK$i/mountpoint"]} partition." - PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/exists?"]=1 - break; - fi - fi + echo 'GPT' + PARTS=$(cat $PARTITIONSPATH | grep -e $SLX_CHOOSEN_DISK[0-9] | tr -s ' ' | cut -d ' ' -f5) # this line fix the empty PARTS error, continue from here + echo $PARTS + for PART in $PARTS; do + for (( i = 1; i < $(($COUNTER-1)); i++ )); do + if [ $i -ne 4 ]; then + if [ ${PARTTBL["$SLX_CHOOSEN_DISK$i/exists?"]} -ne 1 ]; then + echo "sgdisk /dev/$SLX_CHOOSEN_DISK -i $i | grep \"unique GUID\" | cut -d ' ' -f4 | grep '${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}000000-0000-0000-0000-000000000000'" + sgdisk /dev/$SLX_CHOOSEN_DISK -i $i | grep "unique GUID" | cut -d ' ' -f4 | grep '${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}000000-0000-0000-0000-000000000000' + if [ $? -eq 0 ]; then + echo "the partition $PART is the ${PARTTBL["$SLX_CHOOSEN_DISK$i/mountpoint"]} partition." + PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/exists?"]=1 + echo 'boa tarde1' fi - i=$(($i+1)) - done - done + fi + fi + i=$(($i+1)) + done + done else # finding existent partitions in MS-DOS for PART in $PARTS; do @@ -208,12 +212,18 @@ else fi DIALOGSTR="New partitions created:\n\n" -if [ $SLX_PARTITION_TYPE = GPT ]; then - sgdisk -g /dev/$SLX_CHOOSEN_DISK\ - -t 1:"$SCRATCHID"000000-0000-0000-0000-000000000000\ - -t 2:"$HOMEID"000000-0000-0000-0000-000000000000\ - -t 3:"$DNBD3ID"000000-0000-0000-0000-000000000000\ - -t 4:"$BOOTID"000000-0000-0000-0000-000000000000 > /dev/null +echo "SLX_PARTITION_TYPE = "$SLX_PARTITION_TYPE +if [ $SLX_PARTITION_TYPE = 'GPT' ]; then + # create the command that will convert the MSDOS type to GPT and change the unique GUIDs + CMD="sgdisk -g /dev/$SLX_CHOOSEN_DISK" + for (( i = 1; i < $COUNTER; i++ )); do + if [ $i -ne 4 ]; then + CMD=$CMD" -u "$i":"${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}"000000-0000-0000-0000-000000000000" + CMD=$CMD" -c "$i":\""${PARTTBL["$SLX_CHOOSEN_DISK$i/mountpoint"]}"\"" + fi + done + CMD=$CMD" > /dev/null" + $CMD for (( i = 1; i < $COUNTER; i++ )); do if [ $i -ne 4 ]; then |