开发者

Direct copy Ramdisk image to Ramdisk device

开发者 https://www.devze.com 2023-03-05 08:43 出处:网络
Right, so I\'ve got a Ramdisk image on a mounted device at, say, /mnt/sda1/Ramdisk.img . I want to copy the raw data directly to a ramdisk device at /dev/ram0, in such a way that there will be no need

Right, so I've got a Ramdisk image on a mounted device at, say, /mnt/sda1/Ramdisk.img . I want to copy the raw data directly to a ramdisk device at /dev/ram0, in such a way that there will be no need to use mke2fs: I could mount 开发者_高级运维the image and device and find that both are identical.

Ideally this would use only linux commands.

My ideas so far: Mounting the image on a loopback and using basic IO to put the data from one device into the other. I could probably do this with C. Also, somehow finding the physical address of the ramdisk device and using linux or C commands to put the file directly into the memory.

Thanks in advance.

P.S: I know that the kernel somehow flags memory which was used for ramdisks so the system does not reclaim it. Anyone know where these flags are?


Any kind of copy command is going to require a partition and filesystem at the destination. However, dd can work at the disk or partition level, by just specifying the disk (eg /dev/sda) or partition (eg (dev/sda1) level. So in theory, you could do

dd if=ramdisk_image_file of=/dev/ram0
0

精彩评论

暂无评论...
验证码 换一张
取 消