I created an ext2 file-system on /dev/ram0 ramdisk, and mounted it at /mnt/ram.

mkdir /mnt/ram
mkext2fs /dev/ram0
sudo mount /dev/ram0 /mnt/ram -o rw

Reading from ramdisk with dd works.

dd if=/dev/ram0 bs=1 count=1

When I want to write the contents of the file my_file to ramdisk, it fails.

dd if=./my_file of=/dev/ram0 bs=1 count=1
0+0 records in
0+0 records out
0 bytes (0B) copied, 0.000913 seconds, 0B/s

However, just reading the file dumps its content on stdin.

dd if=./my_file bs=1 count=1

The permission on /dev/ram0 shows rw permisssion for root.

ls -l /dev/ram0
brw-rw----   1  root   staff   1,   0   Jul   5   02:56   /dev/ram0

What does prevent dd from writing to /dev/ram0?

  • Im not sure that what you want to do is possible but you better mount the fs instead of trying to overwrite it – Kiwy Jul 5 '18 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.