Guest User

Linux-Windows symlink workaround

a guest
Dec 8th, 2024
59
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | Software | 0 0
  1. #AUTHOR: Erwin Iosef
  2. #Date:08/12/2024
  3.  
  4. The workaround works in three recurring tasks, one being in Linux.
  5. You may adapt this strategy to your particular use case or as an inspiration.
  6.  
  7. Objective: Make a Windows symlink pointing from "C:/Users/admin/Documents/My Games" to "E:/My Games" drive work in both Linux and Windows.
  8.  
  9. Workaround:
  10. So, First things:
  11.  
  12. I) In Windows:
  13. 1)Create a mount directory called C:/Edrive for E:/ via Windows: Computer Management-> Storage.
  14.  
  15. 2)Create a symlink from "C:/Users/admin/Documents/My Games" to "C:/Edrive/My Games" using relative paths, for that we'd use om cmd:
  16.  
  17. mklink /D "C:\Users\admin\Documents\My Games" "..\..\..\Edrive\My Games"
  18.  
  19. Since the mount directory will be rendered invalid by Linux and it's not going to turn into a regular folder when you turn off Windows either,
  20. the best thing to do is to create tasks that would mount and unmount the Edrive directory mount when you startup and shutdown Windows, respectively.
  21.  
  22.  
  23. II)In Windows
  24. 1)So you'll have to create two .bat files. One for mounting the mount directory when you startup Windows and the other to unmount when you shutdown Windows:
  25. i)For Mount_Edrive.bat
  26. @echo off
  27. mountvol C:/Edrive \\?\{Your VolumeGID}\
  28.  
  29. ii)For Unmount_Edrive.bat
  30. @echo off
  31. mountvol C:/Edrive /D
  32. NOTE: To see the volume GID for your drive, simply run 'mountvol' in cmd.
  33.  
  34. Save these files in your preferred directory(preferably in C:/ ,in a folder)
  35.  
  36. 2)In Run, enter gpedit.msc and create two tasks in Computer Configuration->Windows settings->Scripts(startup/shutdown) each corresponding to the two bat files.
  37. These scripts will run regardless of who's the user at startup and shutdown. If you want it for only your user there's User Configuration.
  38.  
  39.  
  40. Final step:
  41. III)In Linux: You will have to create a 'bind mount' directory from /path/to/C:/Edrive to /path/to/E:
  42. for the symlink to finally work in two OSes without much hindrance.
  43.  
  44. 1)Enter a line in /etc/fstab, preferably as the last:
  45.  
  46. /path/to/Edrive /path/to/E:/ auto, none bind,nofail 0 0
  47.  
  48. 2) Write changes.
  49.  
  50. Reboot and test changes in Linux and Windows.
  51.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment