Get my Root's Hard Drive name through CLI (or Applescript)

How do I retrieve the current name of my hard drive through the command line? It needs to be in a way that will allow me to easily parse it. I first tried this:
$ ls -l /Volumes/ | grep -E '> /$'
lrwxr-xr-x 1 root admin 1 Feb 2 17:25 demoive HD -> /
which is pretty close, except for removing all the other stuff would be tricky (due to all the variations that could occur in different scenarios). So then I tried the following:
$ diskutil info -plist / | grep '<key>VolumeName</key>' -A 1 | tail -n 1
<string>demoive HD</string>
which is more robust in my mind and totally works, however, it causes my optical drive make the little noise indicating that it's checking to see if I have a disk...and that sort of thing won't suffice for what I need (both because of the noise and delay of ~1.5 seconds).
If someone knows of a way through AppleScript, that would work too as I can use the 'osascript' command via the command line.
Cheers.

Three AppleScript examples:
osascript -e '"/" as POSIX file' | sed -e 's/:$//'
osascript -e 'tell app "Finder" to get name of startup disk'
osascript -e 'item 1 of (list disks)'
If you want to avoid disktool (because it's deprecated) and also want to avoid AppleScript (bacause it's slow), another possibility is something like
#!/bin/zsh
cd /Volumes
for d in *(@-/) # use * for bash
do
if [ "$(readlink "$d")" = '/' ]; then echo $d; exit; fi
done

