Error creating osx sierra recovery partition

Since the K2100 4.1 update, I get an error while creating the recovery partition when deploying a MacOs Sierra image. In previous version i have used included script without problems. Error says 'create_osx_recovery_partition.sh: line 23: let: tds=: syntax error: operand expected (error token is "=")
remaining partition space is too low (-870203392)
no room for OS'
Anyone have the same problem? Entire recovery creation script;

if [[ ! -a $partloc ]]
      echo "could not find recovery partition image "
      echo "should be $partloc"
      exit 1
dcheck=`diskutil list | grep disk0s | wc -l | awk '{print $1}'`
if [[ $dcheck != "2" ]]
     echo "can not be run on disk0 without and existing HFS partition"
     echo "or with more than one. there are $dcheck on disk0"
     exit 1
let rpartsizeb=`ls -l $partloc | awk '{print $5}'`
let rpartsizes=$rpartsizeb/512
let tds=`diskutil info disk0 | grep "Total Size" | awk '{print $5}' | sed 's/(//g'`
let efisize=220200960
let partsize=$tds-$rpartsizeb-$efisize
if (($partsize<$efisize))
     echo "remaining partition space is too low ($partsize)"
     echo "no room for OS"
     exit 1
/usr/sbin/diskutil resizeVolume "$KACE_SYSTEM_DRIVE_NAME" "$res"
slice=`df | grep disk0 | awk '{print $1}' `
sleep 5
/usr/bin/hdiutil detach $slice
let parts=`gpt show disk0 | grep 48465300 | awk '{print $1 }'`
let partl=`gpt show disk0 | grep 48465300 | awk '{print $2 }'`
let partbase=$parts+$partl
gpt add -b $partbase -s $rpartsizes -t 426F6F74-0000-11AA-AA11-00306543ECAC disk0
pname="Recovery HD"
dd if=$partloc of=/dev/disk0s3
sleep 2
/usr/bin/hdiutil detach $slice
gpt label -i 3 -l "$pname" disk0
exit 0    

0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
Posted by: calixvic 7 years ago
White Belt

Top Answer

I had this error and our engineer discovered the following issue:

let tds=`diskutil info disk0 | grep "Total Size" | awk '{print $5}' | sed 's/(//g'`


But there is no line “Total Size” in the output of “diskutil info disk0”. But there is a line: “Disk Size”, so I changed it to:


let tds=`diskutil info disk0 | grep "Disk Size" | awk '{print $5}' | sed 's/(//g'`


That did the trick.

  • Mark, I have tested your solution and indeed it works. Thank you very much! - Brainpilot 7 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