Showing posts with label networking. Show all posts
Showing posts with label networking. Show all posts

Wednesday, January 18, 2023

Save linux output to jpg or image file

 There are cases where from the Linux terminal, it is required to post the output as an attachment in jpg or png. If ImageMagick is installed, this can be done easily, otherwise they use the traditional command pr to provide the output to printer.

Pre-requisite

Install ImageMagick

Combine the command convert with the output. E.g. output of the route command can be saved as png

route  | convert label:@- myroutetable.png

Next to add data into the png image.

$ convert myroutetable.png \

>  -set 'Copyright' 'CC-BY-SA 4.0'\

>  -set 'Title' 'Routing Table for Linux' \

> routetable.png


The content can then be viewed by the command hexdump

hexdump -C routetable.png

Or

strings routetable.png




Friday, March 16, 2018

VNC Troubleshoot Cannot access vdagent virtio channel /dev/virtio-ports/

On Centos 7, the vncserver started for each service is able to launch and users can login remotely. Within 1 minute, this service crashes and the usual command (see below) to start the vncserver fails.

$ sudo systemctl start vncserver@:1

The reason for this failure is capture in the command;

$ sudo systemctl status vncserver@:1

There were 2 items to take note,
  1. Users were launching the vncviewer almost immediately upon the server boot up.
  2. The following error appears "Cannot access vdagent virtio channel /dev/virtio-ports/" upon checking the status.

Whats on the Linux?

Centos Linux version 7.4.1708 (Core)
Tigervnc version 1.8.0

Spice [reference Fedora]

Spice aims to provide a complete open source solution for interaction with virtualized desktop.  The Simple Protocol for Independent Computing Environments (SPICE) is used for client-server communication. Spice adds a QXL display device to QEMU and provides drivers for this device for both X and Windows. It also provides a Spice server and VDAgent to handle connections and transmit the information via the SPICE protocol to clients. The Spice project provides a Linux, Windows, and HTML5 client. There are experimental Mac OS X and Android clients as well.

This /dev/virtio-ports is created in this feature that modifies the current single-port virtio-console device to guests running on top of qemu and kvm. It exposes multiple ports to the guest in the form of simple char devices for simple IO between the guest and host userspaces. It also allows for multiple such devices to be exposed, lifting the current single device restriction.

Somehow, these were installed on the server.

$ rpm -qa \*spice\*
spice-vdagent-0.14.0-14.el7.x86_64
spice-server-0.12.8-2.el7.1.x86_64
spice-gtk3-0.33-6.el7_4.1.x86_64
spice-glib-0.33-6.el7_4.1.x86_64

The RPM documentation on spice-vdagent states
"* Client mouse mode (no need to grab mouse by client, no mouse lag)
this is handled by the daemon by feeding mouse events into the kernel via uinput. This will only work if the active X-session is running a spice-vdagent process so that its resolution can be determined.
* Automatic adjustment of the X-session resolution to the client resolution
* Support of copy and paste (text and images) between the active X-session and the client"

I make an assumption that if no virtualisations are needed on the server, its a matter of deleting these packages. However, I have an Android Emulator that have dependency on the virtio-ports. Its still a question mark if VNC depends on spice-vdagent.

Solution

Step 1. Start SPICE agent.

At the command line on the host server, start the spice agent.
$ sudo systemctl start spice-vdagentd.service

Check and ensure that this service runs at boot up.
$ sudo systemctl show spice-vdagentd |grep enable
UnitFileState=enabled
UnitFilePreset=enabled

Step 2. Give host server time

Allow the Linux server to fully boot up all processed before attempting to start a VNC client session.


Done

Wednesday, July 6, 2016

NMap, SSH and Matrix the Movie

Matrix the movie is one of the coolest movie with concepts that provoke thoughts of technology and politics.

Ever thought that open source was involved? Surprise, surprise, trinity was referring to the use of Nmap and SSH exploits.

See http://www.theregister.co.uk/2003/05/16/matrix_sequel_has_hacker_cred


Thursday, March 17, 2016

Centos 6 Checklist on Systems Security

Linux Security Checklist

A reliable server is only as good as it is maintained and due processes applied. A systems security checklist template for Centos 6 mentioned below serves to meet the basic security requirements. A more stringent and targeted checklist can be developed further.

This mainly records existing system details and follow common practices. Some stuff like SELinux is mentioned as permissive as this is what I have at the moment. Details should be updated to specific server needs. Another useful checklist is for web application deployment and can be found at http://tboxmy.blogspot.my/2011/06/linux-security-checklist_14.html.

