3

I need to use a ramdisk to mount a filesystem as a ramfs on an embedded device. However, this requires me to increase the size of the ramdisk - currently as per the kernel config, maximum size is 35MB. I can modify boot parameters, but recompiling the kernel may not be possible.

I found this question that addressed ramdisk creation. However, I am unsure as to whether both CONFIG_BLK_DEV_RAM_SIZE and the boot parameter ramdisk= ramdisk_size= need to be changed. Would I be able to create a ramdisk of size, say 40MB by just changing the ramdisk= ramdisk_size= boot parameter?

EDIT : If it helps, this describes the ramdisk I'm trying to get up and running.

TdBm
  • 133

1 Answers1

2

Either Kconfig or a boot-time option works. However, the option name is not ramdisk= anymore. According to Documentation/blockdev/ramdisk.txt, you can change the size using either:

  • the ramdisk_size= option, or
  • the brd.rd_size= option.

In drivers/block/brd.c:

unsigned long rd_size = CONFIG_BLK_DEV_RAM_SIZE;
module_param(rd_size, ulong, 0444);
MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");

[...]

/* Legacy boot options - nonmodular */
static int __init ramdisk_size(char *str)
{
    rd_size = simple_strtol(str, NULL, 0);
    return 1;
}
__setup("ramdisk_size=", ramdisk_size);

You can see that the Kconfig value is merely used to initialize the rd_size variable, and either brd.rd_size=40960 or ramdisk_size=40960 would completely override it and set the size to 40 MB.

grawity
  • 501,077