LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   writing raw data to a block device (https://www.linuxquestions.org/questions/linux-software-2/writing-raw-data-to-a-block-device-554678/)

nacio 05-17-2007 01:37 PM

writing raw data to a block device
 
I'm trying to copy the whole contents of a CF memory card. I did a
Code:

cat /dev/sdb >file
And it works ok. Now I can change the card and write it:
Code:

cat file >/dev/sdb
sync

I run sync in order to make sure buffers are flushed. However, I'm not sure I'm running the right command... man page says "sync flushes filesystem buffers" but I' not accessing the filesystem...
Question is: is it ok to run sync? or is there another program that I should use?

AlbinoJap 05-17-2007 02:26 PM

Running the "sync" command shouldn't hurt anything. You can also transfer the raw data using the "dd" command.

nacio 05-17-2007 02:37 PM

I think I didn't write correctly... sorry! I should have said: is it enough to run sync? I'm in doubt 'cause the filesystem has not been mounted.

tredegar 05-17-2007 04:06 PM

What you have done with cat and sync may well work. You are asking us if it does. The best thing for you to do is test it and find out if it has done what you want to achieve (and you haven't told us what that is).

With linux, there are many ways to achieve what you want. No solution is necessarily "right", but some will be simpler or more "elegant" and robust than others.

I have discovered that running sync can sometimes have unintended consequences: files that are currently open and being written to are immediately closed. This may not be what you want (what else is this multitasking (and therefore very different from windows) OS doing with other files when you issue sync?)

If you want to make sure the buffers are flushed, then unmount the device when you have finished writing to it.

If you just want to clone a memory card you should look at using dd. There are many long threads on this forum about using dd.
There's a search button too.

studioj 05-17-2007 10:37 PM

i might be missing something but
if this is something critical
it would be so easy to write a little utility or alter a sysV utilty to use
fflush on the stream.


All times are GMT -5. The time now is 03:46 AM.