LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to reserve fixed amount of memory for ramdisk? (https://www.linuxquestions.org/questions/linux-general-1/how-to-reserve-fixed-amount-of-memory-for-ramdisk-287130/)

ihristov 02-06-2005 11:34 PM

How to reserve fixed amount of memory for ramdisk?
 
How do I reserve a fixed amount of memory (16 MB) for RAM disk and do not allow the kernel to use it for other stuff?

Any pointers are appreciated. Everything that I find says "the RAM disk
dynamically grows as data is being written into it"

Details:
-----------

I recently installed IPCop on a flash card. I used the LinITX image
<http://linitx.com/support/download.php>

All works well, except after having run for a while I can no longer write
to the ram disk, even though it is not full. This creates all sort of
problems.


> root@ipcop:/var/log # mkdir test
> mkdir: cannot create directory `test': No space left on device

> root@ipcop:/var/log # df -h /ram
> Filesystem Size Used Avail Use% Mounted on
> /dev/ramdisk 16M 5.2M 11M 34% /ram


I can see there is 25M available memory, but it does not want to use it.

> root@ipcop:/var/log # free -k
> total used free shared buffers cached
> Mem: 94872 69216 25656 0 4192 46584
> -/+ buffers/cache: 18440 76432
> Swap:
> 0 0 0

BTW: I have 96 MB or RAM, but can't install more, because it is an old
Pentium 133 motherboard with the old 72 pin SIMM memory.

---
Iassen Hristov

P.S. If this matters the kernel is stock 2.4.27

Oliv' 02-07-2005 07:50 AM

Hello,

the amount of reserved RAMDISK is defined during kernel selection option stage. I mean when you hit "enable RAMDISK" box there's a box below which appears and ask you the amount you want to reserve (by default 4Mo)

Oliv'

ihristov 02-07-2005 10:49 AM

Quote:

Originally posted by Oliv'
the amount of reserved RAMDISK is defined during kernel selection option stage
Oliv' [/B]
That's what I already do.
IPCop is using grub. Here is the /boot/grub/grub.conf

Code:


timeout 5
default saved
foreground = 16064e
background = ffffff
splashimage (hd0,0)/grub/ipcop.xpm.gz
title IPCop
  root (hd0,0)
  kernel /vmlinuz root=/dev/hdc4 panic=10 acpi=off ro idebus=33 ide=nodma ramdisk_size=16384
  savedefault

However this just makes a 16 MB RAM disk, but does not "reserve" it explicitly for the RAM disk. Aparently the kernel uses the memory for cache and other stuff and at some point I can't write to the RAM disk, even though df says there are still 11 MB free. This is my problem.

Oliv' 02-07-2005 12:19 PM

Quote:

at some point I can't write to the RAM disk, even though df says there are still 11 MB free

And you'll never be able to do so... 'cause it's RAMDISK so its filesystem is cramfs and that's a read only filesystem :(
So you must configure it properly, then generate it and you can't modify it anymore when it's in RAM

ihristov 02-07-2005 04:52 PM

We are clearly not understanding each other. This disk is not cramfs, it is ext2. This is a ram disk that IS writeable after I boot. All the log files are written to it. Then after the system has ran for a while I can no longer write to it with a message "No space left on device".

I don't know if the RAM disk specified in the grub config is the same as this one.

I think this RAM disk is created at boot time as part of the init process from the file /etc/rc.d/rc.flash.up

Code:

umount -n /dev/ramdisk
mke2fs -b 1024 -m 0 /dev/ramdisk

mount -n /dev/ramdisk /ram/
mkdir -p /ram/{log,tmp}

ln -s /ram/var/log /var/log
ln -s /ram/tmp /tmp

...
create other folders and set permissions on them
....

So the question is: Is there a way to somehow reserve the memory for the ram disk ONLY?

Actually this got me thinking and it appears I am running out of inodes.

Code:

root@ipcop:/ram # tune2fs -l /dev/ramdisk
...
Inode count:              4096
Block count:              16384
Reserved block count:    0
Free blocks:              10525
Free inodes:              0
...



All times are GMT -5. The time now is 08:23 AM.