Monday, April 11, 2011

Ramdisk Greater than 4 MB

14.3.18. Ramdisk Greater than 4 MB Causes Problems

Question:
I built a ramdisk image which is bigger than 4 MB. I run into problems when I try to boot Linux with this image, while other (smaller) ramdisk images work fine.

Answer:
The Linux kernel has a default maximum ramdisk size of 4096 kB. To boot with a bigger ramdisk image, you must raise this value. There are two methods:
  • Dynamical adjustment using boot arguments:
    You can pass a boot argument ramdisk_size= to the Linux kernel to overwrite the configured maximum. Note that this argument needs to be before any root argument. A flexible way to to this is using U-Boot environment variables. For instance, to boot with a ramdisk image of 6 MB (6144 kB), you can define:
=> setenv rd_size 6144 => setenv bootargs ... ramdisk_size=\${rd_size} ... => saveenv        
If you later find out that you need an even bigger ramdisk image, or that a smaller one is sufficient, all that needs changing is the value of the "rd_size" environment variable.
    • Increasing the Linux kernel default value:
      When configuring your Linux kernel, adjust the value of the CONFIG_BLK_DEV_RAM_SIZE parameter so that it contains a number equal or larger than your ramdisk (in kB). (In the 2.4 kernel series, you'll find this setting under the "Block devices" menu choice while, in the 2.6 series, it will be under "Device drivers" -> "Block devices".)

No comments: