4.2: Accessing my drives

Contents of this section:
4.2 Accessing my drives
   4.2.1 Where are my drives?
   4.2.2 How can I access my CDROM?
   4.2.3 How to mount a floppy, zip drive, dos partition, or a network drive?
   4.2.4 How to mount a remote MS Windows filesystem through Samba?
   4.2.5 Any quick way to access a file on a DOS/Windows floppy?
   4.2.6 Mounting works when I am root. Can a normal user mount?
   4.2.7 Mounting command is too long, how can I simplify it with an alias?
   4.2.8 Can I mount automatically?
   4.2.9 How do I get my zip drive recognized?
   4.2.10 Can I set 32-bit hard drive IO?
   4.2.11 I reached the limit on the number of opened files (error message)
   4.2.12 I attached a new hard drive. What do I do to start using it?
   4.2.13  Swap space Swap partitions Swap files

4.2.1 Where are my drives?

Linux shows all the directories in one directory tree, irrespectively of what drives/hardware they are found on. Generally, this is a much better solution than the traditional DOS/Windows model--it completely abstracts the file system from the underlying hardware. You will appreciate this if you ever have to re-arrange or expand your hardware or add network resources. But for the users who are accustomed to the DOS way of dealing with drives, it adds some extra complexity.
To be brief, don't search for drive letters. There are none under Linux; the content of your disks appears as subdirectories on your single Linux filesystem (directory tree).   On default, the content of removable media does not appear automatically in these subdirectories--you have to "mount" your drives. See the next answers for details. You should also unmount a drive before ejecting the media.
You can access (read and write) a variety of drives and file systems from under Linux. This includes native Linux partitions, DOS and MS Windows partitions (on hard drives or floppies), ZIP and Jazz drives, and CDROM disks. Many less common file system types are also supported. This means that you can download your Linux software using Netscape for Windows, save the downloaded file on your MS Windows hard drive partition, and then boot Linux and copy the downloaded software from the Windows partition on your harddrive to the Linux partition, and finally install the software under Linux.

4.2.2 How can I access my CDROM?

Mount it. The mounting adds all the directories and files from your CD to your Linux directory tree so you can easily access them without the drive letter.
As root, you can mount the CDROM with a command like this:
mount -t auto /dev/cdrom /mnt/cdrom
If this works, the contents of your CD appears in the directory /mnt/cdrom
Chances are this command will not work for you right away--you may have to customize it. Here is how it works.
The command tells the operating system to mount a filesystem autodetecting the filesystem type ("-t auto"). The device is /dev/cdrom. The mountpoint (the directory where to which "mounting" takes place) is /mnt/cdrom. This directory must exist and be empty. If it does not exist, create it with:
mkdir /mnt/cdrom
If the mounting command fails, maybe the device /dev/cdrom does not exist on your system? Try

ls -l /dev/cdrom

 /dev/cdrom is just a convenient symbolic link to a real "device" that is mapped onto your hardware.  On an IDE system, chances are your real CD rom is on /dev/hdb.  Therefore, try /dev/hdb instead of /dev/cdrom in the mount command above:

mount -t auto /dev/hdb /mnt/cdrom

If this fails, you can try /dev/hdc or /dev/hdd, if your CD is an IDE CDROM on the second IDE interface. If none of them is your CDROM, maybe you don't have IDE but a SCSI CDROM? Then try /dev/sda, /dev/sr0, etc.

