> ## Content Index
> Fetch the complete content index at: https://kudithipudi.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# HOW TO : Perl subfunction to unmount a partition in Linux
- URL: https://kudithipudi.org/how-to-perl-subfunction-to-unmount-a-partition-in-linux/
- Published: 2009-05-23T02:18:23.000Z
- Updated: 2009-05-23T02:18:23.000Z
- Description: For my record…here’s a snippet of perl code that can be called as a sub function to unmount a partition in Linux. Â The magic is in...
- Author: admin
- Tags: Programming, Technology, Uncategorized, #wp, #wp-post, #Import 2026-08-23 02:32

For my record…here’s a snippet of [perl](http://perl.org/?ref=kudithipudi.org) code that can be called as a sub function to unmount a partition in Linux. Â The magic is in the line “grep m{$mountPoint}, qx{/bin/mount}”, which essentially lets you check if the partition is already mounted or not.

```
sub UnMountVolume($)
{
    my $mountPoint = $_[0];

    print "Unmounting $mountPoint\n";
	# Check if the mount point exists
	if ( grep m{$mountPoint}, qx{/bin/mount} )
	{
		#Let's try to unmount it
		system("/bin/umount $mountPoint");
	}
	else
	{
		print "$mountPoint is not mounted, so didn't have to do anything\n";
	}
}

```

As with any perl code, I am sure there are a tons of ways to do this in a more efficient and “cool” way.