Similar Messages

  • "revert" deleted hard drive name in disk utility HELP!!

    I booted my wifes macbook pro 10.4.11 in target mode and connected it to my computer, macbook pro 10.5.6 and went into my disk utility to create a partition in the other computer. I used my disk utility from 10.5.6 because for some reason it got erased from the 10.4.11
    so I started to do 2 partitions. It said there was not enough room so I clicked on "revert" and for some reason the name of the "macintosh hd" disappeared and I ejected the computer in target mode. Then when I tried to start it up, it just kept flashing a folder with a question mark. I booted again in target mode but still no "indented" "macintosh hd". it seems like it came unmounted maybe?
    I have tried starting from x key, resetting pram, trying to load from install disc (which gets to the point where it asks where to install the OS and no HD shows up to choose) and even taking it to the apple store where they said the HD is damaged and/or corrupt. Before trying to reclaim the files, if I can, I wanted to see if anyone had this same issue and if it was solvable. I cant believe that I hit "revert" and it erased my hard drive name and it automatically made my HD corrupt or damaged?
    PLEASE help anyone!
    or if this is a lost cause, is there a good file recovery program where I can get my WIFES files back! Yeah, I am in trouble.
    Thanks!

    If anything can be recovered at all, you should quit using the computer asap. The more you use it the more OSX will write over those spots where the files were.
    Data Rescue II...
    http://www.prosofteng.com/products/data_rescue.php
    (Has a Free Demo to see if it could or not, but you'll need another drive to recover to).
    Or FileSalvage...
    http://www.subrosasoft.com/OSXSoftware/index.php?%20mainpage=product_info&productsid=1
    to recover what you can.
    BUT, you'll need that other Mac with this one in FW Target Mode
    BTW, don't use Leopards Disk Utility to do anything to a Tiger Hard Drive.

  • Mac hard drive name

    Why is the name of my hard drive \][poiuytrewq`\ ?  The symbols seem to be causing a conflict with MAC Office 2011.  Has anyone had this issue?

    When I attempt to open an Excel file, I get an error message indicating invalid path name...that it contains a symbol like \.  I've never updated my hard drive name, unless it happened when my computer was being repaired at Apple.  I've only had 2 repairs done to it:  the cd drive replaced and a small board that controls the battery charging.
    I can change the name of the hard drive to something like MAC_HD_MSilva, but I wanted to make sure this wouldn't cause any issues.  From reading posts...the name doesn't seem to matter.

  • My iMac hard drive name is just backslashes

    I have an iMac running OS X 10.9.4

    Could be some accident, keyboard commands were chosen & highlighted
    the icon of desktop items, and then later, if finder/desktop was clicked or
    somehow became the default window, bumping any key could do it.
    You can choose desktop items all by keyboard action, + click enter to open
    in some instances. There are several shortcuts going way back to early
    Mac OS that still do things. Not necessarily the same things in OS X.
    Cycling through several items on the desktop by up/down is then possible;
    if you happen across the correct keys, even by accident.
    {Kids are almost famous for choosing Accessibility preferences; such as
    those to turn the desktop into a chalkboard negative effect}
    Not sure if you can lock a hard drive name (as you can an application)
    in the case of my Macs hard drives, the shorter name in-icon uses HD
    or HDD to avoid longer name issues.
    I've had a few dozen/dozen Macs and some of these kinds of things are
    not so new to me. On rarer occasion, a few others can still be strange...
    Good luck & happy computing!
    edited

  • I have a 4th gen 20G ipod whose hard drive has died.  Are replacement hard drives available through the apple store?

    I have a 4th gen 20G ipod whose hard drive has died.  Are replacement hard drives available through the apple store?

    I don't think Apple will do that repair for you, because the iPod is too old.  I believe the hard drive type used in 4th gen and older iPods is no longer produced.  There may be non-Apple shops who can do the repair, but they may be using a working part salvaged from a used iPod.
    If you want to do the repair work yourself, and you are good at such things, this web site has repair guides
    http://www.ifixit.com/Device/iPod_Original
    (There are probably also YouTube videos on the topic.)
    NOTE:  There are two hard drive physical sizes.  The thick version has two platters, and corresponds to the "thick" iPods (with double storage capacity).  A 4th gen 20GB model should be the thin version.  The hard drive used in iPods up to 4th gen should work interchangeably, but 5th gen and later iPods use a different type.
    I have a 4th gen iPod that started out as a 20GB.  The hard drive failed, so I put a compact flash card on an adapter in there.  The adapter is like this one (I bought it a few years ago so it's probably not the same seller)
    http://www.ebay.com/itm/NEW-Compact-Flash-CF-SSD-To-Toshiba-IPod-1-8-inch-Adapte r-Black-/121174875639
    The compact flash card is standard; I bought the cheapest one.  I currently have an 8GB card in there, but prices have come down, so I may get a 64GB card soon.  It works great with the 8GB card.  No more hard drive spin-up delay.  Battery lasts longer.  It's lighter.  And it should be more shock resistant.
    The only mod I needed to make on the adapter was to bend over two pins 90º, where you place a jumper to set the drive to "master."  The adapter plus CF card is actually smaller and thinner than just original 1.8-inch Toshiba hard drive; I used some thin foam packing material (cut to the right shape) to take up the excess space and ensure the adapter and card did not become disconnected.
    The 4th gen iPod has excellent sound, compared to some later iPods.

  • Hard Drive name changed on it's own.

    Hi there.
    On starting my Mac Mini this morning I noticed that the hard drive name had changed from "Mac HD" to "/" without any input from myself.
    does anyone have an idea what may have occured ?
    Thank's.

    Try using GrandPerspective to see what's taking up all the space.
    Also, make sure everything you don't need is turned off under Sharing; it's possible that you left file sharing on without a password and someone is taking advantage of that.
    If you have a MobileMe account, do you have iDisk Syncing turned on? Or something similar if you have Dropbox or another similar service?

  • Can I install os on a hard drive conected through usb

    Can I install a OS on a hard drive conected through usb On my macbook pro?
    Thanks:)

    Will not work.
    Mac is not capable of running older version then it shipped with originally.
    Allan

  • I have a 2007 20" iMac. Can I get a solid state hard drive installed?  Can the Apple store do it?  How long?  What cost?

    I have a 2007 20" iMac. Can I get a solid state hard drive installed?  Can the Apple store do it?  How long?  What cost?

    Sure-glad to help you. You will not lose any data by changing synching to MacBook Pro from imac. You have set up Time Machine, right? that's how you'd do your backup, so I was told, and how I do my backup on my mac.  You should be able to set a password for it. Save it.  Your stuff should be saved there. So if you want to make your MacBook Pro your primary computer,  I suppose,  back up your stuff with Time machine, turn off Time machine on the iMac, turn it on on the new MacBook Pro, select the hard drive in your Time Capsule, enter your password, and do a backup from there. It might work, and it might take a while, but it should go. As for clogging the hard drive, I can't say. Depends how much stuff you have, and the hard drive's capacity.  As for moving syncing from your iMac to your macbook pro, should be the same. Your phone uses iTunes to sync and so that data should be in the cloud. You can move your iTunes Library to your new Macbook pro
    you should be able to sync your phone on your new MacBook Pro. Don't know if you can move the older backups yet-maybe try someone else, anyways,
    This handy article from Apple explains how
    How to move your iTunes library to a new computer - Apple Support''
    don't forget to de-authorize your iMac if you don't want to play purchased stuff there
    and re-authorize your new macBook Pro
    time machine is an application, and should be found in the Applications folder. it is built in to OS X, so there is nothing else to buy. double click on it, get it going, choose the Hard drive in your Time capsule/Airport as your backup Time Machine  and go for it.  You should see a circle with an arrow on the top right hand of your screen (the Desktop), next to the bluetooth icon, and just after the wifi and eject key (looks sorta like a clock face). This will do automatic backups  of your stuff.

  • How can get formatted data from hard drive

    how can get formatted data from hard drive?

    No chance without special tools/knowledge. There are companies that can do it, unless you use multiple format or rewrite data with special erase ustility or unless you have done low level format.
    Regards
    Milos

  • Applescript for recognizing hard drive names (Chronosync)

    I'm looking for a reliable, flexible and "idiot proof" backup system and am currently considering Chronosync for the job.
    By "idiot proofing" the system I basically mean that the setup should keep track of source/destination drives in a multiple drive setup (I have a 4-bay Firewire enclosure and several removable hard drives each with a unique name) so I don't risk backing up to the wrong drives etc.
    I've asked customer support at Chronosync if their software can detect hard drive names and was told it can't, but I could create an AppleScript that would prompt me to connect a drive, and set that as a pre-sync script in the Options Panel of ChronoSync, in the Scripts section.
    Unfortunately I don't know much about Chronosync, nor do I have any knowledge of Applescripting. Does anyone here know of a readily available solution or have other suggestions?

    I gave that script a short test... should work. =)
    Remember to check (cancel on script error) because the script creates an error when you select "Cancel Backup" in it's dialogs:
    -- 24.05.2011 hubionmac.com
    -- can be added as as a pref-sync script to a  ChronoSync-Job to ask the user
    -- to connect a missing source/destination volume if needed
    --https://discussions.apple.com/thread/3075920
    tell application "ChronoSync"
    set mysource to leftTargetPath of document 1
    set mydesti to rightTargetPath of document 1
    if mysource starts with "/Volumes/" then
    set mydelimiter to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "/"
    set sourceName to text item 3 of mysource
    set AppleScript's text item delimiters to mydelimiter
    else
    tell application "Finder" to set sourceName to name of startup disk
    end if
    if mydesti starts with "/Volumes/" then
    set mydelimiter to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "/"
    set destiName to text item 3 of mydesti
    set AppleScript's text item delimiters to mydelimiter
    else
    tell application "Finder" to set destiName to name of startup disk
    end if
    tell application "Finder" to set drivenames to name of every disk
    set cancelbackup to false
    if sourceName is not in drivenames then
    repeat until 1 = 0
    set myaction to button returned of (display dialog "Source disk (" & sourceName & ") is not mountet!" buttons {"Check again!", "Cancel Backup"} default button 1 giving up after 30)
    if myaction = "Check again!" then
    tell application "Finder" to set drivenames to name of every disk
    if sourceName is in drivenames then
    exit repeat
    end if
    else
    set cancelbackup to true
    exit repeat
    end if
    end repeat
    end if
    if cancelbackup is false then
    if destiName is not in drivenames then
    repeat until 1 = 0
    set myaction to button returned of (display dialog "Destination disk (" & destiName & ") is not mountet!" buttons {"Check again!", "Cancel Backup"} default button 1 giving up after 30)
    if myaction = "Check again!" then
    tell application "Finder" to set drivenames to name of every disk
    if destiName is in drivenames then
    exit repeat
    end if
    else
    set cancelbackup to true
    exit repeat
    end if
    end repeat
    end if
    end if
    if cancelbackup is true then error "Canceling"
    end tell

  • HT1436 I have two hard drives on my G5(2004). How do I get to choose which hard drive is the start up disk when I turn on the computer? Is it the shift key I hold down?

    I have two hard drives on my G5(2004). How do I get to choose which hard drive is the start up disk when I turn on the computer? Is it the shift key I hold down?

    depending on which model of G5 and  OS installed will depend on whether a key command will work
    alt   at start up may  work, if it does not, use the start up disc setting in;  
    apple menu > system preferences > system  > start up disc
    of course, the second drive must have a compatible OS installed for it to be able to boot.

  • HT201250 When getting a replacement Seagate hard drive for my Imac through Apple, will they restore my system to it's current state? Or will I have to do it myself though Time Machine? Will Time machine restore all the programs as well?

    Apple has determined that certain Seagate 1TB hard drives used in 21.5-inch and 27-inch iMac systems may fail. These systems were sold between October 2009 and July 2011.
    Apple or an Apple Authorized Service Provider (AASP) will replace affected hard drives free of charge.
    Will this replacement program restore my system to its current state after the new drive is installed? If not, will I have to have all my original disks to re-install all the programs on my current computer, or will Time Machine restore them as well?

    Most of them will tell you to backup your data.
    Time Machine is nice, but unless you are interested in archival backup, Carbon Copy Cloner is a lot easier to recover from:
    https://discussions.apple.com/docs/DOC-1992

  • HOW TO GET OLD FILES FROM HARD DRIVE? HELP!!!!

    hello. so i changed my 320gb HD to a 1.5tb! its running good. the reason why i changed it was because it went white with a folder that had a question mark blinking! so i inserted the disk that came with it and it wouldnt come up on "select a destination" and when i would go to disk utility, it would only show "Media" (which i believe was suppose to be my hard drive), Pioneer CD-RW, and the Installation Disk. so i decided to buy a new and bigger HD and did a partition (dont what that means but it worked) and installed Leopard. now its working good. i just need help on how to get my old files from this old HD i have in hand (the 320gb). like what do i use? can i put it in a PC? PLEASE HELP!!!!!

    If the old drive is not accessible then, no, you will not be able to access all your files on it. In this case you may need to look at the following:
    Basics of File Recovery
    Files in Trash
    If you simply put files in the Trash you can restore them by opening the Trash (left-click on the Trash icon) and drag the files from the Trash to your Desktop or other desired location. OS X also provides a short-cut to undo the last item moved to the Trash -press COMMAND-Z.
    If you empty the Trash the files are gone. If a program does an immediate delete rather than moving files to the Trash, then the files are gone. Recovery is possible but you must not allow any additional writes to the hard drive - shut it down. When files are deleted only the directory entries, not the files themselves, is modified. The space occupied by the files has been returned to the system as available for storage, but the files are still on the drive. Writing to the drive will then eventually overwrite the space once occupied by the deleted files in which case the files are lost permanently. Also if you save a file over an existing file of the same name, then the old file is overwritten and cannot be recovered.
    General File Recovery
    If you stop using the drive it's possible to recover deleted files that have not been overwritten with recovery software such as Data Rescue II, File Salvage or TechTool Pro. Each of the preceding come on bootable CDs to enable usage without risk of writing more data to the hard drive.
    The longer the hard drive remains in use and data are written to it, the greater the risk your deleted files will be overwritten.
    Also visit The XLab FAQs and read the FAQ on Data Recovery.

  • Access exFAT formatted USB hard drive partition through Time Capsule 2013

    I am trying to move data, mostly music, from my old PC to a wirelessly accessible HDD that we can get to from our MacBooks running OS 10.6.8.  I have a 2013 Time Capsule with a USB hard drive attached, but I can't see the exFAT partition containing all of the data (on my Mac).  I can see the other two partitions, which are formatted for a Mac.  I can also see the exFAT partition on my Mac when it is plugged in directly, I just can't access that partition through the Time Capsule.  Any ideas on how to remedy this?  Or if there is a better solution for moving this data.  We don't care about accessing the data from the PC any longer.  We are going to get rid of it.  We just need a place to keep all of the data where we can get to it.
    Message was edited by: A2Laurel

    You need to connect the drive directly to a Mac, copy the data to another location, reformat that partition as Mac OS Extended (Journaled), and put the data back onto it.
    (85877)

  • How do I get half of my hard drive back because half of it is missing and I can't use it?

    I still have my iMac from Early 2008 and currently when I checked my hard drive space because I'm downloading a large game to see if I still have space for it. I saw that I have about 159.14GB left of Hard Drive Space and I know that I have a 320GB HD installed in my computer. How do I get the missing half of my hard drive space back?

    Or run OmniDisk as root. But don't delete anything while in root. Just look.
    Open Terminal and copy/paste and hit return. Give your admin pword when requested, which won't appear as you type it in. Hit return again.
    sudo /Applications/OmniDiskSweeper.app/Contents/MacOS/OmniDiskSweeper
    And definitely look at Pondini's site for this. Some great tips there.

Maybe you are looking for