03-11-2011
if (disk is mounted) unmount if (disk is unmounted) mount
Hey there, sorry if this is a bit too much of a noob question, trying to get to grips with a simple bash script - but i have done ZERO bash scripting.
basically having worked out how to mount and unmount disks using:
disktool -m *device* & disktool -e *device*
- and looking at the result of disktool -l
i see that from the results each device has a parameter Mountpoint = '/Volumes/My Disk' if the "My Disk" is mounted - or - Mountpoint = '' if unmounted.
Basically I am looking to write a script that looks to see if a partition on my external disk is mounted or not, if it is mounted - then the disk is unmounted - - and if it is unmounted the disk is mounted.
So this this disk is disk1s2. How do I query the Mountpoint and see what the result is?
Basically :
if (disk1s2.Mountpoint == "") {
disktool -m disk1s2
}
if (disk1s2.Mountpoint == "/Volumes/My Disk") {
disktool -e disk1s2
}
^ is obviously very, very, very wrong for a bash script - but you get the gist.
Any help would be greatly appreciated
10 More Discussions You Might Find Interesting
1. HP-UX
Hi,
Someone please help me with how i can unmount and remove all the files systems from a cluster. This is being shared by two servers that are active_standby. (3 Replies)
Discussion started by: joeli
3 Replies
2. HP-UX
Greetings,
I am running HP-UX 10.2 and /usr is out of disk space already. I installed IE 5.0 for UNIX on my machine under /usr and browsed the Internet for a while and presto no more disk space.
I have plenty of hard disk space on my computer so would like to expand the size of the volume. The... (5 Replies)
Discussion started by: Dirk_
5 Replies
3. SuSE
Hi,
I am running Suse on a fujitsu server. The problem is that it will no fully load the usb external disk. When plugged in, dmesg shows that indeed a usb disk has been plugged in ,but gives no devpath e.g sda,sdb.
lsusb shows the disk vendor (western digital) but nothing else.Whats goin on... (2 Replies)
Discussion started by: ulemsee
2 Replies
4. OS X (Apple)
I have had a little issue with one of my disks, the usb cacble was pulled out and one of the external drives on it would no longer mount. I used First Aid and it verified and repaired both OK / nothing to do). After lots of messing around and not being able to mount I used Drive Genius 2 and that... (1 Reply)
Discussion started by: Cranie
1 Replies
5. OS X (Apple)
hdiutil detach -Force disk&number
(ex:hdiutil detach -Force disk1) (3 Replies)
Discussion started by: unimachead
3 Replies
6. Shell Programming and Scripting
I have my Mac OS X program executing a shell script (a script that copies files to a drive). I want to make it so that the shell script automatically kills itself if it finds that the host .app is not running OR kill itself if the drive that it is copying files to has been unmounted. Right now what... (2 Replies)
Discussion started by: pcwiz
2 Replies
7. Shell Programming and Scripting
Hi, How can I unmount an usb disk using the command umount? (3 Replies)
Discussion started by: Guccio
3 Replies
8. UNIX for Dummies Questions & Answers
I need to check if a folder has some kind of logic disk problems.
I have a FreeBSD machine where the (root)\tmp\TEST folder has some file created by a script that i cannot delete.
If i rename the tmp\TEST folder then i can delete them (apparently) but if i recreate a folder in tmp directory... (2 Replies)
Discussion started by: mirrorx
2 Replies
9. Solaris
Hi Guys,
I was wondering; can a disk with mounted partitions be modified? If yes, how can this be done?
Thanks lots (1 Reply)
Discussion started by: cjashu
1 Replies
10. AIX
Hi Guys
I'm new here, and I need urgent help.
This my first steps to be Aix admin and I have this task
-instal Oracle database on Aix machine and create mounting point /u02 of size 100GB for Oracle Standalone database installation.
-download and install the following OS patches
- IV42025... (5 Replies)
Discussion started by: khaled_ly84
5 Replies
LEARN ABOUT DEBIAN
sys::filesystem::darwin
Sys::Filesystem::Darwin(3pm) User Contributed Perl Documentation Sys::Filesystem::Darwin(3pm)
NAME
Sys::Filesystem::Darwin - Return Darwin (Mac OS X) filesystem information to Sys::Filesystem
SYNOPSIS
See Sys::Filesystem.
DESCRIPTION
The filesystem information is taken from diskutil, the system utility supplied on Mac OS X.
INHERITANCE
Sys::Filesystem::Darwin
ISA Sys::Filesystem::Unix
ISA UNIVERSAL
METHODS
version ()
Return the version of the (sub)module.
ATTRIBUTES
The following is a list of filesystem properties which may be queried as methods through the parent Sys::Filesystem object.
The property 'label' is also set, but cannot be queried by Sys::Filesystem yet.
mount_point
The mount point (usually either '/' or '/Volumes/...').
device
The mounted device
format
Describes the type of the filesystem. So far I encountered the following types:
hfs The standard Mac OS X HFS(+) filesystem. Disk images (.dmg) and Mac Software DVDs normally also use the HFS(+) format.
msdos
DOS image files (e.g. floppy disk images)
cd9660
CD-ROM image files or real CD-ROMs
cddafs
Audio CDs
udf UDF filesystem (e.g. DVDs)
(empty)
For mounted FTP servers, disktool returns an empty filesystem type (ie, '').
BUGS
Doesn't take /etc/fstab or /etc/xtab into account right now, since they are normally not used. Contact the author if you need this.
SEE ALSO
Sys::Filesystem, diskutil
VERSION
$Id: Darwin.pm 128 2010-05-12 13:16:44Z trevor $
AUTHOR
Christian Renz <crenz@web42.com>
Jens Rehsack <rehsack@cpan.org> - <http://www.rehsack.de/>
COPYRIGHT
Copyright 2004,2005,2006 Nicola Worthington. Copyright 2009,2010 Jens Rehsack.
This software is licensed under The Apache Software License, Version 2.0.
<http://www.apache.org/licenses/LICENSE-2.0>
perl v5.10.1 2010-05-18 Sys::Filesystem::Darwin(3pm)