(I'm adding back the list)
On Tue, Feb 02, 2021 at 02:38:41PM -0500, przemek klosowski wrote:
On 2/1/21 3:34 PM, Richard W.M. Jones wrote
>RAM disks!
>
> # nbdkit memory 10G
> # nbd-client -b 512 localhost /dev/nbd0
>
Cool! I didn't know about this... the standard way I knew was via tmpfs
mount -t tmpfs -o size=10g myrd /tmp/ramdisk
How does it compare to nbd?
tmpfs doesn't make a RAM disk block device, instead each file is
stored in memory as required. Linux has an actual RAM disk block
device, but that's also different from nbdkit-memory-plugin.
nbdkit-memory-plugin runs in userspace and implements a sparsely
allocated RAM disk. So you can do this on a laptop from 2021 (not
2121 or whenever it will be that we have laptops with 8 exabytes of
RAM):
# nbdkit memory $(( 2**63 - 1 ))
# nbd-client -b 512 localhost /dev/nbd0
# mkfs.btrfs -K /dev/nbd0
The longer answer to this is my talk at FOSDEM:
https://archive.fosdem.org/2019/schedule/event/nbdkit/
"Better loop mounts with NBD: Take your loop mounts to the next level
with nbdkit".
BTW, I kind-of like using loop devices, because they are persistent
dd if=/dev/zero of=/tmp/disk bs=1G count=10; mount -o loop
/tmp/disk /mnt/disk1
Are you preferring ramdisks because of speed, or is there something else?
RAM disks are temporary by their nature. I was suggesting this only
as a way to test the hash algos in btrfs.
nbdkit has many other plugins customized to different use cases,
including many with persistent backing; or you can write your own.
https://libguestfs.org/nbdkit.1.html
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html