The computer I am setting up has three partitions, one for Windows 10, one for Linux, and one for files and programs shared between them. Is there a way to install programs on the third partition (like Python, PyCharm, MATLAB, etc.) to work on both OSs or do I have to install on each OS their own version of Python, C++, etc? Is the third partition limited to sharing files or can it be used to share IDEs, applications, compilers, and interpreters?
3 Answers
You are not going to be able to install programs in the third partition so they can run on both OSes. There is a reason why you need to have different downloads depending on your OS, each OS has many different requirements for software.
You should be able to set it us so that licenses are shared, if you need them, and you may be able to set it up so that files that are produced are shared automatically, and maybe even IDE setting but the programs themselves will have to be installed in each system.
One workaround might be to set up x11 forwarding from one OS to the other but that would require you to have both OSes running at the same time which would be quite janky.
As a side note if you had 2 partitions with Ubuntu instead of Ubuntu and Windows this probably would be possible.

- 1,674
-
1What if I use Ubuntu Bash on Windows? – Ben Rei Mar 16 '18 at 00:12
-
@BenRei if you use Ubuntu Bash on Windows you might be able to do what you want without having to have a dedicated Ubuntu install. check out this guide on "How to run graphical Linux applications on Bash on Ubuntu on Windows 10" I know it's not quite what you asked but I thought I'd put that in here while I try to find out a better answer. – Jeff Mar 16 '18 at 11:59
For almost all programs, no. This is due to Windows and Linux having different API (Application Programming Interface) calls and system calls. API's are functions and define how programs communicate with one another. Typically, they are included in libraries or may be part of the operating system. System calls define how programs request hardware support/activity from the kernel. It is possible to translate API calls and system calls of one operating system into another, but it requires a tremendous amount of effort. WINE is actually a prime example of translating Windows APIs into POSIX (e.g. Linux) ones. This creates a compatibility layer between Windows and Linux, allowing some Windows software to run on Linux. Additionally, Windows and Linux have different binary executable formats. Windows has the Portable Executable (PE) format and Linux has the ELF (Executable Linkable Format).
All of that said, I don't think what you're trying to achieve is possible without significant effort. Maybe (big maybe) you could install WINE and configure it on your shared partition so that it could hold programs for both Windows and Linux. But that's a wild theory. What fellow user Jeff said regarding licenses and other files is more likely to be possible and much easier to accomplish.

