Increase Free Memory and no more reboots due to too long syslog file (Need USB disk)
Ok,
This is working for me, and may be also working for you.
The idea is to disable the ramdisk where the syslog is stored. While disabling gives you some more memory, the biggest advantage (to me) is that the syslog can grow, grow grow without the device runs out of memory.
Now, I would not reccommend this for a flashdrive, as I think a flash can only be written a few thousand times. Well, actually I don't know. At your own risk!
Step 1.
Make sure you have OLEG's firmware running, and you are booting from harddisk.
You can check it by loggin on, and type mount
If you don't see an "cramfs" entry you are running smooth from disk :cool:
Step 2 Make your drive writable after the booting.
For this step you need vi editor. In the latest version of the firmware this is build in, for older versions you need to use the 'full version' which can be found here http://files.wl500g.info/asus/wl500g...pp/busybox.zip
This version might anyway be handy to have somewhere on your disk, just in case you need the extra features.
Make your drive writable after the booting.
Add a line to the "/init/boot" file (maybe make a backup of the boot file cp boot boot.org)
mount -o remount,rw,noatime "$boot_dev" /
after the two mount commands. This brings your disk in read-write mode just after booting.
Step 3 Create empty tmp dir
The original firmware always starts with empty tmp. I'm not sure if it is really needed. Anyway, it nicely cleans up any mess left behind
add the rm line just before the "mkdir /mnt/ramfs/tmp" line
rm -rf /mnt/ramfs/tmp
mkdir /mnt/ramfs/tmp
Step 4 Remove RAM disk
Continue editing the boot file, add the # in front of the mount command of the ramdisk
#mount -t ramfs ramfs /mnt/ramfs
reboot your router, and check with mount command.
you should see something like:
/dev/scsi/host0/bus0/target0/lun0/part1 on / type ext2 (rw,noatime)
none on /dev type devfs (rw)
none on /proc type proc (rw)
Ok, way to go, you have it.
You can see the available mem by typing:
~ # cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 14794752 12906496 1888256 0 425984 6336512
Swap: 0 0 0
MemTotal: 14448 kB
MemFree: 1844 kB
MemShared: 0 kB
Buffers: 416 kB
Cached: 6188 kB
SwapCached: 0 kB
Active: 3760 kB
Inactive: 4316 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 14448 kB
LowFree: 1844 kB
SwapTotal: 0 kB
SwapFree: 0 kB
If you still don't think you have enough memory you might wanna add some swap memory
do it as following:
Create an empty file (the number behind the count is the number of MB you wanna have as swap)
~ # dd if=/dev/zero of=/swp bs=1M count=32
32+0 records in
32+0 records out
(you need again the full version of the busybox)
~ # /path to your busybox/busybox mkswap /swp
Setting up swapspace version 1, size = 33550336 bytes
~ # /busybox swapon /swp
again, you can check if it is working by typing:
~ # cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 14794752 13496320 1298432 0 663552 6955008
Swap: 33546240 131072 33415168
MemTotal: 14448 kB
MemFree: 1268 kB
MemShared: 0 kB
Buffers: 648 kB
Cached: 6664 kB
SwapCached: 128 kB
Active: 2420 kB
Inactive: 6364 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 14448 kB
LowFree: 1268 kB
SwapTotal: 32760 kB
SwapFree: 32632 kB
Note: Mini "vi" editor manual.
Maybe you are struggeling with vi just as I most of the time do.
The way to edit this boot file:
/path to your full busybox/busybox vi /init/boot
scroll to the place where you want to edit, click the "insert" key. You see in the bottom left part of the screen "-- Insert --" (click once more to replace)
No modify/add the text you want to edit, after the edit is done click the "Esc" key. to delete a line type ":d"
Now write the file with the ":w" command
Close vi with the ":q" command
BTW. While experimenting to get this done, I several times booted the device without having a working tmp dir. The interesting behaviour is that some of the services did not start, or did not work. I could not log on to the box anymore with SSH, however the telnetd was each time running and accepting connections. This allowed me to fix the thing and continue.
Problems after moving root fs to usb disk
Hi Erik,
I have read your posting with losts of interest and tried to work it out myself . So, loading the root file system and changing the /init/boot file as describe. It all seems to work fine for a small amount of time, but after 1 or 2 restarts of the router (including detaching/attaching the usb drive) something seems to change in the filesystem that causes the router to end up in some sort of boot loop.
That is: after booting up is finished, my network adapter does get an IP address and I am able to open a telnet session to the router but in seconds that connection is dropped and the router starts booting again. This keeps going on and on.
Solved it a couple of times by reinstalling the root file system from scratch, but it keeps failing every time after 1 or 2 reboots.
Could not find any clear keys in the system log about something failing just before the reboot occurs.
Do you have any idea what can be the problem? And do you have any suggestions to solve it?
TIA,
Mark
Adding swap memory to normal custom firmwares
Hey, this is great. I was just working on the same procedure. Now I don't need to anymore :D
Thanks!
One comment: Migrating from flashboot to USB boot will make the process of upgrading/changing firmware more difficult. So be prepared to go in-dept with this.
Oh, and if someone only wants the additional swap memory but does not want to boot from USB then just copy the full version of busybox to the USB disk and carry on with the described mount commands in Erik' post (Below is the description on howto do this).
Adding Swap memory to a custom firmware without using the rootfs option (tested it on 1.7.5.9-CR5):
- Create a swap partition using Partition Magic (or similar program) or with the 'busybox mkswap' command.
- Add the following command to the post-boot script:
Code:
/mnt/usbfs/busybox swapon /dev/discs/disc0/part6
My partition table:
Code:
/dev/discs/disc0/part1 - 159 GB FAT32
/dev/discs/disc0/part2 - 64 Mb Extended
/dev/discs/disc0/part5 - 32 Mb Ext2
/dev/discs/disc0/part6 - 32 Mb Linux Swap
- Save the changes with:
Code:
flashfs save
flashfs commit
- Reboot and check the swap space with: A note though: Swap memory will have to travel over USB1.1 (11Mb/s) so it will probably be slow...