Centos 6 Checklist on Systems Security (link)

Contents of the checklist includes;

Section A. Details of the system
Section B. Services
Section C. Essential files
Section D. Examples.




Monday, March 14, 2016

NFS Commands 101


Refer to previous article Setup File Sharing with NFS on Centos Linux.

I find NFS version 3 is the most commonly used and uses remote procedure call (RPC) to manage connection between client and server. The service called rpcbind in Centos 6 has replaced portmap to handle RPC (see nfs4). Version 3 onward support files larger than 2 Gb size.

Whenever an NFS server is restarted not gracefully, the service rpc.statd notifies NFS clients. When quota is applied to the NFS, the service rpc.rquotad handles quota information.

The file /etc/exports define which directories are available to NFS clients. Each share is placed on a separate line and it indicates which client can access along with the options. Default users access a share as the user nobody, where this can be overridden in the /etc/exports option.

E.g. The following /etc/exports shares the directory /data with the client 192.168.1.45. The client may read and write and mounts synchronously.

/data 192.168.1.45(rw,sync)

Or user connect as its own user

/data 192.168.1.45(rw,no_root_squash,sync)

Default ports used by NFS are 2049 for the NFS service and 111 for RPC service.

Here are a list of NFS version 3 commands. Most are at the client side unless specified.

General NFS Commands

Start and stop NFS service
# service nfs start
Or
# /etc/init.d/nfs start
Or
# service nfs stop

Enable NFS service at boot
#chkconfig nfs on

Refresh NFS server shares from /etc/exports
# exportfs -r

Unload and reload NFS shares from /etc/exports
# export -a

Check support for NFS on the kernel. Did you forget to compile kernel with NFS support?
# lsmod |grep nfs
or
# grep -i nfs /boot/config

Check if list of commands are running
# rpcinfo -p

Display NFS statistics as client
# nfsstat -c

Display use of io
# vmstat -s

Mounting NFS

Display available NFS mounts
# showmount -e servername

Mount an NFS share
# mount -t nfs servername:/the/sharename

Display if the NFS mount is full or its free space
# df -k


Troubleshoot reference


Friday, January 15, 2016

Raspbian Command Line Basics 101

A few commands to display configurations of Raspbian on a Raspberry Pi 2.

At the Raspbian terminal, users can access a whole load of information. These can be useful for troubleshooting graphics, program conflicts and networking issues.

GENERAL


1. Display version of the Raspbian.
$ lsb_release -a

DISPLAY CONFIGURATIONS


2. Display the GPU chip version
$ vcgencmd version

3. The monitor hdmi mode
$ vcgencmd get_config hdmi_mode

4. Display current configuration
$ tvservice -s
$ tvservice -d monitor.dat
Translate monitor.dat into a readable text
$ edidparser monitor.dat > monitor.txt
cat monitor.txt 

This will display the monitor capabilities. In order to change the monitor settings, edit /boot/config.txt and determine to use CEA or DMT with the following lines

CEA uses hdmi_group=1
DMT uses hdmi_group=2

5. Is the monitor using CEA or DMT
$ vcgencmd get_config hdmi_group

6. Display supported CEA mode for the monitor
$ tvservice -m CEA

NETWORKING


7. Display all IP devices configured
$ ip a
Or just eth0 device
$ ip addr show dev eth0

Raspbian: Example output of basic commands

Friday, January 8, 2016

Howto Configure Static IP Address for Raspberry Pi 2

This is specifically for Raspbian Linux on Raspberry Pi 2 (RPI) using a wired ethernet cable.

Step 1. Connect the ethernet cable.

By default this connection is called eth0. Ensure its connected, look for the blinking lights then steady light on the RPI.

Step 2. Configure the static network information.

In this example I am using the following static IP address information:
IP address: 10.1.1.100
Gateway: 10.1.1.2
DNS: 10.1.1.3
Broadcast: 10.1.255.255

At the Panel, right click the network icon and choose "WiFi Networks (dhcpcdui) Settings".

Choose following;
Configure: interface eth0
Automatically configure empty options: checked
IP Address: 10.1.1.100
Router: 10.1.1.10
DNS Server: 10.1.1.3

Click Apply. Close the window and reboot RPI.

Done.

Test using the web browser or access the terminal and try the ping command.

Reference: RPiconfig in elinux http://elinux.org/RPiconfig

Tuesday, December 8, 2015

Introduction to IPTABLES Tutorial

My notes on iptables commands.

