How Do You Place a Postgres Database on a Flash Drive on a Windows Host Running Oracle VirtualBox with a Linux Guest VM?

Problem scenario
You have Postgres installed on the Linux guest of Oracle VirtualBox.  You have storage capacity on the Windows host.  You can interactively work with smbclient to share files between the Linux guest and the Windows host.   You want to share files between the two servers without the interactive smb commands.  You want the Postgres database to reside on the Windows host.  This way your Linux guest hard disk does not have to be expanded but can run Postgres commands from your Linux guest.

How do you place a large Postgres database on a flash drive (or USB stick) on a shared folder on a Windows host running Oracle VirtualBox with a Linux guest VM?

There may be no definitive "best practice" way of doing this, but if there is insufficient space on the Linux guest running Oracle VirtualBox, you may want to configure the entire Linux guest to be on the flash drive itself.  In short, it may be advisable to create a new VM making sure that its files are on this USB stick.  This way the Postgres databases can be on the USB stick.

vboxsf is an Oracle VirtualBox technology that can present Windows folder shares for regular Linux operations.  However, mounting vboxsf file shares in Linux will not allow you to change the permissions of the directory as it is seen in Linux.  Postgres requires a data directory to have specific permissions.  Therefore it seems impossible as of February 2017 to have a data directory to reside on a Windows file share and work with Postgres that is installed on a Linux guest running on Oracle VirtualBox on a Windows host.  

When creating a new VM, do not accept the default location of the virtual hard disk.  Make sure the virtual hard disk is on the USB stick.  Warning:  installing even the minimal version of CentOS will take hours even if you are using USB 3.0 technology.  The I/O is slower with having a virtual disk on a USB stick.  But it is not unusable.  Installing the OS may be the most noticeable part.

Leave a comment

Your email address will not be published. Required fields are marked *