2

I am new to file systems and i just want to ask, are there any methods to save my file to secondary memory using ram disk file system ?

  • 1
    If you want to access a specific Flash device, do not use an ambiguous term like *"secondary memory"*. Flash memory is unlike a block device such as HDD. Flash memory requires the [MTD subsystem](http://www.linux-mtd.infradead.org/), which is typically not installed on PCs running Linux. – sawdust Mar 07 '16 at 07:46
  • 2
    yes i am using nor flash and mtd drivers are present for that and now i want to save a file to nor flash.can u help me in that??? – konduri praveen Mar 07 '16 at 08:20
  • Did you read the MTD FAQ? Have you defined MTD partitions? What's in **/dev** for those partitions? Do you want to write directly to the char device? Or use a filesystem in the partition? Downvoted for showing no apparent research effort and an unclear question. – sawdust Mar 07 '16 at 08:37
  • You need to have partitions in the flash and mount the partition somewhere. /mnt may be. And write to /mnt/whateverfilename. If there are no valid partitions and file systems, then you will have to write specific programs to access the device and perform write. – subin Mar 07 '16 at 08:42
  • What is a linux distribution you are using? Is it regular GNU/Linux (like on x86) or it's Android? Also, please clarify your question: do you want to just add some file to ramdisk file so that it will appear when you boot your ramdisk, or you are trying to save some file to file system being in RAM (ramdisk) while it's already booted? In second case, that file will be vanished after reboot, because ramdisk being created from image file every time you boot your system, and writing file to RAM will not affect your ramdisk image file. – Sam Protsenko Mar 07 '16 at 09:32
  • 1
    I right now working in embedded board of kernel 2.6.33.7 , i am not specific to any char driver i just want to write a file to flash, and i am using partition /dev/ram for ram disk filesystem @sawdust – konduri praveen Mar 07 '16 at 11:33
  • thanks for your support , i have followed this technique in mounting the jffs2 with the command "mount -t jffs2 /dev/mtdblock1 /mnt " do i need to follow the same procedure here also for mount /mnt for ram disk? please help me in finding the mount command. @subin – konduri praveen Mar 08 '16 at 05:51
  • I am using cross compiler and using the bare linux 2.6.33.7 kernel for power-pc platform. as mentioned above i just want so save a file to flash so that i can read back the file after reboot. @SamProtsenko – konduri praveen Mar 08 '16 at 06:29
  • Yes, you need to follow the same procedure. If you have the partitions in jffs2 format, and your planned mount point is /mnt, you can use the same command you mentioned above. – subin Mar 08 '16 at 06:47
  • @konduripraveen So ramdisk has nothing to do with your task, you shouldn't have mentioned it to not confuse us. You should have some sort of partition table on your flash, format partition as some file system (google for flash file systems names), then mount desired partition to some directory and just write (copy) your file to that partition. Once done you can sync/unmount it, and file will be available after reboot. But if you want to add some file to your ramdisk (which is usually mounted after reboot to RAM from ramdisk image file), the procedure will be completely different – Sam Protsenko Mar 08 '16 at 07:20
  • 2
    yes it worked thanks for you answer @subin actually what i did was i mounted with command " mount -t jffs2 /dev/mtdblock1 /mnt" and copied the files into /mnt and did " umount /mnt " then i restarted the board and again gave the command "mount -t jffs2 /dev/mtdblock1 /mnt" and found that all the files that i have copied are been present. and this is the output i am expecting. thanks again for all your support. – konduri praveen Mar 08 '16 at 16:13

1 Answers1

2

if you want to save any file in the ramdisk filesystem you have to link your file system partition to any of the location in the root filesystem and then you have to copy the file into that location and you can read it back after restarting your board. lets have an example

if you have your file system /dev/mtdblock1 (if you are using the mtd drivers) and if you have support for jffs2 , then you can have the mounting as

  mount -t jffs2 /dev/mtdblock1 /mnt/

then after that you can copy your files into /mnt/ and then unmount it. if you want to get that file back you have to mount /mnt/ with the same command as given above. this was working even after restarting my board. Thank you.......!