Linux

  1. Home
  2. Computing & Technology
  3. Linux

From Authors, for About.com

    default location for all user-generated files. I could even have "mp3s", "cds" and other such directories in this location. The serious drawback of this approach--MS Windows may insist on messing up with this partition on re-install.

    • Partition the new hard drive. For example, if my new harddrive is the slave on the second IDE interface (perhaps the "fourth" IDE drive), I could use:

cfdisk /dev/hdd

or the more old-fashioned (and standard) tool:

fdisk /dev/hdd

If your drive is not "hdd" adjust the above command as needed.

hda -- first ide master (whole disk)

hdb -- first ide slave

hdc -- second ide master

hdd -- second ide slave

sda -- first scsi (whole disk)

sdb -- second scsi (whole disk)

...

sdp -- sixteenth scsi (whole disk)

For other disks, consult /usr/src/Linux/Documentation/devices.txt.

Most of the time, I want my Linux partitions to be of the type ext3 ("Linux").

Partitioning can be tricky--if you never have done it, read man fdisk and man cfdisk. It is very easy to delete a partition with all your data. Make sure you know which disk you are working with!

fdisk or cfdisk does not make any changes to the hard drive until I write the new partition layout. So if I make a bad mistake, I can always quit without writing. I write the layout to the drive only when I am completely done.

    • Format each partition. For example, to format the first partition, while checking for bad blocks (-c), I would do:

mkfs -c -t ext2 /dev/hdd1

    • Test the new partitions around. Mount the new partitions manually (the mount directory must exist and be empty). Copy a bunch of files to each partition. View/edit a couple of random files. Delete them all.

    • Copy data. Optional--only if you would like to move data from an old partition to a new partition. Go to the single-user mode (init 1). Mount the new partition manually. Copy the data from the old partition to the new partition. Careful with the old data, you probably don't want to lose it if you made a mistake, so I wouldn't delete it yet--I rename the top level directory appropriately. E.g.,

cp -R /usr/local/ /mnt/hdd1/

mv /usr/local/ /usr/local.old.backup_of_2001-04-21

    • Edit the file /etc/fstab. Modify it to reflect your new filesystem layout. Perhaps, insert the mountpoint for the new partition(s) or modify any old mountpoints as needed. For example, if moving /usr/local to its own partition, I would need to add to add a line like this:

/dev/hdd1 /usr/local ext2 defaults 1 2

    • Reboot and test. The alternative to reboot is to unmount old and mount new mount points. For example:

umount /usr/local

mount -a

but hard reboot may be a more rigorous test of the new layout.

    • Remove old data. After a few days, when I have the confidence everything is really working fine, I delete the old data (e.g., the directory /usr/local.oldbackup_of_2001-04-21).

5.2.13 Swap space

Swap is an extension of the physical memory of the computer. Most likely, you created a swap partition during the initial RedHat setup. You can verify the amount of swap space available on your system using:

cat /proc/meminfo

The general recommendation is that one should have: at least 4 MB swap space, at least 32 MB total (physical+swap) memory for a system running command-line-only, at least 64 MB of total (physical+swap) memory for a system running X-windows, and swap space at least 1.5 times the amount of the physical memory on the system.

If this is too complicated, you might want to have a swap twice as large as your physical (silicon) memory, but not less than 64 MB.

If you ever need to change your swap, here are some basics.

5.2.13.1 Swap partitions

You can have several swap partitions. [Older Linux kernels limit the size of each swap partition to up to approximately 124 MB, but the Linux kernels 2.2.x up do not have this restriction.] Here are the steps to create and enable a swap partition:

  • Create the partition of the proper size

Explore Linux

About.com Special Features

Linux

  1. Home
  2. Computing & Technology
  3. Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.