A short listing of possible drives could include:
hda -- the master drive on the first IDE interface (that's always the first hard drive)
hdb -- the slave drive on the first IDE interface (you must have at least two hard drives for that)
hdc -- the master drive on the second IDE interface (if you have two IDE interfaces on your computer, most newer computers do)
hdd -- the slave drive on the second IDE interface (if you have one)
sda   -- the first SCSI drive
sdb -- the second scsi drive ("sdc" is the third scsi drive, etc. There can be many scsi drive on a system).
sr0  -- the first scsi CD drive (sometimes called scd0)
sr1 --the second scsi CD drive (sometimes called scd1),  (sr2 is the third scsi CD drive, etc. There can be many scsi CD drives on the system).

It is a good idea to have a device /dev/cdrom anyway because some programs assume that it exists. If it does not exist on your system, you may create it as a symbolic link using, for example:
ln -s /dev/hdb /dev/cdrom
if your cdrom is the /dev/hdb drive.
If you cannot mount because "the device is already mounted or directory busy", perhaps the mountpoint /mnt/cdrom is your current directory. You have to change the directory to somewhere else in order to be able to mount to it; for example change the current directory to the root directory by issuing this command:
cd /
To unmount a mounted CD, exit the directory /mnt/cdrom and type as root:
umount /mnt/cdrom
Your CDROM may refuse to eject the media if it is not unmounted. Also, you may have problems mounting the next CD if the previous one was not unmounted. If you cannot unmount because "the device is busy", perhaps /mnt/cdrom (or any subdirectory underneath) is your current directory? You need to change your current directory to somewhere else out of the mountpoint in order to unmount the device.

4.2.3 How to mount a floppy, zip drive, DOS/Windows partition, or a network drive?

Very much the same as CDROM--see the previous answer if you did not read it.
Floppy. I can mount my floppy (as root) with:
mount -t auto /dev/fd0 /mnt/floppy
Again, make sure that the directory /mnt/floppy exists and is empty. Also, /mnt/floppy/ cannot be your current directory.
After a successful mount, the files from the floppy appear in the directory /mnt/floppy/ . All the users will be able to read the files, but only root will be able to modify/delete the files. Please read further if you wanted the users to be able to write to the floppy.
To unmount a floppy (you *must* do this before ejecting the disk!) use:
umount /mnt/floppy
If you cannot unmount because "the device is busy", perhaps the /mnt/floppy/ directory is your current directory. Exit it by typing (for example):
which will change your current directory to your home directory.
Zipdrive.  I mount the parallel port external zipdrive (scsi emulation) with:
mount -t vfat /dev/sda4 /mnt/zipdrive
The "-t vfat" is used here because zip disks come preformatted in the vfat filesystem, which is the filesystem of MS Windows with the long filename support. You won't be able to eject the disk without unmounting it.  Again, the directory must exist, be empty, and must not be your current working directory (see the previous answer).
I can mount an internal IDE zipdrive using:

mount -t vfat /dev/hdd4 /mnt/zipdrive

On my system, this is the second drive on the second IDE interface, hence "hdd"--replace it with "hdb" or "hdc" if necessary on your system.

A tip  from Alvaro Reguly <alvaro@reguly.net>.  "I have a ATAPI Zip Drive (recognized as ATAPI Floppy) so to make it work with Debian and kernel 2.4.3 I had to switch my BIOS setting from "Autodetect" to "None" (just the Zip channel of course), and mount it using

mount -t vfat /dev/hdb

(without the trailing 4!) "

All zipdrives (internal SCSI and IDE, external SCSI and parallel port) but the USB are supported under Linux (April 1999). See forward in this chapter for info on how to manually load a module (driver) for zipdrives if one does not load automatically on your system.

DOS/Windows partition. I use a dual boot system with both Linux and MS Windows on the same computer. I can access files on the DOS/Windows partition after mounting it with the following command:
mount -t vfat /dev/hda1 /mnt/dosdrive
Again, you may have to customize this command depending on what partition your DOS filesystem is. The "hda1" means the first IDE hard drive (hd a), first partition (1); "hda2" is the first IDE hard drive, second partition; "hda3"--the first IDE hard drive, third partition; "hdb1"--second IDE hard drive,  first partition (or just "hdb" if it is the CDROM installed as a slave on your first IDE interface). "hdc" is the third IDE drive, hdd is the fourth IDE drive. SCSI drives have analogous names but start with letters "sd", followed by the letter indicating the SCSI interface, followed by the number indicating the SCSI device id . For example sda4 means "first SCSI interface, id number 4".
To mount so that all the users can read and write, you may want to try:
mount -t vfat -o user,rw,exec,umask=000 /dev/hda1 /mnt/dosdrive
This uses options (-o user,rw,exec,umask=000) to give absolutely everybody all the permission to all files on your DOS /dev/hda1 partition (you should ask yourself if this is really safe on your system). If users still can't write to the DOS partitions, perhaps the permissions on your mountpoint need to be set. This command (executed by root) will set up the permissions on the mountpoint /mnt/dosdrive so that all users will be given rights to read, write and execute:
chmod a=rwx /mnt/dosdrive
Network File System (NFS). This is great for direct access to files that reside on another Linux computer. For mounting of a remote filesystem as NFS, first check if the NFS service is enabled (use the program setup). NFS also requires permission from the other computer. To configure the permissions on the server machine, run as root:
and adjust the setting under "Exported File Systems" menu.
If you prefer to do it manually, the permissions are set in the file /etc/exports . My /etc/exports looks like this:
/usr hacker(ro) mars(ro)
/home hacker(rw) mars(rw)
/mnt hacker(rw) mars(rw)
This gives the machines called hacker and mars the permission to mount the directories /usr/ (read-only access), /home and /mnt (read-write).
If you set up your NFS properly, you should now be able to mount a network directory using a command like this:
mount -t nfs mars:/home /mnt/mars_home
This mounts the contents of the directory /home/ on a machine called "mars" into the directory /mnt/mars_home/ (which must exist and be empty).
Many operating systems know NFS, but MS Windows doesn't. Therefore MS Windows remote shares have to be dealt with differently. See the next answer for details.

4.2.4 How to mount a remote MS Windows filesystem through Samba?

A remote MS Windows filesystem can be mounted onto a Linux filesystem through the Samba protocol (Samba must be installed, go here if it isn't). Type a command like this (as root):
smbmount //mars/windows /mnt/mars_windows -c marie
This mounts the MS Windows resource called windows from the MS Windows machine called mars. The mountpoint on the client computer is /mnt/mars_windows/ . The option "-c" specifies that the samba server is a machine called marie (this should not be necessary, but it is on my system).
For the above to work, the permission must be given on the MS Windows machine for sharing the directory or drive as a resource. To do this, on the MS Windows machine, enable the filesharing using the "control panel-network", then launch the "Windows Explorer", click the right mouse button on the drive or directory to share, click on properties, switch to the page "sharing", give yourself the permission and give the resource a name.
To unmount an MS Windows directory use:
smbumount /mnt/mars_windows
If you have problems, see:
man smbmount

4.2.5 Any quick way to access a file on a DOS/Windows floppy?

Use "mtools", no mounting required. For example, I can use the mdir command to quickly inspect the contents of the root directory on my DOS floppy:
mdir a:\
I can also use mcopy to copy the file "autoexec.bat" from the root directory on the floppy to my current directory on Linux:
mcopy a:\autoexec.bat .
You have to be root to be able to write to a floppy.
Type "mtools" to see the supported commands in the rich mtools set, which parallel the most popular DOS commands (for example: mformat, mtype, mren, mmove, mdel, mrd, mattrib, ...), and use manual pages if you have problems using them. For example:
man mtype
will show me how to display the contents of a text file on a DOS partition.
To access DOS drives other than a: or b:, you have to configure mtools so as to indicate which devices are associated with other DOS "drive letters". This is quite easy--you just edit and modify the file /etc/mtools.conf . I typically use pico to do it (as root):
pico /etc/mtools.conf
For example, my /etc/mtools contains a line like this:
drive c: file="/dev/hda1"
which instructs the mtools that the partition "/dev/hda1" will be called "c:" The setup of /etc/mtools.conf requires just uncommenting (removing the "#" at the beginning of the line) and adjusting the appropriate entry.

4.2.6 Mounting works when I am root. Can a normal user mount?

You have to edit the file /etc/fstab as root to give the normal users the permission to mount a particular drive. For example I can use the pico text editor to do this:
pico -w /etc/fstab
The option "-w" turns off the long line wrap.
Here is the content of my /etc/fstab:
/dev/hda2 / ext2 defaults 1 1
/dev/hdc3 /home ext2 defaults 1 2
/dev/hdc2 /usr ext2 defaults 1 2
/dev/hdc4 swap swap defaults 0 0
/dev/fd0 /mnt/floppy auto noauto,users,rw 0 0
/dev/cdrom /mnt/cdrom auto noauto,user,ro 0 0
/dev/sda4 /mnt/zipdrive vfat noauto,user,rw,exec 0 0
/dev/hda1 /mnt/dosdrive vfat noauto,user,rw 0 0
none /proc proc defaults 0 0
hacker:/mnt/cdrom /mnt/hacker_cdrom nfs noauto,user,ro 0 0
hacker:/mnt/floppy /mnt/hacker_floppy nfs noauto,user,rw 0 0
hacker:/home /mnt/hacker_home nfs noauto,user,rw 0 0
hacker:/usr /mnt/hacker_usr nfs noauto,user,rw 0 0
Each line contains six space-delimited fields (this means that each line has six entries separated by white space). The first field is the name of the device. The second field is the mountpoint (an existing directory on your Linux system to which the resource will be mounted). The third is filesystem type.  For removable media that may contain filesystems of several types, I use the option "auto" to let Linux probe which filesystem is currently present there. (The order in which they are probed is determined by the content of the file /etc/filesystems . You may want to make sure that it specifies "vfat" before "msdos" or the long DOS filenames may be cut short.) The fourth field contains options: "auto" = mount the filesystem on the system startup; "rw" = read and write allowed; "ro" = read only, "user" = users have the permission to mount this filesystem (one can also use "users" to allow a user to mount and another user to unmount--otherwise only the user that mounted the filesystem can unmount it), "exec" execution of programs is permitted from this filesystem. The number in the field 5 specifies if the filesystem is to be backed up during a system backup, the number in the field 6 determines if to check up the filesystem integrity during bootup. The hacker stuff in my /etc/fstab are filesystems on another computer (called "hacker") on my home network and it serves here as an example of how to mount network resources. Check man fstab for more info.
For example, if regular (non-root)  users have the permission to mount the cdrom (the "user" option is specified), they can mount it using a command like this:
mount /mnt/cdrom
The command which the root uses for mounting (see here) will not work for a regular user because the regular user is restricted by the options in /etc/fstab and therefore s/he cannot specify simultaneously both the device and the mountpoint.
For a regular user to be able to write to a disk or execute a program on it, s/he must also be given the appropriate permission on the "mountpoint" directory. For example, this will give all the users all the permissions (read, write, execute) on the directory /mnt/floppy :
chmod a+rwx /mnt/floppy
Now (also the "rw" option is specified for the floppy in the /etc/fstab) the user will be able to write to a floppy. If the "exec" option was enabled in the /etc/fstab, the user would also be able to execute programs from the floppy.
Please note that the DOS vfat file system doesn't know about the file permissions the way Linux does. Linux manages this during mounting by giving the default file permissions on the mounted filesystem: the user who mounted the filesystem will be the owner of all files and will be given the right to write to the filesystem (if "rw" was specified in fstab) but other users can only read.  If you wanted to change this behaviour, you could use the "umask=" option so that the appropriate line in your /etc/fstab may look like this example:
/dev/sda4 /mnt/zipdrive vfat noauto,users,rw,exec,umask=000 0 0
This gives absolutely everybody all the permissions on your zipdrive (mounting, unmounting, read, write, execute).
To summarize, the file /etc/fstab is the place to keep your defaults on how to mount filesystems and what kind of access is allowed for users. You really want to customize it to simplify mounting on your system.  Linux default mounting scheme is restrictive so as to be secure,  you may want to remove some restrictions when setting up Linux at home.

4.2.7 Mounting command is too long, how can I simplify it with an alias?

An alias is an abbreviation  of a more complex or often used command.  For creating aliases, I edit, as root, the file /etc/bashrc . This way the aliases are available for all the users on the system. (For creating user-specific aliases, I edit the file .bashrc in the user home directory.) The relevant part of my /etc/bashrc looks like this:
alias cdrom="mount -v /mnt/cdrom"
alias ucdrom="umount -v /mnt/cdrom"
alias dosdrive="mount -v /mnt/dosdrive"
alias udosdrive="umount -v /mnt/dosdrive"
alias zipdrive="mount -v /mnt/zipdrive"
alias uzipdrive="umount -v /mnt/zipdrive"
alias floppy="mount -v /mnt/floppy"
alias ufloppy="umount -v /mnt/floppy"
The option "-v" stands for "verbose", i.e., it tells Linux to talk to me a lot during mounting. For the aliases to take effect, the user has to re-login. Now the user can mount the floppy using this simple command:
and s/he can unmount it using

4.2.8 Can I mount automatically?

Yes, you can automatically mount a filesystem as you access it and unmount when you stop using it.  It works similar to what you have experienced under MS Windows. Yet, if you used removable media extensively under DOS or Windows, you must have noticed that automounting is not entirely foolproof.

There are two utilities for automounting under Linux, and they are callled "supermount" and "automount".

Supermount. Mandrake 7.2 gives you the option of using "supermount" as a setup option.  So the simplest way to "supermount" is to install latest Mandrake and select this option.  My /etc/fstab on a computer running Mandrake may contain the following lines:

/dev/hda3 / ext2 defaults 1 1
none /dev/pts devpts mode=0620 0 0
/dev/hda4 /home ext2 defaults 1 2
/mnt/cdrom /mnt/cdrom supermount fs=iso9660,dev=/dev/cdrom 0 0
/mnt/floppy /mnt/floppy supermount fs=vfat,dev=/dev/fd0 0 0
/mnt/zip /mnt/zip supermount fs=vfat,dev=/dev/zip 0 0
none /proc proc defaults 0 0
/dev/hdb2 /usr ext2 defaults 1 2
/dev/hdb5 swap swap defaults 0 0

In the example above, you may notice that I selected to supermount 3 filesystems: cdrom, floppy and zipdrive. I can edit the file /etc/fstab manually (e.g. with pico) or use the supermount command to customize the supermount to my needs.

Automount. To set up "automount", I first run the programs ntsysv (as root) and make sure that automount service ("autofs") is enabled.

Then, I configure automount by editing the files /etc/auto.master and /etc/auto.misc, e.g. (as root):
pico /etc/auto.master
My /etc/auto.master looks like that:
/misc /etc/auto.misc --timeout 1
This says that my automount devices will be mounted in the directory /misc (which must exist and be empty). My automount drives will automatically unmount one second after I stop using them (for example, after I exit the directory). This is a short time--you may choose a longer one. The detailed config file is /etc/auto.misc . Here is mine:
kernel -ro,soft,intr ftp.kernel.org:/pub/linux
cdrom -fstype=auto,ro :/dev/cdrom
floppy -fstype=auto,rw :/dev/fd0
zipdrive -fstype=vfat,rw :/dev/sda4
dosdrive -fstype=vfat,ro :/dev/hda1
hacker_cdrom -fstype=nfs,ro hacker:/mnt/cdrom
hacker_floppy -fstype=nfs,rw hacker:/mnt/floppy
hacker_usr -fstype=nfs,ro hacker:/usr
Each line consists of 3 space delimited fields. The first field is the "key" which will be the name of the subdirectory (under /misc) to which the device will be mounted. This directory must NOT exist. It will not be visible when I use the command ls , but I can "cd" to it and my device will then mount. Don't ask me why it is so, and how to use this automount in GUI. I don't know. The hacker stuff in my auto.misc is the cdrom and floppy from another computer in my home network.
I automount to the directory /misc (not /mnt) so that I can also mount filesystems manually, without using automount, to the directory /mnt.

4.2.9 How do I get my parallel-port (external) Zip drive recognized?

RedHat 6.0 and 6.1  The zipdrive (zip100 drive) installation did not work during my upgrade to RedHat 6.0 (the installation program said that it couldn't find the zipdrive). So, after the installation was completed, I issued the following commands to insert the modules for parallel port zip drive into the kernel (as root):
/sbin/insmod parport
/sbin/insmod ppa
To have these two lines executed automatically after each bootup, I added them at the end of the file /etc/rc.d/rc.local (this file is something like autoexec.bat on DOS).
If this still does not work for you, you may also want to edit the file /etc/conf.modules.  Mine contains such a line:
alias parport_lowlevel parport_pc
and there is no line mentioning the "ppa" module.
For the newer Zip250 drive, I have the following two lines executed from my /etc/rc.d/rc.local file:
/sbin/insmod parport
/sbin/insmod imm

4.2.10  Can I set 32-bit hard drive I/O?

Newer Linux distributions (e.g., Mandrake 7.0) can automatically turn on the hard drive optimization: 32 bit input/outup (I/O) and direct memory access (DMA). Here is how to turn on the hard drive optimization manually. (Based on http://hardwarezone.community.com.sg/main.htm by Edward Choh.)

This procedure worked fine for me, yet be warned that it can possibly harm the content of your harddrive, so do not do it if you are a real PC newbie, don't feel geeky today, or have a weak heart--I can't guarantee it will work for you.

The turning on of the 32-bit I/O and DMA has to be done by root, and I did it in a single-user mode (to minimize the damage to the file system if something went wrong and I had to reboot). I definitely would not do it on a system currently running many programs or X-windows, and would have a current backup of any precious data.
To boot your computer in a single-user mode, I type this at the lilo prompt (during bootup):
linux single
Say, I would like enable the 32-bit I/O on my first IDE harddrive, which is "hda". First, I time the harddrive current performance, and note the score:
hdparm -t /dev/hda
Now, I display my current I/O and DMA settings:
hdparm -c /dev/hda
[my system showed 0, meaning that the 32-bit I/O is turned off and the default 16-bit access is used]
hdparm -d /dev/hda
[my system showed 0 again, meaning that the harddrive DMA access is turned off].
Now, I turn on the 32 bit IO and DMA:
hdparm -c 1 /dev/hda
hdparm -d 1 /dev/hda
Now, I can time the performance of the harddrive again to compare the score with the original one:
hdparm -t /dev/hda
If everything worked ok, and the performance has improved, I can "commit" the new settings, so they can survive a soft reset:
hdparm -k 1 /dev/hda
To have the new settings in effect every time you reboot the machine, you may add a line at the end of the file /etc/rc.d/rc.local (this file is something like AUTOEXEC.BAT in DOS):
hdparm -c 1 -d 1 -k 1 /dev/hda
If something did not work as expected, or the performance did not really improve, I can reboot at any time and the old settings will be in effect as long as I did not perform the last operation.
I performed this tune-up on 4 hard drives on my home network. It was a success on 3 newer hardrives: the performance improved by 30-300% and at least one computer "feels" faster than before. One harddrive (which is always flaky) hanged the computer hard during the performance test and I had to reset the machine (no damage done).

4.2.11  I reached the limit on the number of opened files (error message)

You can increase the limit via the /proc file system. This file system is entirely virtual--it is just a "window" to see or set some parts of the Linux kernel.   To read the maximum number of simultanously opened files on my system,  I use the following command:

cat /proc/sys/fs/file-max

On my system (Mandrake 7.2), the limit is 8192. To increase it, I use (as root):

echo 16000  > /proc/sys/fs/file-max

You may also want to increase the limit on a related kernel variable:

echo 30000 > /proc/sys/fs/inode-max

To make the changes permanent, add the above lines at the end of your startup script /etc/rc.d/rc.local

To learn more about the /proc Linux kernel interface, the meaning of the variables it contains, and their recommended values, you may wish to read (if you installed the Linux kernel source codes, which is a great resource even for a newbie):

less /usr/src/linux/Documentation/proc.txt

or (on RedHat 8.0)

man proc

4.2.12. I attached a new hard drive. What do I do to start using it?

0. Plan the layout of the filesystem with the new drive
1. Partition the new hard drive
2. Format the new partitions
3. Test the new space
4. Copy data from old to new partition (optional)
5. Edit /etc/fstab
6. Reboot
7. Remove old data (optional)

Here is a  longer version for my recipe.

0. Plan the new  filesystem. Where would you like to use the new space? Do

to print a summary of free/used space on each of the existing mounted partitions. Do

on selected directories to find their size.

For example, I would consider using new hard drive space in one of the following mount points:

Here is why.

/usr/local is suposed to survive any upgrade of Linux. It is nice to have it on a separate partition because I can even reformat other partitions without affecting my local contents stored in /usr/local. I surely want it of the type "ext2" or perhaps "reiserfs".

/home contains user data. Surely, it is the data that deserves the most care. It is obviously supposed to survive any upgrade of Linux. Wow, obviously I want it on a separate partition. The type is normally "ext2" or "raiserfs".

/usr/local/mp3s is a non-standard Linux directory. I may keep my MP3 (music) files there. Those tend to be large.

/usr/local/dos_data. Another non-standard directory. If I dual boot, I would consider making an extra partion of the type "DOS FAT32" or similar so as to share files between MS Windows and Linux transparently (both ways). I would configure all the Windows-based programs to use this "drive" as the 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 partion on re-install.

1. 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 ext2 ("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.

2. 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

3. 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.

4. 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

5. 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

6. 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.

7.  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).

4.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. 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 using fdisk (partition type 82, "Linux swap").
- Format the partition checking for bad blocks, for example:
mkswap -c /dev/hda4
You have to substitute /dev/hda4 with your partition name. Since I did not specify the partition size, it will be automatically detected.
- Enable the swap, for example:
swapon /dev/hda4
To have the swap enabled automatically at bootup,  you have to include the appropriate entry into the file /etc/fstab, for example:
/dev/hda4 swap swap defaults 0 0
If you ever need to disable the swap, you can do it with (as root):
swapoff /dev/hda4 Swap files

Swapping to files is usually slower than swapping to a raw partition, so this is not the recommended permanent swapping technique.  Creating a swap file, however, can be a quick fix if you temporarily need more swap space. You can have up to 8 swap files, each with size of up to 16 MB. Here are the steps for making a swap file:
- Create a file with the size of your swap file:
dd if=/dev/zero of=/swapfile bs=1024 count=8192
This physically creates the swap file /swapfile, the block size is 1024 bytes, the file contains 8192 blocks, the total size is about 8 MB. [The dd command copies files. In the example above, the input file (if) was /dev/zero, the output file (of) was /swapfile . You cannot use the cp (copy) command for creating a swap file because the swap file must be physically continuous on the hard drive.]
- Set up the file with the command:
mkswap /swapfile 8192
- Force writing the buffer cache to disk by issuing the command:
- Enable the swap with the command:
swapon /swapfile
When you are done using the swap file, you can turn it off and remove:
swapoff /swapfile
rm /swapfile
You may also want to see the nice info written by Linus Torvalds himself:
man mkswap

Go to Part: 4.3 - Working with X-windows