Firewall tutorial for iptables
Contents:

  1. View
  2. Append rules
  3. Insert a rule
  4. Delete a rule
  5. Default Policy
  6. Saving the rules

The problem with devices and applications not being able to access the server is usually due to configuration of the iptables firewall. This can be configured on an application or through command line terminal.


Monday, September 7, 2015

Display Dnsmasq status on Nagios

This article is an example of adding a custom process status in Nagios here the server (10.10.2.1) is separate from the host (10.10.2.2). In Nagios reference there are lots of option for configurations.

Dnsmasq as a light weight alternative to named, will appear in the linux process. E.g. when issuing the command ps -C dnsmasq

Pre-configuration checklist:

Ensure NRPE is installed and working on the host.

Step 1: Update nrpe.cfg with following;

# vi /etc/nagios/nrpe.cfg

Add the line
command[check_dnsmasq]=/usr/lib64/nagios/plugins/check_procs -C dnsmasq -w 5 -c 10

Save and test the new nrpe command;
# /usr/lib64/nagios/plugins/check_procs -C dnsmasq -w 5 -c 10
PROCS OK: 1 process with command name 'dnsmasq'


Restart nrpe
#service nrpe restart

Step 2: Add this service to the Nagios host

# vi /etc/nagios/servers/server1.cfg

define service{
use generic-service
host_name lbserver2
service_description Dnsmasq
check_command check_nrpe!check_dnsmasq
}

Save and restart Nagios


These 2 step works for any services that the linux ps command can detect.

Install Nagiosgraph on Centos 6

This article is on how to install Nagiosgraph on Centos.

Nagiosgraph is a plugin to Nagios and it provides graphical display of information captured by Nagios.

Installation environment:
Centos 6.5 x86_64
Nagios version 3.5.1-1
Pre-requisite perl modules: rrd tool 1.4+, Nagios::Config, GD, Object

Step 1: Prepare Nagiosgraph 1.5 for installation

# wget http://downloads.sourceforge.net/project/nagiosgraph/nagiosgraph/1.5.2/nagiosgraph-1.5.2.tar.gz
#  tar xvzf nagiosgraph-1.5.2.tar.gz
#  cd nagiosgraph-1.5.2
# less README

Install Perl module if havent installed.
# ./install.pl --check-prereq
# yum install perl-rrdtool perl-GD perl-Nagios-Plugin
# cpan Nagios::Config
If there are many modules not installed, just press Enter (Yes), unless you have other config.

Check all dependencies are met.
# ./install.pl --check-prereq


Step 2: Install Nagiosgraph source

# install.pl --prefix=/usr/share/nagiosgraph
Follow the instructions online. I choose the default values where nagios and httpd (apache) files were not updated automatically.

Step 3: Post configuration

If in step 2, it was chosen to not modify apache and nagios, then following must be configured. All instructions are printed at end of the installation of Step 3.

nagios.cfg
In the nagios configuration file (nagios.cfg),
    add/change these lines:
# vi /etc/nagios/nagios.cfg

Edit value for
process_performance_data=1

Add following lines
# process nagios performance data using nagiosgraph
service_perfdata_file=/tmp/perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph

template.cfg
# vi /etc/nagios/objects/templates.cfg
define service {
        name    graphed-service
        action_url      /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
        register 0
}

command.cfg
# vi /etc/nagios/objects/commands.cfg

# command to process nagios performance data for nagiosgraph
define command {
  command_name process-service-perfdata-for-nagiosgraph
  command_line /usr/share/nagiosgraph/bin/insert.pl
}

Host service files. E.g. for servername server1, append to show the graph service
vi  /etc/nagios/servers/server1.cfg
define service{
use generic-service,graphed-service
host_name applicationser1
service_description Current Load
check_command check_nrpe!check_load
}

* In the apache configuration file (httpd.conf),
    add this line:

include /usr/share/nagiosgraph/etc/nagiosgraph-apache.conf

Restart nagios to start data collection:
# service nagios restart

Restart apache to enable display of graphs:
# service httpd restart
Nagioschart: Chart icon in Nagios page

Nagioschart: Configuration page

Troubleshoot

Check graphs are displaying data, open a web browser and enter the URL
http://serversite/nagiosgraph/cgi-bin/show.cgi

Check RRD is collecting data with the command
# ls /usr/share/nagiosgraph/var/rrd

Check the nagios configuration files for errors
# /usr/sbin/nagios -v /etc/nagios/nagios.cfg

