Convert Iso to VirtualBox Vdi

A issue recently is I have been playing with some new distributions as I have been doing more development using linux as my desktop operation system.

Before I would commit to using a new distribution os my main laptop operating system. I have been trailing them as virtual systems on VirtualBox.

Some of the distributions only come on live iso images, with no installation application. So my solution was to convert the live iso image into a VirtualBox vdi. The process is only one command to convert the iso to a vdi file.

Step One:
Locate the live iso image for conversion to a vdi file..

Once this is complete you want to add this to your VirtualBox machine. When you create your virtual machine, instead of creating your new your new vdi file, load the newly created vdi file.

Enjoy…

Move your Ubuntu system to a new machine.

ubuntu logo

Recently I changed Ubuntu laptops, where a simple dd would not have worked due to the large changes in hardware, like going from non efi to a efi system. So the disk structure had to change. Why doing a disk image was ruled out.

I worked out a way after some google searching that it was best to install a basic installation of Ubuntu 16.10 on the new laptop then, create a list of the packages I had installed upon the old laptop, which I could use to install upon the new laptop.

Once this was done, all you need to do was transfer your data and any configuration files to the new laptop.

Below is a method I used with the commands to replicate the packages from the old system to the new system.

Step One:
On the old machine run this command to make a list of the packages that exist.

You also need to copy from the old machine the /etc/apt directory. This has any repositories etc that are custom added like Mariadb as a example.

Step Two:
Now copy the files across to the new machine. Replace the /etc/apt directory from the old machine.

After you have done this with the pkglist file you can install the packages with the following command.

There is a chance that packages will not be found or it will crash during installation. To get around packages that are not found, you need to edit your pkglist file to continue with package installation. When a package crashes during configuration/installation. You need to kill the dpkg process then type the following command:

This will fix the current installation/configuration issues. You can then restart the command from step two to continue installation of packages.

Step Three:
You can now copy your configuration files and anything else from your old machine to the new machine.

A easier way long as there are not too many files in your machine would be to just archive your home directory and copy the archive file to the new machine and un-archive it in your home directory. This is easiest as there are a lot of hidden files in your home directory.

Now enjoy your new machine.

Auto Start VirtualBox VM’s…

logo-virtualboxI have started using virtualbox more and more for development work, and started getting a bit cheesed off on how to auto start the virtual machines on my server. Server being headless, I thought there would I would create some initialisation scripts under ubuntu get the job done. Then I thought, that someone else has already done this. Why reinvent the wheel, when the wheel has been invented.So a quick google search brought to a webpage that allowed me to start the vm’s when the host server starts up. The link to the original page is here The page is exactly what I needed but it missed a few steps that I have added here to simplify installation.

The issue is if you are not a root user you need to change the “VBOXUSER” in the above script, to the user you want.

If you have not added the user to the vboxusers on the host system the command is

Once this is done you need to add the script to the right /etc/rc*.d directories. This can be done simply with the command.

Once this is done, you should be ready to go unfortunately not. There is still one more process and that is populating the init script config file so it knows what virtual machines you have to start up. The following command I used to startup any unstarted virtual machines so the init script knew about them.

Once this was done you can run the init script if needed to test all your virtual machine startup.

Enjoy…

Reset Network Drivers to eth0…

Recently I came across a issue, where a added a dual network card to my ubuntu server and instead of taking over the eth0 and continuing down the line in sequence. Ubuntu decided to just continue the sequence of eth1 and eth2. So it got me wondering why does it not take over the eth0, since the old network card is not there. It seems the culprit is the udev rules and the network cache which remembers the mac address of the previous card and leaves that eth0. So no other ethernet card can be eth0, till you delete the network cache and udev regenerates the device with the new network card. To resolve this issue you just need to delete the fie below and reboot.

# rm -f /etc/udev/rules.d/70-persistent-net.rules

Install Squid in 600 seconds…

Currently I have a few firewall issues and while I am trying to resolve those issues. I decided I still needed to surf the internet. Till I can resolve my firewall issues, my option was to either surf with my mobile 3g unit, do my internet surfing only at work, or none at all. My other option was to install squid, as a bandaid issue.

The steps to get squid working is shown below.

# apt-add install squid3

We need to edit the squid configuration, before we can start the application.

# cd /etc/squid3
# cp squid.conf squid.conf.orig
# vi squid.conf

We now modify the squid configuration file, and modify, add the following into the squid.conf

