Monday, July 28, 2014

Using mountpoint to check if a filesystem is mounted before doing something else

I use this to check to see if my reformatted usb mp3 player is mounted (improperly), and if so then remount the partition I want:

alias usbmp3='mountpoint -q /mnt/pt/sdb && ((\!$?)) && $(echo <password> | sudo -S umount /dev/sdb;echo <password> | sudo -S mount /dev/sdb1 /var/host/media/removable/USB\ Drive/;cd /var/host/media/removable/USB\ Drive/) || echo "/dev/sdb not mounted"'

No comments:

Post a Comment