From 18722a4e156c1402e7366f2b0d7e58b4c69474d4 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 27 Jan 2022 16:46:43 +0100 Subject: sbin/itzks-diskless-re-partition-dlw: Handle NVMe storage devices gracefully. --- sbin/itzks-diskless-re-partition-dlw | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'sbin/itzks-diskless-re-partition-dlw') diff --git a/sbin/itzks-diskless-re-partition-dlw b/sbin/itzks-diskless-re-partition-dlw index 89d4fd2..a34d0a0 100755 --- a/sbin/itzks-diskless-re-partition-dlw +++ b/sbin/itzks-diskless-re-partition-dlw @@ -21,7 +21,10 @@ # storage, first partition containing 16GB swap space, second # partition containing a scratch partition for local storage. +#!/bin/bash + DEV="$1" # pick your disk device +p="" if [ -z "${DEV}" ]; then echo "no device given" @@ -33,6 +36,10 @@ if [ ! -e ${DEV} ]; then exit 1 fi +if echo ${DEV} | grep -E "\/dev\/nvme.*"; then + p="p" +fi + wipefs -a ${DEV} # recommended if you want to swap partition table types # partitioning for 16G swapfs and rest as a scratch disk @@ -42,9 +49,9 @@ echo "label: gpt device: ${DEV} unit: sectors -${DEV}1 : size=${SWAP_SIZE}MiB, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F -${DEV}2 : type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, name=DLW_SCRATCH +${DEV}${p}1 : size=${SWAP_SIZE}MiB, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F +${DEV}${p}2 : type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, name=DLW_SCRATCH " | sfdisk ${DEV} -mkswap ${DEV}1 -mkfs.ext4 -L DLW_SCRATCH ${DEV} \ No newline at end of file +mkswap ${DEV}${p}1 +mkfs.ext4 -L DLW_SCRATCH ${DEV}${p}2 -- cgit v1.2.3