Ajitabh Pandey's Soul & Syntax

Exploring systems, souls, and stories – one post at a time

Tag: Virtualization

  • Expanding HardDisk of VirtualBox Guest

    VirtualBox is a beautiful piece of virtualisation software created for users, first acquired by Sun and then by Oracle as a part of Sun acquisition. I have been using VirtualBox for quite a few testing projects, however until today have never needed to expand my hard drive on a guest. I am running a Windows 7 guest for some client side related tests. I started with a 25Gb disk for Windows 7, but after applying all security patches (I like my machines patched and upto-date), I realised that 25GB is all gone.

    This is where I love virtualisation. I do not need to buy a new disk if I need more space on my virtual machine (as far as my physical disk has enough space). I can just expand the existing virtual hard disk and get all the space I need. VirtualBox does not yet have a GUI option to do storage expansion work, but fortunately VirtualBox comes with an excellent command line, so I followed the following steps in order to increase my hard drive space.

    In order to see the virtual hard disk info, following command can be used.

    $ VBoxManage showhdinfo VirtualBox\ VMs/Win764/Win764.vdi
    UUID: e2272600-df31-4dbc-a71d-56af5f5714df
    Parent UUID: base
    State: created
    Type: normal (base)
    Location: /Users/ajitabhp/VirtualBox VMs/Win764/Win764.vdi
    Storage format: VDI
    Format variant: dynamic default
    Capacity: 25600 MBytes
    Size on disk: 25502 MBytes
    In use by VMs: Win764 (UUID: 1beda97f-4222-49ad-993e-342e1d44e288)
    

    To expand this to 50GB and then verify that the operation is done

    $ VBoxManage modifyhd --resize 50000 VirtualBox\ VMs/Win764/Win764.vdi
    0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
    $ VBoxManage showhdinfo VirtualBox\ VMs/Win764/Win764.vdi
    UUID:           e2272600-df31-4dbc-a71d-56af5f5714df
    Parent UUID:    base
    State:          created
    Type:           normal (base)
    Location:       /Users/ajitabhp/VirtualBox VMs/Win764/Win764.vdi
    Storage format: VDI
    Format variant: dynamic default
    Capacity:       50000 MBytes
    Size on disk:   25502 MBytes
    In use by VMs:  Win764 (UUID: 1beda97f-4222-49ad-993e-342e1d44e288)
    

    Now so far we have only been able to expand the Hard disk drive, but the partition table still would say that the NTFS filesystem is still the original size. However, we can not use Windows to expand the partition table of the same partition wherein it is installed. The System Rescue CD came to help here. I attached the System Rescue CD ISO to the windows virtual machine and booted the system.

    In the command prompt, I used the GNU parted to expand the partition table (partition 2 in my case)

    % parted resizepart 2 50GB /dev/sda
    

    In case you want to check which is your NTFS partition, which you want to expand use the following command –

    % parted print /dev/sda
    

    After expanding the partition table, we need to expand the NTFS filesystem on it, which can be done by ntfsresize utility as below. First I ran the utility in info mode to find out the exact size to which to expand to and then in dry run (test) mode and finally actually ran it.

    % ntfsresize --info /dev/sda2
    % ntfsresize -n -s 52294093824 /dev/sda2
    % ntfsresize -s 52294093824 /dev/sda2
    

    Finally remove the the System Rescue CD ISO file and boot the system normally in windows, a check will be force and you are done.

  • Adding/Removing the Resources from a Running Solaris Zone

    The zonecfg command is used to configure the zone. We can add and remove a resource from the solaris zone using zonecfg. Any change to zonecfg needs a reboot, but sometimes it is a requirement to dynamically add new resources to the zone without rebooting the zone. Also, we need to make sure that the addition of new resources to the zone are persistent across reboots.
    (more…)

  • Creating and Using MS DOS Virtual Machine in QEMU

    Create a disk image of desired size. I chose 50 MB

    $ dd if=/dev/zero of=msdos622.img bs=1k count=0 seek=50000
    

    Next boot from the DOS boot media. I had a bootable CD image.

    $ qemu -hda msdos622.img -cdrom DOS6.22_bootdisk.iso -boot d
    

    From the DOS prompt, create a partition on drive C using fdisk

    A:\> fdisk
    

    After the partition is created the machine will be rebooted. Once you get the DOS prompt back format the drive C and make it bootable:

    A:\> format c: /s
    

    The /s option of format command transfers the system to the drive.

    Next create a directory DOS in C:\ and copy all the utilities into it:

    A:\> mkdir c:\dos
    A:\> copy *.* c:\dos
    

    DOS is ready to be used. Now in order to transfer your old games and programs, you need to mount it as loopback device in linux. There is one problem with this. Since the image file has a partition table in it, when I tried to mount it, I got the following errors:

    $ sudo mount msdos622.img /mnt -o loop -t msdos
    mount: wrong fs type, bad option, bad superblock on /dev/loop0,
           missing codepage or helper program, or other error
           In some cases useful info is found in syslog - try
           dmesg | tail  or so
    

    To work this around we need to calculate the offset size of the partition using the fidisk -ul command:

    $ fdisk -ul msdos622.img
    You must set cylinders.
    You can do this from the extra functions menu.
    
    Disk msdos622.img: 0 MB, 0 bytes
    16 heads, 63 sectors/track, 0 cylinders, total 0 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Disk identifier: 0x00000000
    
           Device Boot      Start         End      Blocks   Id  System
    msdos622.img1   *          63       98783       49360+   6  FAT16
    

    To calculate the offset we need to multiply the starting block (63 in our case) by 512. If the image has multiple partitions then the same approach can be used and each partition can be individually mounted on a separate mount point.

    $ sudo mount -o loop,offset=32256 msdos622.img /mnt
    $ ls /mnt
    command.com  dos  drvspace.bin    io.sys    msdos.sys
    

    Now you can copy your old dos games and other files to /mnt.

  • Creating and Using MS DOS Virtual Machine in QEMU

    Being an old DOS user, sometimes there is an urge to go back to college days and recall how we used to do various things in DOS. Using dbase III, in a DOS environment reminds me of some of the great times I used to had in college as a student and later when I started my carrier as a Trainer.

    Today’s Virtualization technology had made it possible to run a DOS environment. Read on to find out how did I manage to set-up a MS-DOS VM using QEMU. Oh by the way I damaged my copy of WordStart 4 and Lotus 123 for DOS, if you happen to have one and don’t mind sharing please upload it to a public place and send me a link.

    Create a disk image of desired size. I chose 50 MB

    $ dd if=/dev/zero of=msdos622.img bs=1k count=0 seek=50000
    

    Next boot from the DOS boot media. I had a bootable CD image.

    $ qemu -hda msdos622.img -cdrom DOS6.22_bootdisk.iso -boot d
    

    From the DOS prompt, create a partition on drive C using fdisk

    A:\> fdisk
    

    After the partition is created the machine will be rebooted. Once you get the DOS prompt back format the drive C and make it bootable:

    A:\> format c: /s
    

    The /s option of format command transfers the system to the drive.

    Next create a directory DOS in C:\ and copy all the utilities into it:

    A:\> mkdir c:\dos
    A:\> copy *.* c:\dos
    

    DOS is ready to be used. Now in order to transfer your old games and programs, you need to mount it as loopback device in linux. There is one problem with this. Since the image file has a partition table in it, when I tried to mount it, I got the following errors:

    $ sudo mount msdos622.img /mnt -o loop -t msdos
      mount: wrong fs type, bad option, bad superblock on /dev/loop0,
      missing codepage or helper program, or other error
      In some cases useful info is found in syslog - try
      dmesg | tail  or so
    

    To work this around we need to calculate the offset size of the partition using the fidisk -ul command:

    $ fdisk -ul msdos622.img
    You must set cylinders.
    You can do this from the extra functions menu.
    
    Disk msdos622.img: 0 MB, 0 bytes
    16 heads, 63 sectors/track, 0 cylinders, total 0 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Disk identifier: 0x00000000
    
    Device Boot      Start         End      Blocks   Id  System
    msdos622.img1   *          63       98783       49360+   6  FAT16
    

    To calculate the offset we need to multiply the starting block (63 in our case) by 512. If the image has multiple partitions then the same approach can be used and each partition can be individually mounted on a seperate mount point.

    $ sudo mount -o loop,offset=32256 msdos622.img /mnt
    $ ls /mnt
    command.com dos  drvspace.bin    io.sys    msdos.sys
    

    Now you can copy your old dos games and other files to /mnt.

  • Solaris10 on VirtualBox

    I installed Solaris10 11/06 on VirtualBox 1.5.6 OSE. The first problem immediately after installation I faced was that of mouse not being captured by virtual machine. So I open a terminal window and start the vold and then ran the volcheck command.

    /etc/init.d/volmgt start
    volcheck
    

    The mouse started working after this. The reason for this I guess is because I did not had the mouse inside the virtual machine while booting. I need to confirm this.

    Moving the home directory of root from / to /root:

    Changing the home directory of root using “usermod” command does not work as the root user is logged in. So edit the /etc/passwd file and change root’s home directory to /root. Logout and login again. After that remove all the /.* files and /Desktop directory.

    vi /etc/passwd
    rm -rf /.*pwd
    rm -rf /Desktop
    

    Installing third-party tools

    Next I need to install third party tools in the virtual machine. I downloaded the “pkg-get” as:

    pkgadd -d http://www.blastwave.org/pkg_get-3.8.4-SunOS5.8-all-CSW.pkg
    

    Next I downloaded the static version of the wget utility using mozilla from http://www.blastwave.org/wget-i386.bin and renamed it as wget.
    Next I put the directory containing the wget utility and the /opt/csw/bin directory in default PATH. The first thing installed was wget itself, so that I can get rid of the static version.

    pkg-get install wget
    

    Patch check advanced is a utility which I installed next to apply patches to the operating system.

    pkg-get install pca
    

    The gnupg program was needed to verify the signatures on the catalogue files. This can be installed as:

    pkg-get install gnupg
    

    To install the gpg key of the blastwave repository use the following commands:

    wget --output-document=/tmp/gpg.key http://www.blastwave.org/mirrors.php
    gpg --import /tmp/gpg.key