3

I compile the ramdisk as a module in the kernel.Then I want use the cmd :insmod brd rd_size = 10000 to set the capacity of the ramdisk.But it says I give the wrong parameters. Then I go to see the source code of this module. static int __init brd_init(void).There is no parameters list. If I want to set the capacity of the ramdisk,What can I do?

qyanqing
  • 313
  • 2
  • 5
  • 10

1 Answers1

6

Try modprobe brd rd_nr=1 rd_size=1048576 max_part=0

That should give you one 1G partition at /dev/ram0.

Solution referenced from here with a code reference here

Tyler Jandreau
  • 4,245
  • 1
  • 22
  • 47
Justin B.
  • 61
  • 1
  • 2
  • 1
    More info: `rd_nr` is the number of RAM disks it creates; by default, it creates ram0 through ram15, but specifying 1 just creates ram0. `rd_size` is the size of the disk in **kilobytes** (1024 bytes per kilobyte). Parameter documentation can be found in the source code: https://github.com/torvalds/linux/blob/master/drivers/block/brd.c#L330 – Joey Adams Jan 01 '19 at 15:23