Monday, May 14, 2012

Perl subroutine to un-mount a file-system


sub UnMountVolume($)
{
  my $mountPoint = $_[0];
  print "Un-mounting $mountPoint\n";
  # Checking if the mount point exists
  if ( grep m{$mountPoint}, qx{/bin/mount} )
  {
    #Mount point exists, attempt to unmount it without force option
    system("/bin/umount $mountPoint");
  }
  else
  {
    print "$mountPoint is not mounted, please check it out\n";
  }
}

No comments:

Post a Comment

Popular Posts

About Me

My photo
I have started this blog to share my work experience and spread some smart solutions on Linux to Internet community. I'm hoping more people will get benefited from this blog. Brief about me: I have 14+ years experience working as System Admin and currently work with VMware.