I'm aware of tmpfs
and what I really need is a disk partition resides on RAM where I could format it with BTRFS.
How can I create a raw device on RAM and format it with any regular filesystem?
Or is only chance creating a raw file on tmpfs
, formatting it with a filesystem and mounting through a loop device (source).
mkdir /ramdisks
mount -t tmpfs tmpfs /ramdisks
dd if=/dev/zero of=/ramdisks/disk0 bs=1M count=100
losetup /dev/loop0 /ramdisks/disk0
mke2fs /dev/loop0
...
losetup -d /dev/loop0
rm /ramdisks/disk0
Use Case
I'm using BTRFS for a number of reasons. My current attempt is to use Overlayfs as rootfs (just like Slax does with Aufs) and I want the underlying directory structure be BTRFS.
Slax uses the following trick: While the system is booting,
- instead of actual
switch_root
operation that the normal installations usually do, Slax creates a transient folder and - mounts it as
tmpfs
(puts it on the RAM), switch_root
to it as if it were the actual filesystem.- Then it does some Kung-Fu: Mounts its "modules" (the squashfs files) to somewhere (say
/modules
) - Mounts all folders under
/modules/
to/union
along with a writablechanges
folder pivot_root
to the/union
folder.
What I want is mimicking that, which doesn't require what I asked so far, except: I want to place the changes
folder on the RAM with the support of BTRFS goods:
- Support snapshotting,
- Support
btrfs send | btrfs receive
- Possibly BTRFS RAID-1
/dev/ramX
-type interface is still around; you may want to try instructions found here and then create a file system there, as mentioned here. – AdminBee Feb 17 '20 at 09:15