LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-26-2014, 06:20 PM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 913

Rep: Reputation: 71
Using dd on mounted and unmounted partitions


Hi all,

Can some kind soul summarize the rules of using dd viz-a-viz when must and/or mustn't source and destination drives/partitions be mounted or unmounted during the copying process?
I've read many contractory views on the matter which is highly confusing.

cheers,

CC.
 
Old 10-26-2014, 06:44 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143
Pretty simple in my mind.

When you're reading/writing to a file on a partition, it should be mounted (obviously, in order to access the file).
When you're reading/writing to a raw disk, it should be unmounted to prevent corruption or inconsistency.
 
Old 10-26-2014, 06:51 PM   #3
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 913

Original Poster
Rep: Reputation: 71
Quote:
Originally Posted by suicidaleggroll View Post
Pretty simple in my mind.

When you're reading/writing to a file on a partition, it should be mounted (obviously, in order to access the file).
When you're reading/writing to a raw disk, it should be unmounted to prevent corruption or inconsistency.
The reasons given don't make sense to me.
By your reasoning, when you're reading/writing to a file on a partition, it should also be UNmounted - "to prevent corruption or inconsistency"
 
Old 10-26-2014, 07:23 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143
There's no need to unmount the entire filesystem to prevent writing to a single file, provided it's not some kind of system file that's constantly in use. You just want to make sure it's not being written to by some other process while you're using dd on it, which should be pretty easy to do for the vast majority of files somebody might want to use dd on.

Besides, as I said before, once you unmount the filesystem you lose access to individual files, so it's not an option anyway. If you're truly worried about it you can always remount the partition in read-only mode first, as long as you're just trying to read from the file.

Last edited by suicidaleggroll; 10-26-2014 at 07:25 PM.
 
Old 10-26-2014, 07:35 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143Reputation: 2143
Perhaps this will be a bit more specific:

There are four use-cases for dd and dealing with files. Writing to a file, reading from a file, writing to a raw disk/partition, reading from a raw disk/partition.

1) Writing to a file - the filesystem obviously must be mounted in rw mode in order to write to a file on it, so that's your only option.

2) Reading from a file - You want to make sure the file's contents do not change mid-read. 99.9% of the time you can directly control when/how the file you'll be reading from dd gets written to, so just shut off whatever process writes to it and you're fine. If you want to be on the safe side, remount the filesystem in read-only mode. Since you're dealing with a file on a partition, unmounting the partition entirely is not an option.

3) Writing to a raw disk/partition - It must be unmounted.

4) Reading from a raw disk/partition - Same rule as #2, but it is usually MUCH more difficult to control writes to an entire disk/partition (remember this includes access timestamping on files, etc.), so you're much better off just unmounting entirely, or at a minimum remounting in read only mode.
 
1 members found this post helpful.
Old 10-26-2014, 08:38 PM   #6
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 913

Original Poster
Rep: Reputation: 71
That makes a great deal more sense now, many thanks indeed.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can a mounted FS be edited and afterwards unmounted ? dann_radkov Linux - Newbie 2 03-07-2012 10:42 AM
Unmounted (and unwanted) partitions show up in Nautilus jlavik Linux - General 8 07-17-2011 11:26 AM
Local partitions are being spontaneously unmounted. HypoCee Linux - Server 3 12-19-2006 04:55 PM
how to see unmounted partitions Vensan Linux - General 1 09-07-2006 02:41 AM
playing DVD, CD and mounted & unmounted drive Q. brjoon1021 Linux - Newbie 0 07-25-2006 10:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:25 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration