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?

  • Why not auto mount your windows partition at boot. Symlinks should work fine.
    – Ron
    Apr 28, 2016 at 8:34
  • Yes I will use this solution if else fails. I wanted to avoid the "auto mount at start" for this partition. Don't ask why. I do not have a clear answer., just personal preference. Apr 28, 2016 at 14:11

1 Answer 1


You could use a script similar to this one


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .