I want to install Oracle10g in the Virtual Machine and find that the default swap space does not meet the minimum requirement. Because the physical memory I allocate is 1 GB, 2 GB swap space is required as required, by default, only 1 GB of swap space is available. To add a swap space, follow these steps:
Step 1: make sure that there is sufficient space in the system for swap. I am using KVM and want to add a swap file to an independent file system, add 2 GB swap file to/opt/Image
Step 2: add the swap file and set its size to 2 GB. Run the following command:
[Root @ Sense Image] # dd If =/dev/Zero of =/opt/image/swapbs = 1024 COUNT = 2048000
After a period of time, the following results are returned:
2048000 + 0 records in
2048000 + 0 records out
2097152000 bytes (2.1 GB) Copied, 272.867 seconds, 7.7 MB/S
Step 3: Create (SET) the swap space and run the mkswap command.
[Root @ Sense Image] # mkswap/opt/image/swap
Setting up swapspace version 1, size = 2097147 KB
Step 4: Check the size of the existing swap space and run the free command.
[Root @ Sense Image] # Free-m
Total Used Free Shared Buffers Cached
Mem: 1011 989 21 0 1 875
-/+ Buffers/cache: 112 898
Swap: 1027 0 1027
Or check the meminfo file.
Grep swaptotal/Proc/meminfo
Step 5: Start the newly added 2 GB swap space and run the Swapon command
[Root @ Sense Image] # Swapon/opt/image/swap
Step 6: confirm that the new 2G swap space has taken effect. Run the free command.
[[Root @ Sense Image] # Free-m
Total Used Free Shared Buffers Cached
Mem: 1011 995 15 0 4 877
-/+ Buffers/cache: 113 897
Swap: 3027 0 3027
Or check the meminfo file.
Grep swaptotal/Proc/meminfo
Step 7: Modify the/etc/fstab file so that the newly added 2G swap space will automatically take effect after the system restarts.
Add at the end of the file:
/Opt/image/swap Swap Swap defaults 0 0