diff options
author | Lucas Affonso Xavier de Morais | 2014-08-20 18:01:16 +0200 |
---|---|---|
committer | Michael Pereira Neves | 2014-10-28 14:14:49 +0100 |
commit | babd1c7e8873530e595f8984e817abb851957c14 (patch) | |
tree | d10e5104b9e677216e3d09b707dadc743865c173 | |
parent | [partitioner] setup_partitions changes copied from 'client-cache' branch. (diff) | |
download | tm-scripts-babd1c7e8873530e595f8984e817abb851957c14.tar.gz tm-scripts-babd1c7e8873530e595f8984e817abb851957c14.tar.xz tm-scripts-babd1c7e8873530e595f8984e817abb851957c14.zip |
[partitioner] setup_partitions adapted to work with GPT (need some tests)
-rwxr-xr-x | remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions index 8a541d56..f71410f3 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions @@ -90,15 +90,29 @@ mount_temp_fallback () { rmdir /tmptmp return 0 } - -fdisk -l | sed -n "/^\/dev\//p" > "/etc/disk.partition" +for hd in $(cat /proc/partitions | tr -s ' ' | cut -d ' ' -f5 | grep -o -e "[a-z]*$"); do + echo -n "$hd - " >> "/etc/disk.partition" + sfdisk -d /dev/$hd 2>&1 | grep 'GPT' > /dev/null + if [[ $? -eq 1 ]]; then + echo "MSDOS" >> "/etc/disk.partition" + fdisk /dev/$hd -l | sed -n "/^\/dev\//p" | tr -s ' ' | cut -d ' ' -f1,5 >> "/etc/disk.partition" + else + echo "GPT" >> "/etc/disk.partition" + for part in $(cat /proc/partitions | tr -s ' ' | cut -d ' ' -f5 | grep -o -e "$hd[0-9][0-9]*$"); do + LINE="/dev/$part " + LINE=$LINE$(sgdisk /dev/$hd -i ${part:3} | grep 'GUID code' | cut -d ' ' -f4) + echo -e $LINE >> "/etc/disk.partition" + done + fi +done echo "Partitions:" cat "/etc/disk.partition" # Check for standard swap partitions and make them available to the system HAVE_SWAP=no -for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do +# gpt swap GUID = 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F +for hdpartnr in $(grep -e "82$\|0657FD6D-A4AB-43C4-84E5-0933C84B4F4F$" /etc/disk.partition | cut -d ' ' -f1); do echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab" swapon "$hdpartnr" -p 10 && HAVE_SWAP=yes # low priority, in case we have zram swap, prefer that) done @@ -107,7 +121,7 @@ done # space, thus no normal filesystem will be incidentally deleted or # corrupted HAVE_TEMP=no -for hdpartnr in $(sed -n -e "/ 44 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do +for hdpartnr in $(grep -e "44$\|44000000-0000-0000-0000-000000000000$" /etc/disk.partition | cut -d ' ' -f1); do # check for supported filesystem and formatter if diskfm "$hdpartnr"; then # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready @@ -125,13 +139,13 @@ done HAVE_PERSISTENT_BOOT=no HAVE_PERSISTENT_CACHE=no HAVE_PERSISTENT_HOME=no -for partid in 83 49 48 47 46; do - for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do - if [ "${partid}" -eq 83 ]; then +for partid in 83 0FC63DAF-8483-4772-8E79-3D69D8477DE4 49 48 47 46; do + for hdpartnr in $(grep -e $partid /etc/disk.partition | cut -d ' ' -f1); do + if [ "${partid}" -eq 83 -o "$partid" = "0FC63DAF-8483-4772-8E79-3D69D8477DE4" ]; then mkdir -p "/media/${hdpartnr#/dev/*}" echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab" - elif [ "${partid}" -eq 49 -a "$HAVE_PERSISTENT_BOOT" = "no" ]; then + elif [ "${partid}" -eq 49 -o "$partid" = "49000000-0000-0000-0000-000000000000" -a "$HAVE_PERSISTENT_BOOT" = "no" ]; then mkdir -p "$PERSISTENT_BOOT" if ! mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_BOOT"; then diskfm "$hdpartnr" "jfs xfs ext3" || continue @@ -140,7 +154,7 @@ for partid in 83 49 48 47 46; do HAVE_PERSISTENT_BOOT=yes echo -e "${hdpartnr}\t${PERSISTENT_BOOT}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab" - elif [ "${partid}" -eq 48 -a "$HAVE_PERSISTENT_CACHE" = "no" ]; then + elif [ "${partid}" -eq 48 -o "$partid" = "48000000-0000-0000-0000-000000000000" -a "$HAVE_PERSISTENT_CACHE" = "no" ]; then mkdir -p "$PERSISTENT_CACHE" if ! mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_CACHE"; then diskfm "$hdpartnr" "jfs xfs ext3" || continue @@ -149,7 +163,7 @@ for partid in 83 49 48 47 46; do HAVE_PERSISTENT_CACHE=yes echo -e "${hdpartnr}\t${PERSISTENT_CACHE}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab" - elif [ "${partid}" -eq 47 -a "$HAVE_PERSISTENT_HOME" = "no" ]; then + elif [ "${partid}" -eq 47 -o "$partid" = "47000000-0000-0000-0000-000000000000" -a "$HAVE_PERSISTENT_HOME" = "no" ]; then mkdir -p "$PERSISTENT_HOME" if ! mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT_HOME"; then diskfm "$hdpartnr" "jfs xfs ext3" || continue @@ -159,7 +173,7 @@ for partid in 83 49 48 47 46; do echo -e "${hdpartnr}\t${PERSISTENT_HOME}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab" - elif [ "${partid}" -eq 46 ]; then + elif [ "${partid}" -eq 46 -o "$partid" = "46000000-0000-0000-0000-000000000000" ]; then mkdir -p "/media/${hdpartnr#/dev/*}" #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\ #test -d /mnt/media/${hdpartnr#/dev/*}/home && \ |