LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Tags used in this thread
Popular LQ Tags , , ,

Reply
 
Thread Tools
Old 06-16-2009, 10:44 AM   #1
steven19782007
LQ Newbie
 
Registered: Jan 2007
Location: Merseyside
Distribution: Ubuntu 9.04
Posts: 15
Thanked: 1
Checking if a disk is connected but not mounted


[Log in to get rid of this advertisement]
Hi all

I am looking for a way to check if a drive is plugged in but not mounted. I have a USB drive which I use as an offsite backup. I have a script which mounts the disk, does an rsync with the primary backup drive and then unmounts the drive and sends an email to the I.T department to say the backup is finished. What I want to do now is create a script that keeps checking if the drive has been unplugged and sends an email every 15 minutes or so as a reminder to disconnect the drive. I thought about checking the output of 'fdisk -l' and then using grep to check for the drive name (/dev/sdc) but was wondering if this is a sound way to do it or if there is a more specialized way to check this?
steven19782007 is offline  
Tag This Post , , ,
Reply With Quote
Old 06-16-2009, 11:00 AM   #2
colucix
Guru
 
Registered: Sep 2003
Location: Bologna, Italia
Distribution: OpenSUSE 11.1 CentOS 5.4 VectorLinux 6.0
Posts: 5,134
Thanked: 465
You can simply check if the directory /sys/block/sdc exists. Furthermore you can retrieve more information to uniquely identify the disk, using
Code:
udevinfo -q all -p /sys/block/sdc
colucix is offline     Reply With Quote
Old 06-16-2009, 11:00 AM   #3
GazL
Member
 
Registered: May 2008
Location: England.
Posts: 880
Thanked: 78
Your IT Operations guys are going to love you if you send an email every 15 mins!

Anyway, maybe blkid might be worth considering.
GazL is offline     Reply With Quote
Old 06-16-2009, 11:13 AM   #4
steven19782007
LQ Newbie
 
Registered: Jan 2007
Location: Merseyside
Distribution: Ubuntu 9.04
Posts: 15
Thanked: 1

Original Poster
Thanks

Thanks guys I think that checking /sys/block/sdc should do what I want.

It's ok, we have a small IT dept here and I am one of 4 guys who will be getting that email.

Thanks for your help

Steve
steven19782007 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
how to keep an ssh mounted folder alive and connected. nephish Linux - Software 2 01-04-2009 01:24 PM
Help checking for mounted share with a bash script cmfarley19 Linux - General 6 07-03-2008 02:18 PM
script for checking if a drive is mounted Soulja1 Linux - General 2 05-07-2007 04:07 PM
Checking how many users are connected on different solaris work stations sajidmumtaz Solaris / OpenSolaris 14 06-27-2006 06:31 AM
Checking if a device is mounted using a script thar Linux - Software 2 02-22-2004 04:17 PM


All times are GMT -5. The time now is 02:31 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration