Skip to content

Script does not support GPT tables with new fdisk version for 14.10 and above #26

@hakuna-m

Description

@hakuna-m

The output of fdisk 2.20.1 (version for 14.04) is something like this:
/dev/sda1 1 9999999999 999999999+ ee GPT

The output of fdisk 2.27.1 (version for 16.04) is something like this:

/dev/sda1  999999999  999999999  999999999  999G Windows recovery environment
/dev/sda2  999999999  999999999  999999999  999G EFI System
/dev/sda3  999999999  999999999  999999999  999G Microsoft reserved
/dev/sda4  999999999  999999999  999999999  999G Microsoft basic data
/dev/sda5  999999999  999999999  999999999  999G Linux filesystem
/dev/sda6  999999999  999999999  999999999  999G Linux Swap
/dev/sda7  999999999  999999999  999999999  999G Windows recovery environment

.i.e fdisk shows all partitions but no IDs like 83 as used for non-GPT tables.

As a result the script fails e.g. with
partition /dev/sda5 must be type 83 - Linux.

My suggestion is that the script should accept the ID or the type name:

--- a/check-target.sh
+++ b/check-target.sh
@@ -147,11 +147,11 @@
     elif [ $(fdisk -l "$partition_disk" | grep "$1[ \t]" | grep "[ \t]85[ \t]" | wc -l) -eq 1 ]; then
         error "partition "$1" is an Extended partition."
     elif [ "$2" == "83" ]; then
-      if [ $(fdisk -l "$partition_disk" | grep "$1[ \t]" | grep "[ \t]"$2"[ \t]" | wc -l) -eq 0 ]; then
+      if [ $(fdisk -l "$partition_disk" | grep "$1[ \t]" | grep -i "[ \t]"$2"[ \t]\|[ \t]Linux filesystem" | wc -l) -eq 0 ]; then
         error "partition "$1" must be type "$2" - Linux."
       fi
     else
-      if [ $(fdisk -l "$partition_disk" | grep "$1[ \t]" | grep "[ \t]"$2"[ \t]" | wc -l) -eq 0 ]; then
+      if [ $(fdisk -l "$partition_disk" | grep "$1[ \t]" | grep -i "[ \t]"$2"[ \t]\|[ \t]Linux Swap" | wc -l) -eq 0 ]; then
         error "partition "$1" must be type "$2" - Linux swap."
       fi
     fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions