LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 05-17-2007, 01:37 PM   #1
nacio
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
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?
 
Old 05-17-2007, 02:26 PM   #2
AlbinoJap
Member
 
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
nacio
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
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,008

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
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
studioj
Member
 
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.
 
  


Reply


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


All times are GMT -5. The time now is 11:22 AM.

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