To enable graph links and mouseovers, see README sections:
       Displaying Per-Service and Per-Host Graph Icons and Links
       Displaying Graphs in Nagios Mouseovers

Thursday, September 3, 2015

Howto add Dropbox as Backup to Kodi - OSMC on Raspberry Pi 2

This is generally for backup purpose.

Step 1: Create API in dropbox

Login to dropbox.com or create an account if you haven't.
Go to the URL https://www.dropbox.com/developers/apps
Click "Create"
Choose "Dropbox API app"
In Can you app be limited to its own folder, choose "Yes"
App Name: "Kodi backup"
Click check box for "I agree to...conditions"
Click "Create app"

Write down the values for
App key and App secret.


Step 2: Configure Dropbox in Kodi

Open the Kodi screen and click Programs ->Get more...
Choose "Backup"-> "Install"
Click "Configure", in tab "General", change Remote path type to "Dropbox".
Enter values for Dropbox key
and Dropbox Secret
Click "ok"
Click "Launch"


Step 3: Start the backup

AT THE KODI SCREEN

A popup window "XBMC Backup - Mode" will appear, choose "Backup"
DO NOT CLICK "OK"

Step 4: Locate dropbox authorization
AT THE SSH TERMINAL
Using SSH tool like Putty, login to the OSMC Raspberry Pi and look for the dropbox authorization key in the file kodi.log.
Type
$ grep dropbox /home/osmc/.kodi/temp/kodi.log


AT THE PC WEB BROWSER
Copy that URL to a web browser and when the API request appears, click "Allow"

Step 4: Start backup

Return back to the screen in Step 3 and click "Ok"

Backup should begin.

Check dropbox for a new folder with the backup contents in
Apps/Kodi backup

Done.

Other stuff to do with Dropbox is to stream your home videos.
**To access files on dropbox**
Open the Kodi screen and click Programs ->Get more...
Choose Dbmc (Dropbox add-on)
Click "Install"

Once Dbmc has completed installation, click Dbmc (Dropbox add-on)
Click "Configure"

Tuesday, September 1, 2015

Setup Centos as Nagios clients

Centos Linux servers can be monitored by Nagios remotely. This typically provides information of ping response, services running and system information.

The setup is fairly straight forward assuming Nagios server IP is 10.10.2.1 and uses port 5666.

Step 1: Install Nagios plugins and NRPE.

Read the NRPE documentation.
Login to the nagios host, e.g. 10.10.2.2
# yum install -y nagios-plugins-all nrpe net-snmp

Edit /etc/nagios/nrpe.cfg with these 2 values

server_address=127.0.0.1
or the nagios IP

allowed_hosts=10.10.2.1
or the nagios IP

Example to enable monitoring of http is to have this line;
command[check_http]=/usr/lib64/nagios/plugins/check_http -I 10.10.2.2 -w 5 -c 10

Step 2: Start NRPE

# service nrpe start
# chkconfig nrpe on

Test with
 /usr/lib64/nagios/plugins/check_nrpe -H 10.10.2.2 -c check_load

Step 3: Allow monitoring through firewall

E.g. if using IPTABLES, make it as a rule at the top
# iptables -I INPUT 2 -p tcp -m tcp --dport 5666 -j ACCEPT
# iptables -L |grep 5666
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:5666

# service iptables save

Step 4: Configure Nagios server

Enable the services in the Nagios server, in this example 10.10.2.1
# vi /etc/nagios/servers/server1.cfg

define service{
use generic-service,graphed-service
host_name server1
service_description Http
check_command check_nrpe!check_http!-w 5 -c 10
}


Post installation

Check the service is running
# netstat -anlp |grep nrpe
tcp        0      0 10.240.1.14:5666            0.0.0.0:*                   LISTEN      12467/nrpe
unix  2      [ ]         DGRAM                    14250318 12467/nrpe

From the nagios server, test with 
/usr/lib64/nagios/plugins/check_nrpe -H 10.10.2.2

this should return the NRPE version.

/usr/lib64/nagios/plugins/check_nrpe -H 10.10.2.2 -c check_http

this should return the http check at the host.


Self reminder: TODO check_postgres source github

Tuesday, August 25, 2015

Access VirtualBox VM via SSH

A virtual machine provides lots of space for development, troubleshooting and learning. Sometimes its required to remotely access the virtual machine guest using SSH from the host. Virtualbox allow users to setup so many different type of virtual machines known as the guest.

