You can use
dmsetup to set a
linear device made of a
/dev/ramX plus your
For instance, from the command prompt type:
dmsetup create mydev << EOF
> 0 65536 linear /dev/ram0 0
> 65536 262144 linear /dev/sdb 0
The above creates a logical device named
mydev made of a 32MB (65536 sectors) ramdisk plus the first 128MB (262144 sectors) of /dev/sdb. Of course replace
/dev/sdb with the actual device file for your disk.
You may also want to use the exact size (or a bit less) of your disk or partition, and for that you need to know that size expressed in 512-bytes sectors. In order to know that for e.g. the
/dev/sdb1 device you may do:
grep sdb1 /proc/partitions
and then use the big number that appears on the left of the device name, multiplied by 2. (because that big number is expressed in 1024-bytes blocks).
Then you have to format
mydev with your file-system type of choice. For instance:
Finally mount it with:
mount /dev/mapper/mydev /mnt
/mnt with the actual directory you want to use as mount point, and enjoy.
To remove everything, do:
dmsetup remove mydev
However it’s worth saying that this setup is less efficient than direct tmpfs filesystems, because tmpfs is already a (virtual) file-system on top of Linux's virtual memory manager, whereas ramdisks need an additional operation of memory-pages copying, plus they still require a regular file-system with its overhead on top of them.