From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
Newsgroups: comp.os.linux
Subject: Re: .97 kernel and root disk/probs with swapping
Date: 31 Aug 92 19:47:16 GMT
Organization: University of Helsinki

In article <1992Aug31.024052.12351@cc.umontreal.ca> duperval@ERE.UMontreal.CA (Duperval Laurent) writes:
>In article <6026@pdxgate.UUCP> moyerg@rigel.cs.pdx.edu (gary a moyer) writes:
>>I am now in the process of getting the kernel to compile however I am getting
>>some strange results.  I am using a 2M swap file (NOT partition).  I get
>>some errors during swaps like:
>>rw_swap: bad swapfile
>>
>>This occurs during compilation using gcc 2.2.2d with 4M RAM and 2M swap.
>>Any ideas?  Thanks.
>
>I have similar problems with kernel compilation.  I have 4M of memory and 8M
>swap space.  When compiling I get an out of memory, out of swap space error.
>I'm running all the stuff that was on mcc-interim 0.96c (gcc 2.2.2, kernel
>0.96c).

The "bad swapfile" problem is most usually due to (wait for it) a bad
swapfile.  Hmm.  Maybe I should use cryptic numbers and give something
like "ERR192SWP" instead - but that would also mean I'd have to write
some documentation on the thing.  Not good. 

Anyway, to make a swapfile, it's not enough to just run "mkswap" -
mkswap just writes the swap signature and some bad-page info. You
actually have to create the swapfile with the correct size and without
holes first. How you create the swapfile is totally up to you, but the
normal thing to do is:

	# dd if=/dev/zero of=swapfile bs=1024 count=XXXX

where XXXX is the size of the file in kilobytes. You now have an empty
file which is exactly XXXX blocks long. To mark it swappable, you then
run mkswap on it and sync:

	# mkswap swapfile XXXX
	# sync

You now have a swapfile that is ready to be used: swapping is then
enabled with

	# swapon swapfile

It's normal to put the 'swapon' command in your /etc/rc.local or
whatever - but you can do it by hand at each reboot if you want to.

Note that if you use a swap-paritition, you obviosuly don't have to
create it first with "dd" or whetever: just make sure you have a good
partition free, and run "mkswap" on it.  With swap partitions, it's
generally a good idea to map out bad spots (or you'll get all sorts of
nasty errors), so use the "-c" switch for this: 

	# mkswap -c /dev/hdXX XXXX
	# sync

and

	# swapon /dev/hdXX

Swapping from a partition is a lot faster than swapping from a file, but
creating a file is easier, and it's easier to remove or resize.

>I never encountered this prblem before and I thought I had plenty of room.
>BTW, if anyone is interested, my make fails on chr_drv/tty_io.c when I have 
>one console open and on chr_drv/console.c when two consoles are open.
>
>Also, what are these 'put_tty_queue' declarations disagree about 'inline'
>errors I get.  What do they mean and could they be a hint as to what is going
>wrong?

the "disagree about inline" message is arguably a gcc bug: it's an
uncommonly stupid warning, and I don't know why gcc prints it.  It's
probably easy to get rid of by just putting a "inline" before the
prototype in include/linux/tty.h, but I'm too lazy to even test it out. 
The way gcc inline (nonstatic, nonexternal) functions work, it's totally
illogical to ask it to be prototyped that way.  I don't mind too much:
as long as my only gripes with gcc are of this type, I'm happy. 

		Linus