Saturday, February 11, 2012

How To Add Swap Partition to Linux in Oracle VM

Hi,

I play with OVM this weekend and when I try to install Oracle database, it complains that I need increase swap space.

There is a 2 way to increase swap: by adding swap file or add a new swap partition.

Since there is not enough disk space for linux virtual disk in this Oracle virtual machine, so I decide to add new virtual disk as new swap partition.

Here is the step by step
1. Login oracle vm server manager console
2. Select virtual machine name and hit Configuration
3. Hit Storage tab
4. Hit Create New Virtual Disk, for example the new virtual disk is /dev/sdd
5. After virtual Disk created properly, login virtual machine
6. use su to change root user


[soa@vrremcc12c ~]$ su
Password:


7.  free -k to check how much swap space is currently used


[root@vrremcc12c soa]# free -k
             total       used       free     shared    buffers     cached
Mem:       6117676     192628    5925048          0       9368      56500
-/+ buffers/cache:     126760    5990916
Swap:      1052248          0    1052248

8.  user fdisk -l to check the new partition mounted
Disk /dev/sdd: 5368 MB, 5368709120 bytes
166 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 10292 * 512 = 5269504 bytes

Disk /dev/sdd doesn't contain a valid partition table

9 format the new partition by fdisk

[root@vrremcc12c soa]# /sbin/fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1018, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1018, default 1018):
Using default value 1018

Command (m for help): p

Disk /dev/sdd: 5368 MB, 5368709120 bytes
166 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 10292 * 512 = 5269504 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        1018     5238597   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

10. setup newly created partition by mkswap

[root@vrremcc12c soa]# /sbin/swapon -s
Filename                                Type            Size    Used    Priority
/dev/hda3                               partition       1052248 0       -1
[root@vrremcc12c soa]# /sbin/mkswap /dev/sdd1
Setting up swapspace version 1, size = 5364318 kB

11. enable swap partition 
[root@vrremcc12c soa]# /sbin/swapon /dev/sdd1
[root@vrremcc12c soa]# swap/sbin/on -s
Filename                                Type            Size    Used    Priority
/dev/hda3                               partition       1052248 0       -1
/dev/sdd1                               partition       5238588 0       -2
[root@vrremcc12c soa]#

12. update /etc/fstab file with new swap area
/dev/sdd1       swap    swap    defaults        0 0




No comments:

Post a Comment