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?

NonStandardModel
  • 3,350
  • 7
  • 27
  • 45
  • Why not [auto mount](http://askubuntu.com/questions/46588/how-to-automount-ntfs-partitions) your windows partition at boot. Symlinks should work fine. – Ron Apr 28 '16 at 08: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. – NonStandardModel Apr 28 '16 at 14:11

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
  • 47,137
  • 13
  • 140
  • 258