Saturday, October 25, 2008

Creating a swap partition

For swap area give at least twice computer memory size, ex. +512M.
Default partition type is LINUX native, to change a Linux partition to a
swap partition with fdisk:

l # show partition
t 1 # change partition type for partition 1
Hex code: 82 # set type to Linux swap
w # write partition table

The new swap partion is set using the below listed commands to create
and enable the swap partition.

# mkswap -c /dev/hda2 size_in_blocks

# swapon /dev/hda

To enable all swap partitions:

# swapon -a

Check swap space usage with /usr/bin/top, /usr/bin/free and defined
partitions with /sbin/swapon (see Section 10.4) as follows:

$ /sbin/swapon -s

Filename Type Size Used Priority
/dev/hda5 partition 2048248 0 -1
/dev/hda6 partition 2048248 0 -2

Finally add the new swap partition to /etc/fstab:

/dev/hda14 / ext2 defaults 1 1
/dev/hda1 /boot ext2 defaults 1 2
/dev/hda13 /home ext2 defaults 1 2
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0
/dev/hda5 swap swap defaults 0 0
/dev/hda6 swap swap defaults 0 0
/dev/fd0 /mnt/floppy ext2 noauto,owner 0 0
none /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
#
nodea:/fsa /fsa nfs rw,soft,bg 0 0
nodea:/fsb /fsb nfs ro,soft,bg 0 0

N.B. With RH7.x file systems in /etc/fstab are listed by label instead
of using partition number, in the above example /etc/fstab
entry /dev/hda1 for the /boot file system, is mapped to LABEL=/boot for
RH7.x.

No comments: