Creating a Linux disk image

One of my colleagues needed to set up a server to run the software I was developing. To make his task easier, he suggested that I create a disk image from my development virtual machine.

The most important thing is the configuration would be taken from my Linux environment and so would be guaranteed to run with minimal setup required. As a bonus, he would also get the latest version of my code.

My colleague suggested using Remastersys. This is a tool which can image the Linux environment that it is running on.

Installation of Remastersys was straightforward.

$sudo apt-get update

$sudo apt-get install remastersys remastersys-gui

Once installed, I attempted to make a backup of my entire virtual machine.

$sudo remastersys backup custom.iso

It was soon obvious that this was not the best approach. I had a lot of large files from previous work. The disk image failed to create as I ran out of space on my fixed size virtual disk. On failure, the image size was over 11GB, which was way too big for my purpose.

My first reaction was to remove most of the large files.  This time the ISO file was created properly, but again it was large at over 3.4GB. My colleague was at a remote location, and I needed to share the image with him through DropBox. A quick check confirmed that my DropBox account was restricted to 2.5GB of data.

So, I needed a different approach. At this point, I realised that the image did not need most of the files in my home directory, which included a lot of test data as well as development tools. So, I could make a distribution image which excluded my home directory.

In order to accomplish this, I needed to move my project code out of its cloned repository in my home directory and move it to an accessible location for the distribution image. I had to update my Apache virtual hosting configuration and reload Apache. [Please see my last post , Installing Laravel on Linux Mint / Ubuntu/]

Once, this change was made and tested, I removed the Remastersys data related to creating the previous image.

$sudo remastersys clean

Now, I was ready to create my distribution image.

$sudo remastersys dist custom.iso

Once complete, the new ISO image was 2.4GB in size. While still large, it was manageable. I managed to upload the image to my DropBox account and share it with my colleague, who was able to set up his server with a single clean installation.

Finally, as the disk image was created, I reset my Apache virtual host to point to my cloned source code repository, so that I could continue my development as before.

Transferring Files to Virtual Box

To facilitate debugging some problems with encoding large video files using open source software running on Linux, I decided to run the encoding software on a virtual machine. Initially, I copied the data onto the Windows host from a memory stick.

The next step was to do the encoding. I needed to copy the source video to my VirtualBox virtual machine. My first thought was to use Virtual Box’s file sharing feature. To enable this, I had to install the VirtualBox Extensions. Then, I discovered that I would have to buy a licence, to use the Extensions beyond the trial period, as only VirtualBox itself is open source. To try it out, I opted to install the Extensions for the one month trial period. However, I got an error when trying to install the Extensions.  A second attempt yielded the same result.

I did not have time to resolve the error, as I needed to look at problems found with video encoding. To get working on our debugging, I copied the video files to the virtual machine using a USB stick, which turned out to be very slow and laborious.

Then, I remembered from previous research that I had configured port forwarding on my virtual machine. This experiment involved loading web pages on the Windows host served by Apache on the virtual machine (VM). I did this through port forwarding. At the time, I had also configured port forwarding to allow ssh access to the VM.

A colleague pointed out that scp uses the same port as ssh (port 22). So, I should be able to use port forwarding to transfer files using scp from Windows to my VM.  Please see the below screenshot.

Image

At this point, all that I needed to do was configure WinSCP on Windows to transfer to the local host using the port 3022 which was mapped to port 22 on the VM. So, on the WinSCP Login page, I set up a session with as follows:

File protocol: sftp

Hostname: 127.0.0.1

Port number: 3022

This worked very well. It still took some time to transfer the large video files back and forth. The files were so large that it was better to delete them from the VM once they had been encoded and copied back to the host via scp, as the VM’s virtual hard disk was limited in size.

It would be a faster work flow to enable file sharing as the shared folder would be available on both the host and VM simultaneously. However, this was a useful solution given the fact that the VirtualBox Extensions would not install on my system. In addition, if only occasional file transfer is involved, then the VirtualBox Extensions may be avoided, thus avoiding the associated licensing costs.

Using a virtual machine as a development environment

For my last project, I decided to use Linux as my development environment.  My laptop runs Windows and I wanted to try using Linux without setting up a dual-boot system. I tried VMware Player and installed Linux Mint with the Mate interface. I have Linux Mint with Cinnamon, so this would be a way to try a different variation.

I found the virtual machine to have good performance apart from the User Interface, which showed some lag for scrolling, especially when using MySQL Workbench, which depends on a graphical representation for the schema.

Overall, it was good to have a complete development environment which is separate from that of my main work. I configured the Apache environment to work with my repository. All of these changes are encapsulated in one folder on the host machine, which I zipped into an archive file. This makes it easier to make configuration changes as you can always roll back.

Recently, I looked at Oracle Virtual Box. This is open-source software. It looks to be quite a good program, and I plan on using it going forward for a personal project. I may move some of the work of my main project from Windows onto a Linux virtual machine, time permitting.