Hi Roger, I use this script for backing up data to an USB-disk. If the disk is not mounted, I will get a message. If the disk is mounted but I have not yet created a directory with todays date, I will get the same message. Maybe you can adapt the idea for your need? Regards, Göran ============= #!/usr/bin/perl -w use strict; my $datum = `date +"%Y-%m-%d"`; chomp ($datum); my $target = "/media/usb-lacie/" . $datum; if (! -d $target) { printf ("\nCan not find directory %s\n\n", $target); print "1) Make sure that the USB-drive is mounted.\n"; print "2) Make a directory with the current date.\n"; print "3) Run this script again...\n\n"; } else { $target .= "/."; system ("cp -a /etc /home /root /var /usr/local '$target'") == 0 or die "copy failed!"; } On Friday 11 August 2006 17.21, Roger Oberholtzer wrote:
I have a data collection system that collects data to hot swappable disks. Is there a way I can determine the type of media a file will be written to? Let me explain:
I have a diskless boot system. The Linux OS and all come from over the network. So, unless I mount a disk, anything written anywhere will be to RAM. If I mount a disk, the file will be written to the disk and not RAM. How can I determine that it is a disk and not RAM? The disks are mounted via udev. The mount point exists as a directory whether there is a disk mounted over it or not, so I cannot use that to see. I want to know if there is a disk mounted where I am writing, or somewhere above it.
As I read this question I too think it sounds odd. But I really would like to know. Maybe statvfs()? If the size of the media is greater than some test limit, (RAM in the machine perhaps) then it must be some mounted thing? Is there a better way?
-- Roger Oberholtzer
OPQ Systems AB Ramböll Sverige AB Kapellgränd 7 P.O. Box 4205 SE-102 65 Stockholm, Sweden
Tel: Int +46 8-615 60 20 Fax: Int +46 8-31 42 23