[Sussex] thanks and questions

Steve Dobson steve.dobson at krasnegar.demon.co.uk
Sat Apr 26 01:10:00 UTC 2003


John

On Fri, Apr 25, 2003 at 11:49:18PM +0100, john davis wrote:
> On Friday 25 Apr 2003 1:32 pm, Geoff Teale wrote:
> > Steve wrote:
> > ------------
> >
> > > The best solution is to check /etc/fstab and look for the line:
> > > /dev/hda3   none  swap
> > >
> > > At least I think that that is the line - check the man page for
> > > fstab to be sure - it's bound to have an example.
> >
> > AFAIK that should work fine..
> 
> So, as my /etc/fstab seems to look like this:-
> 
> /dev/hda2 / ext2 defaults 1 1
> none /dev/pts devpts mode=0620 0 0
> none /mnt/cdrom supermount 
> dev=/dev/hdb,fs=auto,ro,--,iocharset=iso8859-15,codepage=850,umask=0 0 0
> none /mnt/cdrom2 supermount 
> dev=/dev/scd0,fs=auto,ro,--,iocharset=iso8859-15,codepage=850,umask=0 0 0
> none /mnt/floppy supermount 
> dev=/dev/fd0,fs=auto,--,iocharset=iso8859-15,sync,codepage=850,umask=0 0 0
> /dev/hda1 /mnt/nt ntfs iocharset=iso8859-15,ro,umask=0 0 0
> none /proc proc defaults 0 0
> 
> I must presume that I have no swap?

No that doesn't mean that.  It means that any swap partition will not be
automaticlly "mounted" at boot.  But it does look like you've only got
one file system partition.

To see if you have swap you need to look at your disk partitions.  As I've
now meet you and you claim to be a newby I'll take you through this slowly.

First login as root (I normally just open up a shell window on my X
desktop and type "su -" and enter the root password.  If your system is
configured right the prompt will end in a "#".

Next do a "mount" command.  This will list your mounted file systems
(partitions) and tell you what the device names for the disk(s) are.  On
my lap to I see the following:
  # mount
  /dev/hda1 on / type ext3 (rw,errors=remount-ro)
  proc on /proc type proc (rw)
  /dev/hda5 on /usr type ext3 (rw)
  /dev/hda6 on /var type ext3 (rw)
  /dev/hda7 on /home type ext3 (rw)
  /dev/hda8 on /usr/src type ext3 (rw)
  /proc/bus/usb on /proc/bus/usb type usbdevfs (rw)

Ignore the lines with proc in them - they not disk devices and beyond the
scope of this e-mail.

I'll assume that you're using IDE disks (let me know if you aren't).
The device names are as follows:
  /dev/hda  Master disk on IDE1
  /dev/hdb  Slave disk on IDE1
  /dev/hdc  Master disk on IDE2
  /dev/hdd  Slave disk on IDE2
The different partitions on the disk have a number - I'll assume that you 
know what a partition is as it is common to disks on Windows as well as
Linux.  If you have more than one disk you might see something like this
from the mount command (my server at home):
  # mount
  /dev/hda1 on / type ext2 (rw,errors=remount-ro)
  proc on /proc type proc (rw)
  /dev/hdc3 on /mirror type ext2 (rw)
  /dev/hda6 on /home type ext2 (rw)
  /dev/hdc1 on /var type ext2 (rw)
  /dev/hda5 on /usr type ext2 (rw)
  /dev/hdc4 on /usr/local type ext2 (rw)

So my laptop has one disk (hda) with five partitions (1, 5, 6, 7, and 8).
My server has two disk (hda & hdc) also with five partitions but this time
spread over the two disks.

But mount only lists the mounted file-systems.  The swap partitions are not
reported - for this we need to use fdisk (if you don't have fdisk try cfdisk
it gives the same information but in a different way - fdisk is easier for 
showing the output in this email).

Before you run "fdisk" be warned - you can change the partition layout and
therefore loose all the data on your disk so for doG's sake [1] don't commit
any modifications. If you type the following you'll see a list of the
partitions on a disk (I'll assume that only have the one IDE disk):
   # fdisk /dev/hda   <- Run the command
   p                  <- Print the partition table
   q                  <- Quit fdisk
And you should see something like this (my laptop disk):
  Disk /dev/hda: 30.0 GB, 30005821440 bytes
  16 heads, 63 sectors/track, 58140 cylinders
  Units = cylinders of 1008 * 512 = 516096 bytes

        Device Boot    Start       End    Blocks   Id  System
     /dev/hda1   *         1      1984    999904+  83  Linux
     /dev/hda2          1985      2976    499968   82  Linux swap
     /dev/hda3          2977     58140  27802656    5  Extended
     /dev/hda5          2977     14881   6000088+  83  Linux
     /dev/hda6         14882     22818   4000216+  83  Linux
     /dev/hda7         22819     42659   9999832+  83  Linux
     /dev/hda8         42660     58140   7802392+  83  Linux

Note that you can now see two partitions not given my "mount": hda3
the extended partition where hd5, 6, 7 & 8 live and hda2 the swap 
partition.  If your system is dual boot then there maybe a partition
that listed for windows too.

If you can see a partition that is formatted as a Linux swap then this
is the device that needs to be configured in the "/etc/fstab" file to
be automaticlly enabled at boot.  If you don't see one then there are
a number of options:

  1). Live without swap - given the 750MB of memory your system has 
      this is a possiblity as long as you aren't running any big 
      applications or lots of little ones.

  2). Re-configure an existing partition as swap (or split up a partition
      in to two making on of the partitions swap).  I need to know more
      about you're system before giving advice here so if this looks
      like a way forward please reply with the output of "fdisk" and 
      also the "df -k" command - from those I'll be able to advise.

  3). Re-install (take backups first if you can [2]) configuing in swap.
      From looking at your fstab output above I would tend to do this.
      But that's me - I don't beleive that you should just have the one
      big supper partition in which everything lives, but others on this
      list do.  There are advantages and disadvantages to both.

  4). Use a swap file (rather than a swap partition) slower - but it
      works.  Let me know if you want to try this.

  5). Buy a second disk and congiure some of that for swap.
      You'll need to partition the disk and there are some good HOWTOs
      on doing that.  If you are adding a second hard disk it is best
      to put in on the different IDE bus.  That way the system can use
      both disks at the same time.

Assuming that you've found yourself a partition that you want for swap
then there are two things to do.

A). If it isn't configured as a "Linux swap" it needs to be.  "fdisk"
    is the program for this:
       # fdisk /dev/hda  <- To run the fdisk command
       t                 <- To change the type of one of the partitions
       p                 <- Print the current partition config
       2                 <- Or whichever partion number it is
       82                <- The id of Linux swap (L lists the complete set)
       p                 <- Print the new partition config
			    (if it doesn't look as you expected press
			     'Q' NOW!!!!!!!)
       w                 <- Write the partition table back to disk
       q                 <- quit fdisk

Then add the following line to "/etc/fstab" (again following my laptop's
configuration where /dev/hda2 is swap - the number should be the one
for you swap partition):
  /dev/hda2 none swap sw 0 0
And re-boot to make sure that it mounts on boot.  Once the machine is 
back up there are two ways to check:

  1): "dmesg | grep swap" which should show you something like this:
       # dmesg | grep swap
       Starting kswapd
       Adding Swap: 499960k swap-space (priority -1)

  2): "# swapon -s" which will report on all the swap spaces:

Have fun and let me know how you got on

Steve

[1]
I'm a dyslexic agnostic.




More information about the Sussex mailing list