How to tell if a physical HDD has failed withno drive letter

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

How to tell if a physical HDD has failed withno drive letter

#1 Post by MKANET » 03 Jul 2012 16:29

How can I tell if a physical disk has failed on a remote machine if the disk doesn't have a logical drive letter?

The physical drive is pointing to a subdirectory on another physical disk using "Mount in Empty NTFS Folder" feature of Windows.


Supposing that: Physical disk label is called: Backup
and... Empty folder is: C:\Test\Backup

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to tell if a physical HDD has failed withno drive le

#2 Post by foxidrive » 03 Jul 2012 22:57

If the mount point is c:\test\backup then you could test for files or a folder within the mount point.

Say a folder "Files" exists in the root of the HDD then

if exist "c:\test\backup\Files\" echo the hard drive is mounted.

Or if a file called readme.txt exists in the root then this too will work:

if exist "c:\test\backup\readme.txt" echo the hard drive is mounted.


You can share the backup folder and use this:

if exist "\\server\share\Files\" echo the hard drive is mounted.

MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Re: How to tell if a physical HDD has failed withno drive le

#3 Post by MKANET » 03 Jul 2012 23:19

Hmmm... Do you mean to blindly try to give it a temporary share name; and, if that share doesn't exist, then it means the hard drive has failed? Then, blindly unshare it.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to tell if a physical HDD has failed withno drive le

#4 Post by foxidrive » 03 Jul 2012 23:31

Are you serious? You want to see if a drive on a remote system exists and you don't want to actually access it?

What *do* you want to do? Use PSEXEC and access the system remotely - oh, hang on, *blindly* access the system remotely.


Be *very* aware that you didn't give any details apart from you want to see if a drive is mounted.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: How to tell if a physical HDD has failed withno drive le

#5 Post by Ed Dyreen » 04 Jul 2012 01:22

'
No need to check for any file, dir or drive letter.
Let's assume your server's name is backup and one of it's drives is shared as backup, in that case

Code: Select all

if exist "\\backup\backup\" &&echo.exist ||not exist
or

Code: Select all

if exist "\\192.168.*.*\backup\" &&echo.exist ||not exist
It doesn't matter whether your system assigns a drive letter to a remotely shared drive/folder.
This is a local thingy which the remote share doesn't cares about.
What matters is whether the remote share is on-line, operational, accessible and that you have the required privileges.

MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Re: How to tell if a physical HDD has failed withno drive le

#6 Post by MKANET » 04 Jul 2012 01:38

I dont think I explained this very well. I don't care how the script detects if a disk has failed or not; as long as it's reliable. I was just saying it's possible that disk may be empty (where no files or folders are on it).

One more thing to consider.. Considering that the "Backup" folder under C:\Test\Backup is pointing to a physical disk (not the same physical disk that logical drive C: is on). If the "Backup" folder isn't there for any reason, the backup software unfortunately create a local "Backup" sub-directory under "C:\Test" (which is obviously not the same thing as that location pointing to a completely different physical disk). If that were to happen, a script that just checks for files and/or share name, will think that that disk is still there just because there is a folder which exists there.

I was thinking the only way to know for sure that the disk is up or not is to use diskpart to check for the volume label "Backup". If it is there, to check to see if it's pointing to an empty existing folder under C:\Test\Backup. I just dont know how to do that without depending on a separate diskpart.txt script file.

MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Re: How to tell if a physical HDD has failed withno drive le

#7 Post by MKANET » 04 Jul 2012 01:41

What would happen if the disk isn't shared and the disk still hasn't failed :) That's why I was suggesting that a temporary share would have to be created originally. However, even then, I dont think it would still be reliable for the reason I mentioned in my previous post; which looks like it needs the help of diskpart.

Ed Dyreen wrote:'
No need to check for any file, dir or drive letter.
Let's assume your server's name is backup and one of it's drives is shared as backup, in that case

Code: Select all

if exist "\\backup\backup\" &&echo.exist ||not exist
or

Code: Select all

if exist "\\192.168.*.*\backup\" &&echo.exist ||not exist
It doesn't matter whether your system assigns a drive letter to a remotely shared drive/folder.
This is a local thingy which the remote share doesn't cares about.
What matters is whether the remote share is on-line, operational, accessible and that you have the required privileges.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: How to tell if a physical HDD has failed withno drive le

#8 Post by Ed Dyreen » 04 Jul 2012 01:53

MKANET wrote:What would happen if the disk isn't shared and the disk still hasn't failed :)
If the disk isn't shared then it doesn't matter that it has or hasn't failed, you won't have access either way and,
if you don't have access, the disk may have failed.

You could run a wmic script on the remote system though, that should provide the info you're after

Code: Select all

wmic.EXE diskdrive
And now if you'll excuse me, I really need to do some homework :)


MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Re: How to tell if a physical HDD has failed withno drive le

#10 Post by MKANET » 04 Jul 2012 16:16

Hi Ed, thanks for replying. Unfortunately WMIC diskdrive does not display disk volume labels; which is the only reliable/consistent information I can depend on Backup HDD volume label is always labeled: "Backup".

Anyway, below is the only way I know of to reliably detect if the "Backup HDD" drive has failed; which doesn't mess with share names.

Code: Select all

psexec.exe \\%Server% echo list volume >%temp%\diskpart.txt| 
diskpart /s %temp%\diskpart.txt | find "Backup" >nul&&del %temp%\diskpart.txt
if errorlevel 1 echo disk Backup has failed






Squashman, I appreciate your response, however, I needed this specifically for a batch file; and, wanted to keep things as simple as possible.

PS: Ed, I think you might have missed this since you might have been in a rush; but that question that you were answering was meant to be rhetorical; hence, why I had a the followup sentence. ;)

Ed Dyreen wrote:
MKANET wrote:What would happen if the disk isn't shared and the disk still hasn't failed :)
If the disk isn't shared then it doesn't matter that it has or hasn't failed, you won't have access either way and,
if you don't have access, the disk may have failed.

You could run a wmic script on the remote system though, that should provide the info you're after

Code: Select all

wmic.EXE diskdrive
And now if you'll excuse me, I really need to do some homework :)

Post Reply