LinuxQuestions.org
Register a domain and help support LQ
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-16-2009, 09:44 AM   #1
steven19782007
LQ Newbie
 
Registered: Jan 2007
Location: Merseyside
Distribution: Ubuntu 9.04
Posts: 15

Rep: Reputation: 1
Checking if a disk is connected but not mounted


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?
 
Old 06-16-2009, 10:00 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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
 
Old 06-16-2009, 10:00 AM   #3
GazL
Senior Member
 
Registered: May 2008
Posts: 3,426

Rep: Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937
Your IT Operations guys are going to love you if you send an email every 15 mins!

Anyway, maybe blkid might be worth considering.
 
Old 06-16-2009, 10:13 AM   #4
steven19782007
LQ Newbie
 
Registered: Jan 2007
Location: Merseyside
Distribution: Ubuntu 9.04
Posts: 15

Original Poster
Rep: Reputation: 1
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
 
  


Reply

Tags
disk, drive, fdisk, usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


All times are GMT -5. The time now is 02:05 AM.

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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration