1

I'm creating ram block devices on a linux machine for a project we're working on. I don't want to use tmpfs.

When I use module brd to create a ramdisk I run the command

modprobe brd rd_size=1048576

This creates 16 devices -> /dev/ram[0-15] (all of size 1 GB)

But now I want to create two ramdisks of different sizes, say 1Gb and 2Gb.

I also understand I might be able to use lvm to "merge" two devices together and create a new 2GB device from two 1GB devices.

But I want the module to create ramdisks of different sizes without having to do the merging.

I've looked around for a method to do this, but it just seems that there is no way.

Does anyone know if there is a way to do this?

loosebazooka
  • 131
  • 1
  • 4

2 Answers2

1

I'd been looking for similar information on RAM disks (in my case, planned RAM disk as part of RAID 1 array). For a partial answer, as I'm not sure how to create RAM disks of differing sizes:

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

Which should create one, 1GB RAM disk. Perhaps tailor rd_nr=1 to rd_nr=3? That should give three 1G RAM disks, leaving assembling them to 2GB perhaps to LVM?

Referenced solution, and pardon the necro-post answer (there remains very lacking documentation on this subject): http://forums.debian.net/viewtopic.php?f=5&t=114458

Justin B.
  • 11
  • 1
0

Option 1

Create a 4GB ram disk. Then create two partitions on it. The first partition would be 1GB, the second partition would be 2GB. Use the partitons.

Here is the modprobe command:

modprobe  brd  rd_nr=1  rd_size=4194304  max_part=2

I assume you already know (or can easily learn) how to partition a device, for example with gdisk. We need a device that is larger than 3GB because the MBR or GPT header will use a small amount of space on the device.

Option 2

Create two 2GB ram disks. Then create a 1GB partition on one of them. Use the 2GB ram disk and the 1GB ram partition.

modprobe  brd  rd_nr=2  rd_size=2097152  max_part=1

Note: I believe memory on brd devices is only allocated when written to. So the neither of the above options wastes memory.

mpb
  • 243
  • 2
  • 8