[Bootcd-user] A Different RAM Disk Approach / RAMTYPE

Mark Clarkson markjclarkson@hotmail.com
Mon, 7 Jun 2004 02:23:32 +0100


> >  The only thing gained by using tmpfs is limit checking since
> > we have no swap. (sounds useful to me)
> 
> What do you mean? By using tmpfs instead of ramfs?

Yes, by using tmpfs instead of ramfs.
ramfs was written first as a proof of concept, then tmpfs was written
based on ramfs. See Documentation/filesystems/tmpfs.txt in the kernel
sources. ramfs has no limit checking so can conceivably use all the
available ram, but tmpfs can be limited so we can stop, say, a big
log file killing processes.

You said earlier that ramfs did work but tmpfs did not so we could
deduce that they are different beasts from that. Also different code
is used for each - tmpfs is in mm/shmem.c, and ramfs is in
fs/ramfs/inode.c, both make interesting reading, and both have their
own CONFIG_ definitions.
 
> Maybe I just switched something off in 
> my kernel configuration, or there is a problem with ramfs in PPC...

See if CONFIG_TMPFS is set in the .config, hopefully it is not. This would
be useful to know.

> But we don't need ramfs anyway, because I just checked what Knoppix does 
> and it just uses one instance of tmpfs :
> 
> /ramdisk on /ramdisk type tmpfs

And I think Knoppix also does not get rid of the initial ramdisk (ram0)
set at 100000K, but the kernel will only use what it needs, so there is
already memory wastage due to inodes in ram0. I would like to keep ramfs
as an option as this increases the range of kernel versions bootcd can
run on, which Thomas/Bernd think is an important factor.

>From my limited knowledge Bootcd is a very clean and structured approach
to creating a live boot cd and follows the boot conventions - knoppix is
a very clever hack (meant in a nice way) that breaks many rules, and since
they control the environment they can do this. I don't think it would be
wise to copy what knoppix does just because they do it, however it has
quite a large user base and is therefore probably very well tested.

> In that directory you find 'var' and 'home' subdirectories, in Knoppix. 
> Of course 'etc', 'root' and 'dev' could also reside there, for bootcd.
> 
> The problems I have with the current ramdisk system are:
> 
> a) waste of memory: 12 are being used in my /ram1, but only less than 1
>     MB get used in /ram2. tmpfs is supposed to use only as much ram
>     as the files it contains need - by default the maximum is half of the
>     available ram, which seems reasonable.


I believe the memory usage for your ram2 would actually only be 3mb. As the
kernel doc says:

  "Now the RAM disk dynamically grows as more space is required..."

,so it uses 1mb in files, and 2mb in inodes. To test this dd the rest
of the space on /ram2 then look at 'cached' in the output from free.
Delete it and it's returned.

I personally just want tmpfs so I can use more memory without spreading
accross multiple ram disks - but I want it built in so it can be used
easily, and configured in the same place, bootcdwrite.conf.

> b) it is complicated and initialisation takes longer ("calculating
>     number of inodes needed").

I barely notice the time it takes to calculate the number of inodes
needed but my machines range from 350Mhz to 2.5Ghz. My old 75Mhz pentium
laptop doesn't support bootable cds, and I was unable to get the
boot floppy option to work, but I think I'll try again, and maybe search
out my old scsi quad speed cdrom... Now where's my old TRS-80 gone...

Complicated? I find the whole lot very clever and complex indeed.

> I already mount a tmpfs file system in /tmp (or /ram1/tmp, more 
> precisely) because I put the firefox browser's cache in /tmp and so /tmp 
> might need more space than /ram1 provides (/ram1/etc already uses much).
> 
> So my suggestion is:
> 
> RAMTYPE="<tmpfs|ramdisk|auto>"
> 

So far I'd have to stick with 

  RAMTYPE="<tmpfs|ramfs|ramdisk|auto>"
  TMPFS_SIZE="<size in mb|auto>"

Any comments Bernd/Thomas? Or am I on my own on this one? :-)

Just to recap ------------------------------------------->

So for the RAMTYPE="auto" case:

  If kernel >= 2.4 then
    RAMTYPE=tmpfs if CONFIG_TMPFS found
    RAMTYPE=ramfs if CONFIG_RAMFS found
    otherwise RAMTYPE=ramdisk
  else If kernel >= 2.2
    RAMTYPE=ramfs if CONFIG_RAMFS found
    otherwise RAMTYPE=ramdisk
  else
    RAMTYPE=ramdisk
  endIf

(I believe pre 2.4 kernels could not specify the size of tmpfs.)

I suppose we would also need

   TMPFS_SIZE="<size in mb|auto>"

where auto would be half the memory(?).

To start I would probably keep /ram1 and /ram2 and only symlink
from /ram[1|2] to the tmpfs/ramfs directory. I think this would
'waste' around 4mb in inodes but better than breaking everything.
Hopefully bootcd2disk would not need modifying by doing it this
way.

Also I would only store /tmp, /home, /root and /var on the tmpfs
mount leaving /etc and /dev where they are on /ram1.

Any comments?
Best Regards
Mark.