Implementing Virtual Disk


Creating a LINUX swap area on a VM vdisk is simple and easy. It is advantageous to use a swap area even during the initial install of LINUX under VM. The following outlines the steps required to implement a virtual disk swap area:

Make virtual disk available: Virtual disks can either be defined in the directory or dynamically by the user. For dynamic definition, there are some system level controls. The two following class B commands provide for a maximum amount of vdisk in the system, and a maximum value that can be defined by each user.

SET VDISK SYSLIM 120M 
set vdisk userlim 10M

Define a virtual disk: On the LINUX userid, select a minidisk device number which is unassigned. Define a VDISK using the available device number. Depending on the installation, the VDISK could be defined by a CP DEFINE command, such as the following (for a 10MB disk)

DEFine VFB-512 200 BLK 20480
 
or by an MDISK statement in the CP directory:
MDISK 0202 FB-512 V-DISK 20480 MR 

Format the disk at Initialization: Assuming your virtual machine will IPL CMS to set some environment options, you can utilize some shortcuts for using a virtual disk.

In the PROFILE EXEC for the LINUX machine, try to detect whether the VDISK is formatted, and format it if not, as follows, assuming a VDISK with device number 202 is to be used. Add these lines to the LINUX machine PROFILE EXEC:

....
'ACCESS 202 B'
if rc <> 0 Then Do /* Format if needed */
   push 'SWAP'     /* Volume label */
   push '1'        /* Allow format */
   'FORMAT 202 B ( BLK 4096'
   push '1'        /* Allow format */
   'RESERVE LINUX SWAP B6'
   End
'RELEASE B' 
Update LINUX Boot Parameter: Change the LINUX boot parameters to include the swap area using the minidisk driver:

mdisk=205,202

Boot Linux Kernel: IPL the LINUX kernel. After logging in as root, issue these commands to activate the swap space. Assuming minidisk 202 is defined as /dev/mndb, then:

mkswap /dev/mndb
swapon  /dev/mndb

Determine that the space is in use by:

swapon  -s

Configure Linux: Add a statement to the LINUX file "/etc/fstab" as follows:

/dev/mndb      swap         swap    defaults

This will bring up the swap space on the next IPL of LINUX. Don't forget to reduce the virtual machine size. We have found 24MB and 32MB satisfied our requirements.

Re-Sizing Vdisk: If the VDISK is re-allocated on a subsequent LOGON, it will be necessary to repeat the following commands after logging in as root.

mkswap  /dev/mndb
swapon  /dev/mndb