The current disk partitions and swap partitions are as follows:
[Root@bys3 ~]# Fdisk-l
disk/dev/sda:21.4 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 104391 Linux
/dev/sda2 2078 16587112+ Linux
/dev/sda3 2079 2600 4192965 Linux Swap/solaris
[Root@bys3 ~]# Free-m
Total used free shared buffers Cached
mem:2013 1850 163 0 131 1274
-/+ buffers/cache:444 1568
swap:4094 0 4094
There are two ways to add swap partitions: for TMPFS use see: http://blog.csdn.net/haibusuanyun/article/details/17199617 click Open link
1. Use the DD command to create a new file and mount it as swap
2. Add a new swap partition
The additional steps are:
1.free---To view the memory status command, you can display Memory,swap,buffer cache size and use status;
2.DD---reading, converting and outputting data commands; fdisk slicing new partitions
3.mkswap---Set swap area
4.swapon---Enable the swap area, equivalent to Mount;swapoff---Close the swap area, equivalent to Umount
5. Set the boot automatically mount/etc/fstab
#########################################################
1. Create a file using the DD command
[Root@bys3 ~]# dd if=/dev/zero of=/root/swap bs=1024 count=1024000---Here bs= is bytes,count a block, here is blocks 24000k=1000m
1024000+0 Records in
1024000+0 Records out
1048576000 bytes (1.0 GB) copied, 43.5605 seconds, 24.1 MB/s
[Root@bys3 ~]# Mkswap/root/swap
Setting up Swapspace version 1, size = 1048571 KB
[Root@bys3 ~]# Swapon/root/swap
[Root@bys3 ~]# Free-m
Total used free shared buffers Cached
mem:2013 1864 149 0 37 1389
-/+ buffers/cache:436 1577
The swap:5094 0 5094--compared with the first, increased by nearly 1000M.
Set up automatic mount-
[Root@bys3 ~]# Vi/etc/fstab
label=//ext3 Defaults 1 1
Label=/boot/boot ext3 Defaults 1 2
TMPFS/DEV/SHM TMPFS Defaults 0 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-sda3 Swap Defaults 0 0
/root/swap Swap Defaults 0 0
[Root@bys3 ~]# mount-a--no error, modify/etc/fstab success
View after reboot: The--swap space contains the newly added space.
[Oracle@bys3 ~]$ Free-m
Total used free shared buffers Cached
mem:2013 214 1799 0 15 150
-/+ buffers/cache:48 1964
swap:5094 0 5094
###############################################################################
2. Use FDISK to format unused partitions and mount them as swap partitions
[Root@bys3 ~]# Fdisk-l
disk/dev/sda:21.4 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 104391 Linux
/dev/sda2 2078 16587112+ Linux
/dev/sda3 2079 2600 4192965 Linux Swap/solaris
[Root@bys3 ~]# FDISK/DEV/SDA
The number of cylinders for this disk is set to 2610.
There is no wrong with then, but this is larger than 1024,
And could in certain setups cause problems with:
1 software that runs in boot time (e.g., old versions of LILO)
2) booting and partitioning software from the other OSs
(e.g., DOS fdisk, OS/2 fdisk)
Command (M for help): P
disk/dev/sda:21.4 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 104391 Linux
/dev/sda2 2078 16587112+ Linux
/dev/sda3 2079 2600 4192965 Linux Swap/solaris
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
E
Selected Partition 4
The cylinder (2601-2610, default 2601):
Using Default Value 2601
Last cylinder or +size or +sizem or +sizek (2601-2610, default 2610): +50m---New extended partition with 50M added.
Command (M for help): P
disk/dev/sda:21.4 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes