LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-21-2020, 01:03 AM   #1
DownSouth
LQ Newbie
 
Registered: Apr 2020
Posts: 27

Rep: Reputation: Disabled
Qustions re using 'dd' command


Hello

I'm intending to use the 'dd' command to transfer a Linux installation from one USB
to another USB. The target partition will be slightly larger than the source partition.
I have researched the details of the command and triple checked with other reliable
sources. However, there are a couple of questions I need answered before I begin.

I will use a host system, plug in the source USB and once it's mounted plug in the
target USB & run the command from the host system. Process will be performed
on a fairly basic machine with just 2GB ram.

First question: do both USBs need to be mounted or, just the source USB?

Logic suggests they should both be mounted, but logic without experience is why
a worthwhile forum such as LQ is necessary. :-)

Second question - the numerical figure in the command to specify the data transfer
rate - should that be kept to a fairly low level (say, 4096) to ensure accuracy?
The source partition is about 12GB.

thanks
DownSouth
 
Old 11-21-2020, 01:38 AM   #2
lvm_
Member
 
Registered: Jul 2020
Posts: 912

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
If the source device is being written to during copying you may will end up with corrupted target filesystem, so the source device must be either not mounted at all or mounted read-only. Target must not be mounted as modifying a mounted filesystem bypassing its driver will result in all sorts of nasty consequences. If target device is larger you will have to resize partitions and filesystems after copying to utilize all available space. Restricting bandwidth will not affect copying accuracy, its primary and only goal is to manage system load.
 
1 members found this post helpful.
Old 11-21-2020, 01:43 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
If you want to copy one partition (e.g. /dev/sdb1) to another (e.g. /dev/sdc1), neither the source nor the target should be mounted. The command would be something like
Code:
dd if=/dev/sdb1 of=/dev/sdc1 bs=1M
I am not aware of a dd parameter that specifies the data transfer rate. It goes as fast as it can. The bs parameter in my example indicates the amount of data tranferred by a single read and write request. The larger it is, the fewer I/O requests are generated, leading to less overhead and better performance.
 
1 members found this post helpful.
Old 11-21-2020, 01:53 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by DownSouth View Post
First question: do both USBs need to be mounted or, just the source USB?

Logic suggests they should both be mounted, but logic without experience is why
a worthwhile forum such as LQ is necessary. :-)
Mounting is for filesystems.
dd does not (necessarily) deal with filesystems, mounting is not required, might even be harmful to write operations.

Quote:
Originally Posted by berndbausch View Post
I am not aware of a dd parameter that specifies the data transfer rate. It goes as fast as it can. The bs parameter in my example indicates the amount of data tranferred by a single read and write request. The larger it is, the fewer I/O requests are generated, leading to less overhead and better performance.
That said, the default blocksize is so small that it will go significantly slower.
I usually use bs=4M, but if there's enough memory one could go int GBs... e.g. bs=1G
This does not affect accuracy in any way whatsoever.
dd is always bit-precise.
 
1 members found this post helpful.
Old 11-21-2020, 02:18 AM   #5
DownSouth
LQ Newbie
 
Registered: Apr 2020
Posts: 27

Original Poster
Rep: Reputation: Disabled
Many thanks for the detailed responses, everyone.

Just one more question - bs=4M, given that the host machine only has 2GB ram could I (safely)
raise that to bs=10M? Thinking of the other comment that the less I/O requests there are the
better the performance. Or, would keeping to bs=4M be recommended for that machine?
 
Old 11-21-2020, 02:33 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
The bs parameter is merely logical - I did some low-level tracing and it appears to make no difference to the actual physical I/O performed. I use 4M on much larger systems, purely out of habit.
 
1 members found this post helpful.
Old 11-21-2020, 03:55 AM   #7
DownSouth
LQ Newbie
 
Registered: Apr 2020
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
The bs parameter is merely logical - I did some low-level tracing and it appears to make no difference to the actual physical I/O performed. I use 4M on much larger systems, purely out of habit.
Thanks - appreciate you responding.
 
Old 11-22-2020, 10:20 AM   #8
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,342

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by DownSouth View Post
Many thanks for the detailed responses, everyone.

Just one more question - bs=4M, given that the host machine only has 2GB ram could I (safely)
raise that to bs=10M? Thinking of the other comment that the less I/O requests there are the
better the performance. Or, would keeping to bs=4M be recommended for that machine?
With 2G memory you would be ahead to check how much memory is actually free with the system operating. Use the "free" command and it will tell you how much is available, used, free, and more. I would suggest using any block size you choose up to about half of the free memory number, although you should make it in increments of 1K multiples. If your memory starts to get full then it will begin to swap excessively and really slow things down.

As has already been mentioned, having both source and destination unmounted is best.
 
Old 12-09-2020, 03:35 AM   #9
DownSouth
LQ Newbie
 
Registered: Apr 2020
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
With 2G memory you would be ahead to check how much memory is actually free with the system operating. Use the "free" command and it will tell you how much is available, used, free, and more. I would suggest using any block size you choose up to about half of the free memory number, although you should make it in increments of 1K multiples. If your memory starts to get full then it will begin to swap excessively and really slow things down.

As has already been mentioned, having both source and destination unmounted is best.
Computersavvy, I somehow missed your response at the time. However, I am still grateful
for the input - have used the "free" command and all appears OK. My belated thanks.
 
  


Reply



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
bitmap file format qustions deathalele Programming 2 02-06-2009 11:57 AM
The console Qustions! every one wants to know! livecrow Linux - Newbie 2 04-03-2007 01:15 PM
Mandrake 7 - Absouloute beginner qustions jimlg Linux - Newbie 11 10-24-2003 06:26 PM
MPlayer qustions grinder Linux - Software 5 06-22-2003 12:42 AM
A couple of newbie qustions about Mandrake 9.1 javiersf Linux - Software 3 04-09-2003 08:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:44 PM.

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