The machine installed with VirtualBox is known as the host. In this example, the host is a MS Windows 7 computer with virtual machine guest OS being Centos Linux 6. SSH client such as Putty is run on the host computer and will attempt to connect to the virtual machine. This will also allow multiple guest OS to SSH between one another.

Step 1: Configure VirtualBox networking

Shutdown all guest virtual machines. Open VirtualBox Manager, click on the virtual machine to be configured and choose Settings ->Network. There should already be an existing network for access to the Internet. Nothing needs to be changed if you can already access the Internet from the guest OS.

Guest virtual machine default networking with access to Internet

Choose one of the unused Adapter (example Adapter 2) and configure the settings:
Attached to: Host-only Adapter
Name: VirtualBox Host-Only Ethernet Adapter



On the MS Windows, VirtualBox has already setup its own network 192.168.56.1 as can be seen below. The other IP is the dynamic IP used by host computer to access the Internet.



Step 2: Configure a static IP on guest OS.

Start the guest OS and login. Open a terminal as root and the new network device has been identified but we need to configure the IP to match that of the VirtualBox network 192.168.56.x.


In the case above, VirtualBox has already configured network device eth0 to access Internet. Check eth1 with

# ethtool eth1

The default eth1 if we started that network, it would use DHCP but we want a static IP so that we know the IP for SSH. We now need to create/edit eth1

vi /etc/sysconfig/network-scripts/ifcfg-eth1

Add/modify following lines;

DEVICE="eth1"
BOOTPROTO=static
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=192.168.56.10
NETMASK=255.255.255.0
IPV6INIT=no
NAME="System eth1"

Start the networking for eth1 and check that eth1 is using the new IP. 

Step 3: Restart the guest virtual machine.

Reboot the guest OS and test access to Internet and ability to SSH into the guest OSS from the host computer as can be seen below.

Guest VM network for Internet and SSH

The network routing is shown below.
Guest virtual machine network routing




Friday, August 7, 2015

What is OpenStack? Some Figures and statistics.

Cloud computing is still gaining some interest in public and private organisations. Many large organisations have shown interest and support for OpenStack as a software to deliver cloud platforms. With the source code to OpenStack freely accessible and welcomes community participation via the Foundation, it has also grown into an operating system of its own.

Recognition of the companies contributing to some parts of OpenStack include;
Those who are keen, should look up these developers to see how they contribute to the project.

There are some statistics that may be of interest at Openstack Activity Dashboard. Number are just numbers, but it makes lots of nice charts and puts some perspective of the project.

Some figures as of 6th Aug 2015;
  • Code developers; 3,971
  • Code submitters; 4,171
  • Launchpad participation; 8,881
  • IRC participants; 20,302
  • Ask participants; 4,035





Contribution by companies like HP, IBM and Red Hat;




There is a Malaysian OpenStack meetup on 13th Aug 2015 (Event), and its free.

Monday, June 22, 2015

Accessing password for D-Link provided by TM Unifi

As a note, if the admin password is lost or forgotten, there is a way to access the admin console for the D-Link routers (DIR-615) before 2015.

Some people say, better to just don't share it but, some may say that its public knowledge anyways.

Method 1: Brute force attack. Or in layman term, guess the admin password (Its either empty or admin).
Method 2: Use a feature within the router. Not sure if newer routers have the same feature. See below;

Step 1

Connect a PC to the router (LAN or wireless) and open a web browser URL at
192.168.0.1

This should show the admin page of the router.

Step 2

Change the URL to
192.168.0.1/model/__show_info.php?REQUIRE_FILE=/var/etc/httpasswd

It will display the login password for admin.


Kid: OMG...you mean I can change the password as much as I like but anyone can view the password?
Tech support: Err... yeah.
Kid: Time to change the router?
Tech support: You could. We can arrange for the technician to come over.

Update:
TM unifi has updated their routers remotely. Please check, if you see your password displayed, contact them for a fix.

Monday, September 29, 2014

Serious exploits in August and Sept 2014

These recent months have shown how the open source software model could handle (or is still handling) bugs that could be turned into an exploit of Linux servers. These are;

Shellshock (Sept 2014) - remotely take over a server.
BBC http://www.bbc.com/news/technology-29361794

Heartbleed (April 2014) - OpenSSL data could be intercepted.
BBC http://www.bbc.com/news/technology-28867113

The sheer number of Linux servers affected means that it is a serious threat and is wide spread. In Heartbleed, its patched but Shellshock is yet to have a patch to fully resolve the bug.

Interesting technical discussion on Shellshock is found at stackexchange.
https://unix.stackexchange.com/questions/157329/what-does-env-x-command-bash-do-and-why-is-it-insecure

How do you know if your shell is vulnerable? Hackernews recommends to run the following command in all the shell being used;

env X="() { :;} ; echo shellshock" /bin/sh -c "echo completed"
env X="() { :;} ; echo shellshock" `which bash` -c "echo completed"

If you see the text output "shellshock", please find a patch.

Chris, a contributor at Buzzfeed News, provided a good material on how 2 persons maintained the OpenSSL package, Steve Marquess and Stephen Henson. The commercial entity for this is known as OpenSSL Software Foundation.

Now doesn't it make you wonder who is responsible of bash shell and is it the same package for every Linux distro?


Tuesday, September 9, 2014

What is FTP?

FTP or File Transfer Protocol
"... is a standard network protocol used to transfer computer files from one host to another host over a TCP-based network, such as the Internet. FTP is built on a client-server architecture and uses separate control and data connections between the client and the server."
wikipedia.org

One reason why this is being replaced by other network protocol is in its exposure of the user password in plain text for a traditional FTP server. SSH and encrypted FTP sessions have replaced almost all new implementations these days.

Which ports are used by this service?
Standard ports used are port 20 (data) and 21 (command) but this may change depending on the server's settings. On the client FTP site, free standard ports higher than number 1023  is used.



This service by the FTP Server can provide active or passive connection and sometimes both. A simplified explanation in Slacksite.org entitled "Active FTP vs. Passive FTP, a Definitive Explanation" is a good read.

Typically, on the FTP server in Passive mode will require connection to several higher standard ports and this allows larger number of connections. In Active mode, limitation on the server is to how many connections can be done over that one port 20.

How to determine if its in Passive more?
After login to FTP server, type
quote PASV

How to establish connection to an FTP server?
Use an FTP client and enter the FTP server's URL. E.g. on Linux, to connect to the FTP server ftp.myserver.com

ftp ftp.myserver.com

-end-


Wednesday, February 5, 2014

Passwordless root SSH Public Key Authentication on CentOS 6

Need to remote login to linux servers?

Create a public key and store it in the remote server. By default it is recognised as authorized_keys but this is fully configurable. The ssh-keygen generated the public key with RSA that is by default called id_rsa.pub

A well written article to do this can be found at Passwordless root SSH Public Key Authentication on CentOS 6

An alternative sshpass command as mentioned in January 31, 2014 Linuxpromagazine seems to force users to make the password visible. Good that this is no available in a default Centos 6, as this will help to maintain good password practices. I.e. do not have password kept where anyone can read it.

Monday, June 27, 2011

Clone a VirtualBox disk

Duplicating a disk for a new VirtualBox VM requires addressing the disk UUID conflict with same value. The following steps address this matter.

1. Start VirtualBox graphical interface (GUI), and edit settings for the VM using the disk we wish to clone. E.g VM name is centos and the virtual disk as centos_hdd.vdi

2. Remove (Do not delete) this disk from the VM.

3. At a command prompt
VBoxManage clonehd centos_hdd.vdi copy_centos_hdd.vdi
VBoxManage internalcommands setvdiuuid copy_centos_hdd.vdi

The first command duplicates the virtual disk. In the second command we assign a new UUID to the new disk (copy_centos_hdd.vdi)

4. Return to VirtualBox GUI and attach back the centos.vdi to the VM.

5. Create a new VM to attach the copy_centos_hdd.vdi

The new virtual machine is ready to use the cloned virtual disk. As a note, why not just make more copies of the disk with new UUIDs in case you need another image.

Friday, February 11, 2011

Using shared folder on virtualbox OSE

Virtual box has a feature to access the host folder from a guest machine. Following is Centos 5.5 Linux guest that is set to access the Ubuntu 10.04 Linux host machine.

Host machine (Ubuntu)
- shared folder: /home/username/Downloads
- virtualbox share name: shared

Guest machine (Centos)
- mount share as /mnt/hostfolder

Step 1: Install Virtualbox Guest Additions.
Read the manual.

Step 2: Apply the shared folder for Virtualbox
Open the virtualmachine (guest) and go to Devices ->Shared Folders
Click on "Add Shared Folders", its a plus sign. Enter the following values
Folder path: /home/username/Downloads
Folder name (no white spaces): shared

Step 3: Mount the shared folder
Reboot the guest machine and mount with following command (use root/administrator);

mount -t vboxsf shared /mnt/hostfolder

Then apply the required permissions to the folder.

Blog Archive