1

I have created a link to directory on windows partition on Desktop in Ubuntu 14.04. Because this partition will not be automatically mounted at startup the link is marked broken each time I power on computer. So I would like that when I click on a link the command ln -s -f "path1" "path2" would be executed before the link is "opened". How can this be done?

Other option would be to make a script with icon on Desktop. When double-clicked the script would check if the partition is mounted and mount it if it is not mounted and then open the Directory I want. But I have no idea how to make this? Any sugestion?

1 Answers1

0

You could use a script similar to this one

#!/bin/bash

mount | grep /dev/sda5 || gksu mount /dev/sda5 /path || zenity --error --text="Failed to mount"
ln -s -f "path1" "path2" || zenity --error --text="Failed to make link"
  1. mount get list of mounted nodes
  2. | grep /dev/... filter previous output of looking only for target device
  3. || gksu mount /dev/sda5 /path if previous command fails, it means it is not mounted then mount it. BTW, remove gksu if you don't need superuser power to mount.
  4. || zenity --error --text="Failed to mount" Raise an error message if previous command fails.

The 2nd command, seems simpler then the 1st.

user.dz
  • 48,105