acl our_networks src 192.168.0.0/24
acl localnet src 127.0.0.1/255.255.255.255
http_access allow our_networks
http_access allow localnet

An optional extra is if you want to modify the cache of squid the line that needs to be modified is

cache_dir ufs /var/spool/squid3 7000 16 256

The only part you may wish to modify is the 7000 which denotes the amount of megabytes. You can increase or decrease the size of your cache, depending on your needs.
Before you start squid you need to create the cache, with the following command.

# squid -z

You now can start squid with the command

# /etc/init.d/squid restart

Mac Wyse 60 Terminal Emulation…

Recently I have had to go back to Wyse 60 terminal emulation. I needed Wyse 60 terminal emulation due to legacy applications that have no other option but to be accessed. I could spend a fair few dollars on a commercial Wyse 60 terminal emulator. But in the spirit of free and open source, there is a free Wyse 60 terminal emulator out there for use.

You can download the Wyse 60 source from the following site.

http://code.google.com/p/wy60/

You can also directly download the source code from…

http://code.google.com/p/wy60/downloads/detail?name=wy60-2.0.9.tar.gz&can=2&q=

Once you have the source code downloaded, you can upack the source code.

# tar -xvfz wy60-2.0.9.tar.gz

Now we can compile the source code and install the executable.

# cd wy60-2.0.9
# ./configure
# make
# make install

Once you have compiled an installed the code. To activate the Wyse 60 emulation you type.

# wy60

Once this is run, you screen is now in Wyse 60 emulation, and you are able to ssh etc like any other screen, but in Wyse 60 emulation.
Or Under Ubuntu 10.04, you can just add this as a package.

Ubuntu 10.04

# apt-get install wy60

This is simpler than compiling the code.

Setup a PPTP server:

Recently I have been wanting to connect to my home network, from anywhere in the world. I want to connect back home via the device I have in my hands on me at the time. This could be my osx, windows 7, linux laptop, ipad, iphone or android device. I was originally thinking of setting up openvpn, as this was the easiest to setup, but decided against as there is clients for windows, android, linux, osx but not for ios devices. So I had to look for another virtual private network software. I was looking of setting up a ipsec/l2tp server, but decided at the moment against this, as it will take some time to setup and debug. This left me with pptp. This protocol is common to all devices and needed no extra client installed for it to run.

The following steps below will show you howto setup a pptp server.

Ubuntu 10.04

# apt-get install ppp pptpd pptp-linux

Enable port 22 in your firewall to pass throu for emergency purposes to ssh back into the machine. Here is the command to allow ssh through. You need to edit your permanent firewalls for this work on reboot.

# /sbin/iptables -A INPUT –protocol tcp –dport 22 -j ACCEPT

Enable port 1723 in your firewall to pass throu for pptp protocol to work on your system.

# /sbin/iptables -A INPUT –protocol tcp –dport 1723 -j ACCEPT
/sbin/iptables -A INPUT –protocol udp –dport 1723 -j ACCEPT

now we modify the /etc/pptpd.conf file. Look for the lines below in your file and modify them. These lines represent the ip address the vpn connections can have upon your local network.

localip 192.168.0.1 remoteip 192.168.0.241-255

The localip is the ip if the internal nic behind the wan port. This ip address is the ip of the pptp server. The remoteip is the ip’s allocated by the pptp process when you make a connection. I have allocated 15 ip’s. This allows me to have 15 devices connected to the server. I probably only need two ips allocated.

Now we modify /etc/ppp/pptpd.options edit the ms-dns entries to reflect the domain nameserver your network uses. A example is below. ms-dns 8.8.8.8 ms-dns 8.8.4.4

ms-dns 8.8.8.8
ms-dns 8.8.4.4

Also modify your file /etc/sysctl.conf

net.ipv4.ip_forward=1

No we need to restart the system controls. The other option than below is restarting the machine.

# sysctl -p

You now need to add users to the system, so we can make a login into the pptp server. You modify the /etc/ppp/chap-secrets file.

username <TAB> * <TAB> user-password <TAB> *

You now need to restart the pptpd daemon for all the changes to be implemented.

# /etc/init.d/pptpd restart

Create a VirtualBox Headless Machine…

More and more I have been running Virtualbox virtual servers upon my main Ubuntu 10.04 server. I used to create the virtual server upon my Macbook Pro 13″, then export the image, and reimport the image upon the linux headless server. Recently I found it was much easier to create the VirtualBox server upon a headless linux server. Certainly creating the virtual server upon a guy based tool is a lot easier, but it does not save time when you need to export and import the image across to the linux server.

The following steps below will show you howto setup a VirtualBox virtual headless server.

Ubuntu 10.04.03

We now create and register the virtual server with the command VBoxManage.

# VBoxManage createvm -name “server” –ostype Ubuntu_64 –register

We allocated the amount of memory the virtual server will have, the sequence of boot, e.g. dvd first, and which either net adapter does the virtual machine attach itself too. The memory we have allocated is 1024mb and the ethernet it uses is eth4.

# VBoxManage modifyvm “server” –memory 1024 –acpi on –boot1 dvd –nic1 bridged –bridge adapter1 eth4

We now create the hard disk or virtual disk for the virtual server. We allocated 100gb of hard disk space, and store the virtual hard disk file in /home/vbox

# VBoxManage createvdi –filename “/home/vbox/server.vdi” –size 100000

We state that the virtual server uses a ide controller. We can use ahci also, but ide is safe to use.

# VBoxManage storagectl “server” –name “IDE Controller” –add ide

We state that the virtual server uses the ide controller and attach the vital server hard disk to the ide controller.

# VBoxManage storageattach “server” –storagectl “IDE Controller” –port 0 –device 0 –type hdd –medium “/home/vbox/server.vdi”

We need also attach the dvd driver to the ide storage controller. Also we attach the iso image to the dvd drive, so that when we boot the virtual server for the first time, it boots the  virtual dvd driver and uses the iso image.

# VBoxManage storageattach “server” –storagectl “IDE Controller” –port 1 –device 0 –type dvddrive –medium “/home/vbox/ubuntu-10.04.3-server-amd64.iso”

We now allow remote desktop software to connect to the virtual server.

# VBoxManage modifyvm “server” –vrde on”

We now set the port, we can connect to the virtual server on with the remote desktop software. We can connect to the virtual server on port 3392. You can use Microsoft Remote Desktop Connection to connect.

# VBoxManage modifyvm “server” –vrdeport 3392

Once this is all done we can now startup the headless virtual server.

# VBoxHeadless –startvm “server” &

You can shutdown the virtual server with the following command.

# VBoxManage controlvm “server” poweroff

You can pause and restart the virtual server, but within the means of this document, I will not explain them, as they are commands not really needed.

Fujitsu P1620 a new hope…

I have had for a while a Fujitsu P1620 small form factor convertable. I have had for a while Windows Seven working upon the machine, but with only two gigabytes of ram, performance was limited at best. I have decided to install ubuntu 11.04, 64 bit desktop, and remove the gnome desktop for the xfce desktop. The other issue is the very slow 4200rpm 100gb hard disk. The installation was about sixty minutes to install. Half of the installation was downloading packages from the ubuntu repository. I used a external usb dvd rom drive to install ubuntu 11.04, 64 bit desktop. I will further along the way try to document the configuration of software and hardware as in the touchscreen which seems a tricky issue.

Converting RHEL to CentOS:

One of the biggest issues when running RedHat Linux in any verison is how to get updates when you do not pay for mantenance. As far as I know, you cannot get the updates from redhat for free once your 30 day trail is over. Many companies need to run redhat due to the applications we designed around redhat in linux. There are many ways to get around this when running different flavours of linux, but they necessary become a pain in the backside when it comes to this, as the next update of the flavour may break the application. A workaround is too use the free version of redhat enterprise linux which is CentOS. You can convert a redhat machine to CentOS, very easily. Below will show you the process of how it is done.

CentOS 5:

# yum clean all

# mkdir ~/centos

# cd ~/centos/

# wget http://mirror.centos.org/centos/5/os/i386/RPM-GPG-KEY-CentOS-5

# wget http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-8.el5.centos.i386.rpm

# wget http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.8-0.i386.rpm

# wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm

# wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm

# wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm

# rpm –import RPM-GPG-KEY-CentOS-5

# rpm -e –nodeps redhat-release

# rpm -e yum-rhn-plugin

# rpm -Uvh –force *.rpm

# yum upgrade

At the time of this post CentOS 5.8 is the highest release to upgrade a redhat enterprise 5 installation. I am yet to work out howto upgrade a redhat enterprise 6 release to CentOS 6.

update 2012.04.04