Question

I am trying to create a script to format a newly added disk on a VM in vmware. I want to run the script with a sudouser.

echo "- - -" > /sys/class/scsi_host/host0/scan
echo "scsi add-single-device 0 0 1 0" > /proc/scsi/scsi
dev=/dev/disk/by-path/*-scsi-0:0:1:0
count=0
while [ ! -r ${dev} ]; do
    count=$(($count+1))
    if [ $count -gt 5 ]; then
        echo "New disk for target is not visible by the OS"
        exit 1
    fi
    echo $count
    sleep 5
done
dev=$(readlink -f $dev) || exit 1
parted -s -- $dev mklabel msdos

When I run the script as sudo ./mount.sh, the script fails saying "parted: command not found". I added the path for parted in the PATH variable for the sudouser. What am I missing? Where did I go wrong?

I tried adding sudo to each command individually, then the script fails in the while loop. Do I need to add any more permissions for the sudouser? Or is there any implementation error? Am I missing something? Please help me.

I observed that this happens when I try to run any of the commands in /sbin/ sudo ifconfig throws sudo: ifconfig: command not found

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top