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

Mounting System.img

This section describes how to mount System.img for LVM-based vServers and non-LVM vServers.

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:

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.x.x of the Exalogic Guest Base Template, you can manage disks by using LVM commands, as described in Mounting System.img for LVM-Based vServers.

  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.

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
    
    export LOOP=`losetup -f`
    losetup $LOOP path_to_system.img
    kpartx -a $LOOP
    lvm pvscan
    lvm vgchange -ay
    mount /dev/mapper/VolGroup00-LogVol00 mount_location
    

    This example uses the default template disk name VolGroup00. mount_location is the path to the location at which 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.

Unmounting System.img

This section describes how to unmount Exalogic VM images for LVM-based vServers and non-LVM vServers.

Unmounting System.img for Non-LVM vServers

To unmount System.img for non-LVM vServers, do the following:

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.x.x of the Exalogic Guest Base Template, you can manage disks by using LVM commands, as described in Unmounting System.img for LVM-Based vServers.

  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.

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 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.