Archive for May, 2009

SBDavid

Creating a Swap File

Creating a Swap File

At a shell prompt as root, type the following command with count being equal to the desired block size:

64 MB swap file is 65536

dd if=/dev/zero of=/swap bs=1024 count=65536

Setup the swap file with the command:

mkswap /swap

To enable the swap file immediately but not automatically at boot time:

swapon /swap
SBDavid

Adding Swap Space in LVM

To extend an LVM2 swap logical volume (assuming LogVol01 is the volume you want to extend):

1.Disable swapping for the associated logical volume:

# swapoff -v LogVol01

2.Resize the LVM2 logical volume by 500 MB:

# lvm lvresize LogVol01 -L +500M

3.Format the new swap space:

# mkswap LogVol01

4.Enable swap on the extended logical volume:

# swapon -va
SBDavid

Changing Virtual Files

Changing Virtual Files

As a general rule, most virtual files within the /proc/ directory are read-only. However, some can be used to adjust settings in the kernel. This is especially true for files in the /proc/sys/ subdirectory.
To change the value of a virtual file, use the echo command and a greater than symbol (>) to redirect the new value to the file. For example, to change the hostname on the fly, type:

echo www.serverbuddies.com > /proc/sys/kernel/hostname

Other files act as binary or Boolean switches. Typing cat /proc/sys/net/ipv4/ip_forward returns either a 0 or a 1. A 0 indicates that the kernel is not forwarding network packets. Using the echo command to change the value of the ip_forward file to 1 immediately turns packet forwarding on.

SBDavid

Using the sysctl Command

Using the sysctl Command

he /sbin/sysctl command is used to view, set, and automate kernel settings in the /proc/sys/ directory.
For a quick overview of all settings configurable in the /proc/sys/ directory, type:

/sbin/sysctl -a

The sysctl command can be used in place of echo to assign values to writable files in the /proc/sys/ directory. For example, instead of using the command

echo 1 > /proc/sys/kernel/sysrq

Use the equivalent sysctl command as follows:

sysctl -w kernel.sysrq=”1″
kernel.sysrq = 1
SBDavid

Reverting to an ext2 File System

Reverting to an ext2 File System

If you wish to revert a partition from ext3 to ext2 for any reason, you must first unmount the partition by logging in as root and typing:

umount block_device

Next, change the file system type to ext2 by typing the following command as root:

/sbin/tune2fs -O ^has_journal block_device

Check the partition for errors by typing the following command as root:

/sbin/e2fsck -y block_device

Then mount the partition again as ext2 file system by typing:

mount -t ext2 block_device /mount/point

Next, remove the .journal file at the root level of the partition by changing to the directory where it is mounted and typing:

rm -f .journal

Remember to update the /etc/fstab file.

« Prev - Next »