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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-26-2014, 06:20 PM
|
#1
|
Member
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 913
Rep:
|
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.
|
|
|
10-26-2014, 06:44 PM
|
#2
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
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.
|
|
|
10-26-2014, 06:51 PM
|
#3
|
Member
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 913
Original Poster
Rep:
|
Quote:
Originally Posted by suicidaleggroll
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"
|
|
|
10-26-2014, 07:23 PM
|
#4
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
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.
|
|
|
10-26-2014, 07:35 PM
|
#5
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
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.
|
10-26-2014, 08:38 PM
|
#6
|
Member
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 913
Original Poster
Rep:
|
That makes a great deal more sense now, many thanks indeed.
|
|
|
All times are GMT -5. The time now is 10:25 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|