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.

2
  • Linux "ramfs" and "tmpfs" aren't ramdisk-based, and not even blockdev-based (they're backed by page cache and dynamically sized). Are you using ramfs or ramdisk? Feb 18, 2019 at 7:45
  • @grawity I'm using a ramdisk. Sorry for the confusion.
    – TdBm
    Feb 18, 2019 at 7:48

1 Answer 1

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.

1
  • Thanks @grawity, I'll try it out. One of the reasons I had this doubt, was that I was getting a couple of errors with just the boot parameter. Maybe I didn't allocate enough memory.
    – TdBm
    Feb 18, 2019 at 9:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .