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
The intent of this blog is to share my work experience and spread some smart solutions on Linux to System Administrators. I'm hoping the solutions shared in this Blog would be helpful and come as a handy for Viewers. Brief about me: I have 18+ years work experience in System and Cloud Administration domain, primarily works on VMware Cloud Products (vSphere, vCloud Director, vRealize Automation, NSX Adv. Load Balancer, vROps).