LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-05-2022, 05:08 PM   #1
fogles
LQ Newbie
 
Registered: Jun 2022
Posts: 1

Rep: Reputation: 0
Finding disk on macOS script


Hi Im trying to turn this bash script so it would work for macOS.

Basically what it already does it look for a disk that's attached but lsblk doesn't work for macOS and
cat /sys/class/block/$phison/device/vendor
PHP Code:
echo "Checking privileges."
if [ "$EUID-ne 0 ] ;then
    
echo "You must run this script as root, try sudo."
    
exit
fi


disks
=$(lsblk -awk '$6=="disk" {print $1}')

for 
disk in $disks
do
    echo 
"Checking:$disk"
    
partitions=$(ls -/dev/* | grep "$disk" | wc -l)
    if [ "$partitions" -eq 14 ]; then
        echo "Phison candidate found: $disk"
        phison=$disk
    fi
done


#Uncomment below to override the detection.
#phison="sde"

echo "Checking Phison..."
if [ -z "$phison" ]; then
    echo "No phison candidate found."
    exit
fi

echo "The Phison has been detected as: $phison ($(cat /sys/class/block/$phison/device/vendor)), is this correct? [y/N]"
read verify

if [ "$verify" != 'y' ]; then
    echo "You selected N, cancelling write."
    exit
fi 

Last edited by fogles; 06-05-2022 at 05:10 PM.
 
Old 06-05-2022, 06:05 PM   #2
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
MacOS uses apfs, which doesn't appear to be supported by Linux's fdisk.

Maybe this will help: https://thinkzinc.com/blog/index.php...ive-in-ubuntu/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] on macos 10.15, configure script can't find ncurses menu library Andy Alt Programming 1 05-13-2021 04:24 PM
Comparing JPEGs and finding matches... or not finding matches. rnturn Linux - General 16 02-20-2018 02:37 PM
Finding files and then finding content within those files... Maeltor Linux - Software 5 03-13-2007 12:06 PM
MacOS 8.6 -- disk detect problem after a disk wipe BinJajer Other *NIX 2 02-05-2006 03:24 AM
macos x (darwin) questions frieza *BSD 1 07-26-2002 07:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration