6.14.5 Increasing the Size of the Swap Area
You can increase the amount of swap configured in a guest.
- In the KVM host, create a new disk image and attach
it to the guest.
For example, the following command adds the disk image
swap2.img
to the guestdm01db01vm01.example.com
:# /opt/exadata_ovm/vm_maker --create --disk-image /EXAVMIMAGES/swap2.img --attach --domain
dm01db01vm01.example.com
[INFO] Allocating an image for /EXAVMIMAGES/swap2.img, size 50.000000G... [INFO] Running 'qemu-img create /EXAVMIMAGES/swap2.img 50.000000G '... [INFO] Create label gpt on /EXAVMIMAGES/swap2.img. [INFO] Running 'parted -a none -s /EXAVMIMAGES/swap2.img mklabel gpt'... [INFO] Running 'losetup -P -f /EXAVMIMAGES/swap2.img'... [INFO] Finding loop device... [INFO] loop device is /dev/loop0 [INFO] Finding number of sectors... [INFO] 104857600 sectors [INFO] Releasing loop device /dev/loop0... [INFO] Removing device maps for /dev/loop0... [INFO] Running 'kpartx -d -v /dev/loop0'... [INFO] Removing loop device /dev/loop0... [INFO] ## [INFO] ## Finished . [INFO] ## [INFO] Created image /EXAVMIMAGES/swap2.img [INFO] File /EXAVMIMAGES/GuestImages/dm01db01vm01.example.com/swap2.img is a reflink from /EXAVMIMAGES/swap2.img and added as disk to domain dm01db01vm01.example.com [INFO] -------- MANUAL STEPS TO BE COMPLETED FOR MOUNTING THE DISK WITHIN DOMU dm01db01vm01 .example.com -------- [INFO] 1. Check a disk with name /dev/VGExaDbDisk.swap2.img/LVDBDisk exists. [INFO] - Run the command 'lvdisplay' to verify a disk with name '/dev/VGExaDbDisk.swap2.img/ LVDBDisk' exists. [INFO] 2. Create a directory that will to be used for mounting the new disk. [INFO] 3. Add the following line to /etc/fstab: /dev/VGExaDbDisk.swap2.img/LVDBDisk <mount_ point_from_step_2> <fstype> defaults 1 1 [INFO] 4. Mount the newly added disk to mount point through the command: mount -a.Do not perform the manual steps described in the output. However, take note of the logical volume path identified in manual step number 1.
In general, the logical volume path has the form:
/dev/VolumeGroupName/LogicalVolumeName
.In the example, the logical volume path is
/dev/VGExaDbDisk.swap2.img/LVDBDisk
. - In the guest, configure the new logical volume as a
swap device.
Use the
mkswap
command, and configure the new logical volume with a unique label, which is not currently in use in the/etc/fstab
file.In the following example, the swap device label is
SWAP2
and the logical volume path is/dev/VGExaDbDisk.swap2.img/LVDBDisk
.# mkswap -L SWAP2 /dev/VGExaDbDisk.swap2.img/LVDBDisk
- In the guest, enable the new swap device.
Use the
swapon
command with the-L
option and specify the label of the newly created swap device.For example:
# swapon -L SWAP2
- In the guest, verify that the new swap device is
enabled by using the
swapon -s
command.For example:
# swapon -s Filename Type Size Used Priority /dev/dm-3 partition 8388604 306108 -1 /dev/VGExaDb/LVDbSwap2 partition 8388604 0 -2
- In the guest, edit the
/etc/fstab
file to include the new swap device.You can copy the existing swap entry, and then change the LABEL value in the new entry to the label used to create the new swap device.
In the following example, the new swap device is added to the
/etc/fstab
file usingLABEL=SWAP2
.# cat /etc/fstab LABEL=DBSYS / ext4 defaults 1 1 LABEL=BOOT /boot ext4 defaults,nodev 1 1 tmpfs /dev/shm tmpfs defaults,size=7998m 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=SWAP swap swap defaults 0 0 LABEL=SWAP2 swap swap defaults 0 0 LABEL=DBORA /u01 ext4 defaults 1 1 /dev/xvdb /u01/app/12.1.0.2/grid ext4 defaults 1 1 /dev/xvdc /u01/app/oracle/product/12.1.0.2/dbhome_1 ext4 defaults 1 1
Parent topic: Increasing the Disk Space in a Guest