Portable MinGW and MSYS
Sometimes I have to use Windows (for example in my university) and each time it turns out to be sort of a pain in the ass. Standard terminal window is not resizable, text editor is only able to handle DOS linebreaks, even grep is not present on some systems (on the others it is still not that functional) and the whole system is full of things that are opposite to obvious and seem very strange to me.
I decided to create a USB flash drive with a handy terminal, convenient text editor, compiler and popular Unix utilities. MinGW and MSYS seemed a good choice, but it needed some workarounds to be done to make my installation portable.
I was following the official installation instructions in a virtual machine.
First of all, download
mingw-get-setup.exe and run it.
Then, select your USB drive’s root as installation target.
This is what you will have on your flash drive after downloading the installer.
Select your desired options in the installer and apply. I only selected
mingw32-base (probably, you can leave it out if you don’t need a complier). And this is what you will have on your flash drive after.
To finish the installation, run
postinstall/pi.sh and answer it’s questions.
You can later add and remove packages with
mingw-get. I wanted to have terminal emulator and a text editor, so I also installed
Making it portable
I wrote this batch script
launch.bat on my flash drive that modifies
/etc/fstab to use correct Windows drive letter assigned to this flash drive and then launch mintty. It also clears the
PATH, so only MinGW and MSYS binaries are in the path, so utilities like
ping will not be accessible unless installed with
This does the trick. Now I can use my portable system almost on any Windows computer.
Adding pseudo package manager
Official MinGW documentation recommends installing software with
/mingw prefix which adds some extra mess to the system. So I would create a directory
/mingw/addons and install each package to
/mingw/addons/$pkgname. Each package will install binaries, headers, libraries and other resources. If any information needs to be altered to make the package portable, add it to
/mingw/addons/$pkgname/install.sh which will be executed each time when system starts.
To make the system see those files, add this to your
Now you generally will only need these steps to install new software:
./configure --prefix=/mingw/addons/$pkgname make make install
Now this system is more or less complete and easily extensible.
If you have similar portable system, you can use any Windows computer comfortably and compile your software with favorite compiler.