E Customizing Guest vServer Images
E.6 Modifying Swap
disk = ['file:<Path_to_System.img>,hda,w', 'file:<Path_to_ExtraDisk.img>,hdb,w']...
Where <path_to_System.img> is the path to the mount location, and <path_to_
ExtraDisk.img> is the path to ExtraDisk.img mounted on System.img. 4. Start the VM.
5. Find the device with the new disk by running the following command:
# cat /proc/partitions
This example procedure uses the /dev/xvdb device.
6. Make the disk ext3 as follows:
# mkfs.ext3 /dev/xvdb
7. Edit the /etc/fstab file to add the mount point for the disk:
/dev/xvdb /<mount_point> ext3 defaults 1 2
8. Mount the disk either by restarting the VM or by running the following command:
# mount -t ext3 /dev/xvdb <mount_point>
E.5 Example Procedure: Modifying Current Disk Size
This section describes how to modify the current disk size using modifyjeos. In the following example, the default disk size (4 GB) is modified to 10 GB:
# modifyjeos -f System.img -I 10240
E.6 Modifying Swap
This section describes how to modify the swap size (in MB). It contains the following topics:
■ Section E.6.1, "Example Procedure: Modifying Swap Size Using modifyjeos"
■ Section E.6.2, "Example Procedure: Adding Swap Manually"
E.6.1 Example Procedure: Modifying Swap Size Using modifyjeos
Note: This procedure applies to guest vServers created by using version 2.0.4.x.x (or earlier) of the Exalogic Guest Base Template. For guest vServers creating using v2.0.6 of the Exalogic Guest Base Template, you can manage disks by using LVM commands, as described in Appendix F, "Managing LVM Partitions on Guest vServers."
Mounting and Unmounting System.img
# modifyjeos -f System.img -S 1024
When you start the VM after modifying the swap size, it may start without any active swap. To fix this problem, complete the following steps:
1. Verify the label by running the following command:
# cat /etc/fstab
2. Look for a line starting with LABEL=SWAP and make sure that it is LABEL=SWAP-VM. If not, change it by editing the /etc/fstab file.
3. Reboot the VM. The swap should become active.
E.6.2 Example Procedure: Adding Swap Manually
To add swap manually (for example, 1 GB), complete the following steps:
1. Create a swap file as follows:
# dd if=/dev/zero of=<path_to_swap_file> bs=1M count=1024
This example uses a 1 GB swap. You can create a swap file of your desired size.
2. Run the following commands:
# mkswap <path_to_swap_file>
# swapon <path_to_swap_file>
3. Add an entry to the /etc/fstab file to persist the swap file in the case of reboots:
<path_to_swap_file> swap swap defaults 0 0
E.7 Mounting and Unmounting System.img
This section describes how to mount and unmount System.img for Logical Volume Manager (LVM) vServers and non-LVM vServers
E.7.1 Mounting System.img
This section describes how to mount System.img for LVM-based vServers and non-LVM vServers.
Note: This procedure applies to guest vServers created by using version 2.0.4.x.x (or earlier) of the Exalogic Guest Base Template. For guest vServers creating using v2.0.6 of the Exalogic Guest Base Template, you can manage disks by using LVM commands, as described in Appendix F, "Managing LVM Partitions on Guest vServers."
Note: This procedure applies to guest vServers created by using version 2.0.4.x.x (or earlier) of the Exalogic Guest Base Template. For guest vServers creating using v2.0.6 of the Exalogic Guest Base Template, you can manage disks by using LVM commands, as described in Appendix F, "Managing LVM Partitions on Guest vServers."
Mounting and Unmounting System.img
E.7.1.1 Mounting System.img for Non-LVM vServers
You can mount System.img and directly modify the mounted files. To mount System.img, do the following:
1. Create a script, say MountSystemImg.sh, containing the following code:
#!/bin/sh
# Export for later, i.e. during unmount export LOOP=`losetup -f`
export SYSTEMIMG=/mount/point
# Create temporary mount directory mkdir -p $SYSTEMIMG
# Create a loop for the system image losetup $LOOP System.img
kpartx -a $LOOP
mount /dev/mapper/`basename $LOOP`p2 $SYSTEMIMG
#Change directory to the mounted image cd $SYSTEMIMG
2. Run MountSystemImg.sh from the directory containing the System.img file.
E.7.1.2 Mounting System.img for LVM-Based vServers
You can mount System.img and directly modify the mounted files. To mount System.img, do the following:
1. Ensure LVM is installed on the mount host.
2. Create a script, say MountSystemImg.sh, containing the following code:
#!/bin/sh
This example uses the default template disk name VolGroup00. mount_location is the path to the location where you want to mount the image.
3. If you are mounting the image on an Oracle VM Server node, there may be a name conflict with VolGroup00. You must temporarily rename the host by adding the following command to the MountSystemImg.sh script, in the line after #!/bin/sh:
lvm vgrename VolGroup00 VolGroupTmp1
4. Run MountSystemImg.sh from the directory containing the System.img file.
Note: This procedure applies to guest vServers created by using version 2.0.4.x.x (or earlier) of the Exalogic Guest Base Template. For guest vServers creating using v2.0.6 of the Exalogic Guest Base Template, you can manage disks by using LVM commands, as
described in Appendix E.7.1.2, "Mounting System.img for LVM-Based vServers."
Mounting and Unmounting System.img
E.7.2 Unmounting System.img
This section describes how to unmount Exalogic VM images for LVM-based vServers and non-LVM vServers.
E.7.2.1 Unmounting System.img for Non-LVM vServers
To unmount System.img for non-LVM vServers, do the following:
1. Create a script, say UnmountSystemImg.sh, containing the following code:
#!/bin/sh
# Assuming $LOOP and $SYSTEMIMG exist from a previous run of MountSystemImg.sh umount $SYSTEMIMG
kpartx -d $LOOP losetup -d $LOOP
2. Run UnmountSystemImg.sh from the directory containing the System.img file.
E.7.2.2 Unmounting System.img for LVM-Based vServers
To unmount System.img for LVM-based vServers, do the following:
1. Create a script, say UnmountSystemImg.sh, containing the following code:
#!/bin/sh
# Assuming $LOOP exists from a previous run of MountSystemImg.sh umount /mount/point
lvm vgchange -an kpartx -d $LOOP losetup -d $LOOP
2. If you renamed the template disk in step 3 of Section E.7.1.2, "Mounting System.img for LVM-Based vServers", add the following command to the UnmountSystemImg.sh script, in the line after #!/bin/sh:
lvm vgrename VolGroupTmp1 VolGroup00
3. Run UnmountSystemImg.sh from the directory containing the System.img file.
Note: This procedure applies to guest vServers created by using version 2.0.4.x.x (or earlier) of the Exalogic Guest Base Template. For guest vServers creating using v2.0.6 of the Exalogic Guest Base Template, you can manage disks by using LVM commands, as described in Appendix E.7.2.2, "Unmounting System.img for LVM-Based vServers."