- 266
You can do it for Ubuntu Bash on Windows
Here is my partition setup:
$ lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE,MODEL
NAME FSTYPE LABEL MOUNTPOINT SIZE MODEL
sda 931.5G HGST HTS721010A9
├─sda4 ntfs WINRETOOLS 450M
├─sda2 128M
├─sda5 ntfs Image 11.4G
├─sda3 ntfs HGST_Win10 /mnt/d 919G
└─sda1 vfat ESP 500M
nvme0n1 477G Samsung SSD 960 PRO 512GB
├─nvme0n1p5 ext4 NVMe_Ubuntu_16.0 / 44.6G
├─nvme0n1p3 16M
├─nvme0n1p1 ntfs 450M
├─nvme0n1p6 swap Linux Swap [SWAP] 7.9G
├─nvme0n1p4 ntfs NVMe_Win10 /mnt/c 414.9G
├─nvme0n1p2 vfat /boot/efi 99M
└─nvme0n1p7 ntfs Shared_WSL+Linux /mnt/e 9G
nvme0n1p7
is shared between Windows and Ubuntu
I setup a 9 GB partition that both WSL (Windows Subsystem for Linux) and Ubuntu can have in their paths and run programs. Here is the tree for it:
$ sudo tree /mnt/e -d
/mnt/e
├── bin
├── boot
│ └── grub
│ ├── fonts
│ ├── i386-pc
│ └── locale
├── Desktop
├── Documents
├── Downloads
│ └── WinScreeny-master
├── etc
│ ├── apt
│ │ ├── sources.list.d
│ │ └── trusted.gpg.d
│ ├── cron.d
│ │ └── test-directory
│ ├── cron.daily
│ ├── cron.hourly
│ ├── cron.monthly
│ ├── cron.weekly
│ ├── default
│ ├── ssmtp
│ └── systemd
│ ├── network
│ ├── system
│ │ ├── bluetooth.target.wants
│ │ ├── default.target.wants
│ │ ├── display-manager.service.wants
│ │ ├── final.target.wants
│ │ ├── getty.target.wants
│ │ ├── graphical.target.wants
│ │ ├── hibernate.target.wants
│ │ ├── hybrid-sleep.target.wants
│ │ ├── multi-user.target.wants
│ │ ├── network-online.target.wants
│ │ ├── paths.target.wants
│ │ ├── printer.target.wants
│ │ ├── sleep.target.wants
│ │ ├── sockets.target.wants
│ │ ├── suspend.target.wants
│ │ ├── sysinit.target.wants
│ │ └── timers.target.wants
│ └── user
├── lib
│ └── systemd
│ └── system-sleep
├── $RECYCLE.BIN
│ └── S-1-5-21-1568003092-1971238075-3041751339-1001
├── System Volume Information
├── Temporary Work
├── usr
│ ├── local
│ │ └── bin
│ │ ├── bell
│ │ │ └── sounds
│ │ ├── startup-scripts
│ │ └── zap
│ │ └── Assembly-Intro-hello
│ │ ├── BeOS
│ │ ├── FreeBSD
│ │ └── Linux
│ └── share
│ └── plymouth
│ └── themes
│ ├── details
│ ├── earth-sunrise
│ ├── text
│ ├── tribar
│ ├── ubuntu-logo
│ └── ubuntu-text
└── wsl-linux-tmp
71 directories
Making a hybrid program
I took one of my bash programs: Application that will lock screen after a set amount of time for Ubuntu and modified it to recognize when running under Windows 10 and issue powershell
commands instead of the Ubuntu commands for message bubbles and system sounds.
For example, here's a code snippet for checking if the environment is Windows and using a different command than in Ubuntu:
if [[ $WSL_running == true ]]; then
powershell.exe -c '(New-Object Media.SoundPlayer "C:\Windows\Media\notify.wav").PlaySync();'
else
ogg123 '/usr/share/sounds/ubuntu/stereo/phone-outgoing-calling.ogg' ;
fi
Here's the complete bash code after the application was made a Windows / Ubuntu hybrid:
$ cat /mnt/e/bin/lock-screen-timer
#!/bin/bash
NAME: lock-screen-timer
PATH: $HOME/bin
DESC: Lock screen in x minutes
CALL: Place on Desktop or call from Terminal with "lock-screen-timer 99"
DATE: Created Nov 19, 2016. Last revision Nov 12, 2017.
UPDT: Updated to support WSL (Windows Subsystem for Linux)
NOTE: Time defaults to 30 minutes.
If previous version is sleeping it is killed.
Zenity is used to pop up entry box to get number of minutes.
If zenity is closed with X or Cancel, no screen lock timer is launched.
Pending lock warning displayed on-screen at set intervals.
Write time remaining to ~/.lock-screen-timer-remaining
MINUTES="$1" # Optional parameter 1 when invoked from terminal.
if no parameters set default MINUTES to 30
if [ $# == 0 ]; then
MINUTES=30
fi
DEFAULT="$MINUTES" # When looping, minutes count down to zero. Save deafult for subsequent timers.
Check if lock screen timer already running
pID=$(pgrep -f "${0##*/}") # All PIDs matching lock-screen-timer name
PREVIOUS=$(echo "$pID" | grep -v ^"$$") # Strip out this running copy ($$$)
if [ "$PREVIOUS" != "" ]; then
kill "$PREVIOUS"
rm ~/.lock-screen-timer-remaining
zenity --info --title="Lock screen timer already running" --text="Previous lock screen timer has been terminated."
fi
Running under WSL (Windows Subsystem for Linux)?
if cat /proc/version | grep Microsoft; then
WSL_running=true
else
WSL_running=false
fi
while true ; do # loop until cancel
# Get number of minutes until lock from user
MINUTES=$(zenity --entry --title="Lock screen timer" --text="Set number of minutes until lock" --entry-text="$DEFAULT")
RESULT=$? # Zenity return code
if [ $RESULT != 0 ]; then
break ; # break out of timer lock screen loop and end this script.
fi
DEFAULT="$MINUTES" # Save deafult for subsequent timers.
if [[ $MINUTES == 0 ]] || [[ $MINUTES == "" ]]; then
break ; # zero minutes considered cancel.
fi
# Loop for X minutes, testing each minute for alert message.
(( ++MINUTES ))
while (( --MINUTES > 0 )); do
case $MINUTES in 1|2|3|5|10|15|30|45|60|120|480|960|1920)
notify-send --urgency=critical --icon=/usr/share/icons/gnome/256x256/status/appointment-soon.png "Locking screen in ""$MINUTES"" minute(s)." ;
if [[ $WSL_running == true ]]; then
powershell.exe -c '(New-Object Media.SoundPlayer "C:\Windows\Media\notify.wav").PlaySync();'
else
ogg123 '/usr/share/sounds/ubuntu/stereo/phone-outgoing-calling.ogg' ;
fi
;;
esac;
# Record number of minutes remaining to file other processes can read.
echo "$MINUTES Minutes" > ~/.lock-screen-timer-remaining
sleep 60
done
rm ~/.lock-screen-timer-remaining # Remove work file others can see our progress with
if [[ $WSL_running == true ]]; then
# Call lock screen for Windows 10
rundll32.exe user32.dll,LockWorkStation
else
# Call screen saver lock for Ubuntu versions > 14.04.
dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
fi
# Reset sound to Laptop or HDMI TV - Uncomment to fix sound device changing
# sleep 5 # HDMI deactivates when screen turned off. Give 5 seconds for TV to resync screen.
# hotplugtv
done # End of while loop getting minutes to next lock screen
exit 0 # Closed dialog box or "Cancel" selected.

- 102,282
-
Interesting, so you got this to work for your own BASH script (or at least one you could change the code for) but have you tested things like IDEs or other complex programs like OP is trying to do? – Jeff Mar 16 '18 at 11:45
-
@Jeff Yes it works perfectly and it only took a little googling into powershell. Unfortunately I'm still a beginning bash scripter and haven't moved up the food chain to Python yet. It might be either in Python if libraries for Ubuntu and libraries for Windows are automatically sourced. Not sure though... – WinEunuuchs2Unix Mar 16 '18 at 11:48