Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 05-17-2007, 01:37 PM   #1
LQ Newbie
Registered: Mar 2007
Location: Italy
Distribution: Debian
Posts: 18

Rep: Reputation: 0
writing raw data to a block device

I'm trying to copy the whole contents of a CF memory card. I did a
cat /dev/sdb >file
And it works ok. Now I can change the card and write it:
cat file >/dev/sdb
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?
Old 05-17-2007, 02:26 PM   #2
Registered: Mar 2004
Posts: 36

Rep: Reputation: 15
Running the "sync" command shouldn't hurt anything. You can also transfer the raw data using the "dd" command.
Old 05-17-2007, 02:37 PM   #3
LQ Newbie
Registered: Mar 2007
Location: Italy
Distribution: Debian
Posts: 18

Original Poster
Rep: Reputation: 0
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.
Old 05-17-2007, 04:06 PM   #4
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Debian "Testing"
Posts: 6,116

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
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.
Old 05-17-2007, 10:37 PM   #5
Registered: Oct 2006
Posts: 460

Rep: Reputation: 31
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
find hex patterns in raw hdd block device dtimms Linux - Software 6 01-04-2006 05:52 AM
writing raw data to a tiff file James_dean Programming 4 10-25-2005 05:03 AM
block device raw access rvilarl Programming 0 10-24-2004 12:53 PM
How to enable raw i/o on partition (e.g. /dev/hdc1, non block device) psyclobe Programming 2 12-13-2003 06:59 AM
"permission denied" when I try to send raw data to the sound device. Travis86 Linux - Hardware 2 10-29-2003 09:08 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:23 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration