How to read Windows SBS2008 volume name from Linux

Mark
Mark used Ask the Experts™
on
I have a Western Digital USB drive attached to my SBS 2008 computer. I use this drive for backups. The volume is shared and is named "Castor".

I have this drive cifs mounted from a linux host in the LAN. I want to access the volume name for backup logging purposes. An "ls -l" of this volume from Linux gives:

drwxrwxrwx 1 root root          0 2009-10-05 14:40 System\ Volume\ Information/

as a directory supposedly containing the volume name, further supposedly in Windows format. However, I cannot see the contents of this folder. I get a permission error:

> ls /offsite/System\ Volume\ Information/
/bin/ls: reading directory /offsite/System Volume Information/: Permission denied

How can I see the volume name of this drive?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Philip ElderTechnical Architect - HA/Compute/Storage

Commented:
SBS 2008 native backup only supports a directly connected USB drive. That is, a cable is connected between the drive and the server. SBS backup is then configured to use that drive as a destination.

Once that process has completed the drive becomes essentially useless to all other systems except the SBS server.

You could possibly use the native Windows Server 2008 backup to back up to a network share on that drive but this is not supported.

Third party backup software is another method.

Philip

Author

Commented:
Sorry I confused the issue by mentioning "backup". This question has nothing to do with backup. The drive is not used by SBS backup, nor was it ever formatted or name by SBS backup. Btw - I am using a 3rd party backup program (Acronis), but I repeat, this drive has nothing to do with that sort of backup and the Acronis backup is NOT going to that drive.

It is a normal 'ole 5TB, USB drive. I named the volume myself using Windows, Computer > right click on device > rename.

So, my question is, how do I read the volume label created BY WINDOWS on this drive from Linux? I want to read the volume name because I want to detect when the user switches drives.

Also, please don't respond with solutions having to do with creating another file on the drive from Linux (or wherever) that I can read. I am already doing that and for various reasons I want to be able to read the actual volume name, not an artificially created substitute.

THX
Although I have not completely understand what are you trying to do, you are looking for a way to see what is the name of this external drive from linux?! If that is the case, then please clarify what Linux distribution are you using? When you say that you have CIFS mounted the drive you mean through SMB (smbmount) or what?

In general what is see is that the error you get is logical, since the System Volume Information folder is a system folder. After all I don't understand why you need to access this folder since (and I copy from Microsoft site) "The System Volume Information folder is a hidden system folder that the System Restore tool uses to store its information and restore points. There is a System Volume Information folder on every partition on your computer."
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I am using the slackware distribution, kernel 2.4.29. cifs is similar to smb, but is newer (as I understand) and works for large files whereas smb can only handle files of 2GB. See http://www.experts-exchange.com/OS/Linux/Setup/Q_26400199.html?cid=1575#a33427077 for the discusion on this.

Why I want to do this isn't that interesting. This is a USB drive connected to SBS 2008 and I basically want to detect when someone changes the drive. I can create little tag files on the drive(s), but I'd really rather read the volume lable.

Windows creates the System Volume Information folder, as you say. I want to read the info in that folder from Linux. Surely there is a way.
Philip ElderTechnical Architect - HA/Compute/Storage

Commented:
IIRC, because that folder is a system folder it cannot be touched at the user level.

Philip
By "change the drive" you mean putting an other drive or changing the drive contents. If it's the first, then why don't you use different drive names from drive 1 and drive 2. If it is the second one, then you could propably use a script to check the time a file was last modified.
In any case I don't think there is a way to check the contents of the System Volume directory.

Author

Commented:
sorry about the delay in responding. webSynthesis: yes, by "changing the drive" I mean your first scenario: putting another drive. Your suggestion: "use different drive names" is exactly what I'm doing. Each of the drives has a different name. Now the trick is to be able to read that name! How do I do that? The name appears to be kept in the System Volume directory, which I can't seem to read.
The System Volume directory is not for storing the drive name, but for storing the restore points.
So let's do a recap. You have external usb drive, let's name it ext1 that under Windows has the name usb1 and one more external usb drive, let's name it ext2 with the windows name usb2. Both drives when connected to SBS2008 are recognized let's say as drive G: You have made this drive G: shared with the name Castor and on the linux you have mounted this Castor share on /mnt/offsite.

So you were thinking a way to get the actual Windows drive name (usb1 or usb2) by reading the System Colume directory in order to know when it is either disk ext1 or disk ext2.

Even if you give EVERYONE acces to the System Volume Information directory (http://support.microsoft.com/kb/309531) you will not get the Windows drive name, since this information is written on the partition, NOT on some system file or folder. Since when you mount the share to the linux machine you are actually using one more layer over the disk partition, you cannot read the actual partition information of the drive, so it is impossible - as far as i know and i can think - to get the Windows drive name.

So here is my reccomendation. Create a TXT file (under linux) with the name .diskext1 or .ext1 or .usb1 and make it hidden under windows. In that way it will be both hidden in Linux and Windows. On you script just use this TXT as a reference on what drive it is mounted!

Linux
$ echo > .ext1
$ ls -a | grep .ext?

The first command will create a hidden file named .ext1 and the second command will return ONLY hidden files starting with .ext (.ext1 in my example)
So whenever you want to check wich disk is ON just run ls -a | grep .ext?

I have attached a very simple bash shell script to check.

Windows
On windows you see dot linux files (hidden files) as simple uknown files you simply run ATTRIB +h +r .ext1 and the file is also hidden on Windows (and Read Only too).

I hope this makes your day better! :-)

#!/bin/bash
#
ERRMSG="There is not a correct backup drive mounted or the drive is corrupted!"
DRIVE_NAME=$(ls -a | grep .ext?)
if [ -z "$DRIVE_NAME" ]
then
echo $ERRMSG
exit 1
fi

if [ "$DRIVE_NAME" == ".ext1" ]
then
echo "Drive mounted is USB1!"
elif [ "$DRIVE_NAME" == ".ext2" ]
then
echo "Drive mounted is USB2!"
else
echo $ERRMSG
fi

Open in new window

Author

Commented:
OK, webSynthesis, I will throw in the towel on this. If it is impossible to read the Windows volume name I'll accept that. In fact, I had been doing something quite similar to your solution using a plain 'ole file to hold the name, so I will keep that as the solution.

Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial