LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 02-08-2024, 09:35 AM   #1
newbiesforever
Senior Member
 
Registered: Apr 2006
Location: Iowa
Distribution: Debian distro family
Posts: 2,375

Rep: Reputation: Disabled
dd vs. e2image


For copying a partition, I'm trying to follow someone's advice to use dd rather than e2image. The problem is that dd doesn't say how long it's going to take. I've seen dd run for hours for a 50 GB partition without finishing, whereas e2image clones it in maybe 15 minutes. Presently I'm giving dd another try. Should have remembered to start my stopwatch right away; but I know it's certainly taking longer than e2image. It's probably been half an hour.
 
Old 02-08-2024, 10:02 AM   #2
lvm_
Member
 
Registered: Jul 2020
Posts: 928

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
Actually neither of them copies partitions - dd copies files and if a block device is selected it will copy it too, while e2image copies extN filesystems, and by copying only used blocks can do it faster and use less space. Could've been a good tool, where it not for its fondness of sparse files. Note that dd's performance can be greatly reduced by selecting a too small block size value, and copy progress can be checked at any time by sending USR1 signal to dd. And then there is fsarchiver...
 
1 members found this post helpful.
Old 02-08-2024, 10:11 AM   #3
newbiesforever
Senior Member
 
Registered: Apr 2006
Location: Iowa
Distribution: Debian distro family
Posts: 2,375

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lvm_ View Post
copy progress can be checked at any time by sending USR1 signal to dd....
USR1 signal? And how do I send that?
 
Old 02-08-2024, 10:18 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,708

Rep: Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898
dd command has the status=progress option.

dd command technically copies bytes not necessarily files.

Last edited by michaelk; 02-08-2024 at 10:21 AM.
 
1 members found this post helpful.
Old 02-08-2024, 10:44 AM   #5
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,788

Rep: Reputation: 1468Reputation: 1468Reputation: 1468Reputation: 1468Reputation: 1468Reputation: 1468Reputation: 1468Reputation: 1468Reputation: 1468Reputation: 1468
Quote:
Originally Posted by newbiesforever View Post
USR1 signal? And how do I send that?
Code:
killall -USR1 dd
 
Old 02-08-2024, 11:08 AM   #6
lvm_
Member
 
Registered: Jul 2020
Posts: 928

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
Quote:
Originally Posted by michaelk View Post
dd command technically copies bytes not necessarily files.
Code:
DD(1)                                                        User Commands                                                        DD(1)

NAME
       dd - convert and copy a file

SYNOPSIS
       dd [OPERAND]...
       dd OPTION

DESCRIPTION
       Copy a file, converting and formatting according to the operands.
 
Old 02-08-2024, 12:27 PM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
this is the first hit: https://askubuntu.com/questions/2155...progress-of-dd
 
Old 02-08-2024, 12:54 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,708

Rep: Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898
dd - disk/data duplicator

Since everything is a file the description is true but it can do a lot more.

https://www.linuxquestions.org/linux...ything_With_DD

You can copy a block device i.e. if=/dev/sdx or a partition i.e. if=/dev/sdxy but as posted it will copy unused space as well so if the partition is large it will take time.
 
Old 02-08-2024, 01:04 PM   #9
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,493

Rep: Reputation: Disabled
Basically, when using dd, give it a bs= (block size) - I often use 1G - the basic size is about 512 bytes if you don't, so will take a very long time...
 
1 members found this post helpful.
Old 02-08-2024, 11:55 PM   #10
lvm_
Member
 
Registered: Jul 2020
Posts: 928

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
Quote:
Originally Posted by michaelk View Post
Since everything is a file the description is true but it can do a lot more.
No it can't. Block device is a file. Everything, absolutely everything dd operates on is files and it does exactly what is says in the man page, no less and no more. It is not dd which can do more but linux concept of a file is wider than in MS DOS.
 
Old 02-09-2024, 09:31 AM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,708

Rep: Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898
I can copy bytes from a tape drive.
dd if=/dev/st0 of=/whatever bs=512 count=1

I can copy bytes from a drive i.e legacy MBR
dd if=/dev/sdx of=/whatever bs=446 count=1

I can create an empty file by copying bytes
dd if=/dev/null of=/whatever bs=xx count=y

I can create an ISO image file from an optical disk
dd if=/dev/sr0 of=/whatever/

If a partition is a file i.e. /dev/sdxy then obviously it can be copied.
 
Old 02-09-2024, 09:39 AM   #12
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Note the parameters you give to dd. if = input file, of = output file.
 
Old 02-10-2024, 07:23 AM   #13
lvm_
Member
 
Registered: Jul 2020
Posts: 928

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
Quote:
Originally Posted by michaelk View Post
I can copy bytes from a tape drive.
dd if=/dev/st0 of=/whatever bs=512 count=1
Yes, there are many wondrous things, and they are all files. It all comes into focus once you accept that everything starting with a slash is a file.

Code:
INTRO(4)                                                Linux Programmer's Manual                                               INTRO(4)

NAME
       intro - introduction to special files

DESCRIPTION
       Section 4 of the manual describes special files (devices).

FILES
       /dev/* — device files
 
Old 02-10-2024, 07:31 AM   #14
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
In short, everything which can produce and consume bytes (information) is a file. A directory will specify the location of it and the kernel will know how to read from and write to the given location or device.
Programs do nothing else, just read and write files and compute/manage the data (in between).
 
Old 02-15-2024, 05:36 PM   #15
newbiesforever
Senior Member
 
Registered: Apr 2006
Location: Iowa
Distribution: Debian distro family
Posts: 2,375

Original Poster
Rep: Reputation: Disabled
Well, I'm now using that status=progress parameter. When dd reports a status such as
Code:
17179869184 bytes (17 GB, 16 GiB) copied, 537 s, 32.0 MB/s
, the status isn't entirely clear. Which GB is the amount of data copied, and which is the amount remaining? I'm guessing the first is the amount copied.
 
  


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
what if I tried to e2image two partitions at once? newbiesforever Linux - Software 2 08-21-2023 09:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:45 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