How can I dd copy all files from 1 hdd to another but without the target being in an image file?
Linux - NewbieThis 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
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.
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.
Disregarding the error causing the hdd to stop copying...
If I put a partion table on, partion, and format/ext4 - can i accurately dd the source hdd using the following?
Code:
sudo dd if=/dev/sdx1 bs=16M of=/dev/sdy1
...this way not removing the partition table, etc...
??
Yes, that should work as long as the destination partition is of same or larger size as the source partition. However, you do not need to format the destination partition, format structure will be carried over from the source partition. If the destination partition is larger than the source partition, one "resize2fs" command can add remaining space to the filesystem.
Disregarding the error causing the hdd to stop copying...
If I put a partion table on, partion, and format/ext4 - can i accurately dd the source hdd using the following?
Code:
sudo dd if=/dev/sdx1 bs=16M of=/dev/sdy1
...this way not removing the partition table, etc...
??
NO! While that would work exactly as you asked, I don't recommend it. The new partition will be exactly the same as the one on sdx and will gain nothing since it is now on the new drive with the same warts and blemishes. You could (space permitting) mount the new partition you just created somewhere like /mnt then copy the device to an image file with
Code:
sudo mount /dev/sdy1 /mnt
sudo dd if=/dev/sdx1 of=/mnt/sdx1.img bs=16M
Now you have an image file to work with instead of the original, possibly failing, sdx. You might then look at ddrescue or photorec as a tool to assist in recovery of your files from the image. Ddrescue scans the entire drive or image attempting to make a clean image. Photorec scans the entire drive or image attempting to recover files.
You also could use ddrescue or photorec on the original drive or partition but that is not recommended since the recovery efforts would hammer the mechanical drive and potentially cause cascading failure.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Quote:
Originally Posted by blooperx3
Disregarding the error causing the hdd to stop copying...
If I put a partion table on, partion, and format/ext4 - can i accurately dd the source hdd using the following?
Code:
sudo dd if=/dev/sdx1 bs=16M of=/dev/sdy1
...this way not removing the partition table, etc...
??
I'm scratchin' my head trying to understand why you're trying to bend 'dd' -- which is intended to do block-by-block copying of objects like devices and/or individual files and not directory trees -- into a tool for backing up multiple files. There are much, much better tools whose purpose in life is to copy files. Some of them have even been mentioned above. And most of those -- esp. rsync, find|cpio, and, I'm reasonably sure, "cp -R" (actually don't use that one too much myself) -- avoid the problem with spaces-in-filenames that your original post mentioned that you were worried about.
Thanks. If they had been OpenZFS, then there would have been additional options but you will be able to make a fast and accurate copy across two EXT4 partitions using rsync, unless you are dealing with millions of files. I'm not sure where the threshold is but at that level you'd have to split up the transfer into smaller hierarchies.
NO! While that would work exactly as you asked, I don't recommend it. The new partition will be exactly the same as the one on sdx and will gain nothing since it is now on the new drive with the same warts and blemishes. You could (space permitting) mount the new partition you just created somewhere like /mnt then copy the device to an image file with
Code:
sudo mount /dev/sdy1 /mnt
sudo dd if=/dev/sdx1 of=/mnt/sdx1.img bs=16M
Now you have an image file to work with instead of the original, possibly failing, sdx. You might then look at ddrescue or photorec as a tool to assist in recovery of your files from the image. Ddrescue scans the entire drive or image attempting to make a clean image. Photorec scans the entire drive or image attempting to recover files.
You also could use ddrescue or photorec on the original drive or partition but that is not recommended since the recovery efforts would hammer the mechanical drive and potentially cause cascading failure.
Does photorec look for "all files on the hdd" including both non-deleted and deleted, or just 'deleted' files?
I used
Code:
sudo dd if=/dev/sdx bs=16M of=/dev/sdy
...worked without an apparent problem, copying almost 1 million items, but the 'target' hdd did have 3,000 less files in the end. The most important thing are the deleted files.
I'm scratchin' my head trying to understand why you're trying to bend 'dd' -- which is intended to do block-by-block copying of objects like devices and/or individual files and not directory trees -- into a tool for backing up multiple files. There are much, much better tools whose purpose in life is to copy files. Some of them have even been mentioned above. And most of those -- esp. rsync, find|cpio, and, I'm reasonably sure, "cp -R" (actually don't use that one too much myself) -- avoid the problem with spaces-in-filenames that your original post mentioned that you were worried about.
Decided not to use the partitions in the command. My reason was just trying to copy "to" an ext4 hdd filesystem - the source hdd is not ext4.
It seems safer to break up the whole hdd into multiple partitions in case there is a problem with opening 1 partition, and that were the only partition on the entire hdd. With multiple partitions, less chance data loss - my opinion after reading.
It seems safer to break up the whole hdd into multiple partitions in case there is a problem with opening 1 partition, and that were the only partition on the entire hdd. With multiple partitions, less chance data loss - my opinion after reading.
Agree/ disagree?
Absolutely, data recovery a lot faster on smaller partitions also. Which gets the partition re-formatted and back in service much faster after a Whoops! also. But ultimately, have a backup drive of same or larger size and back up your data, then you don't have to mess with recovery efforts in a Whoops! event. Not hard to back up operating systems in compressed files also.
Absolutely, data recovery a lot faster on smaller partitions also. Which gets the partition re-formatted and back in service much faster after a Whoops! also. But ultimately, have a backup drive of same or larger size and back up your data, then you don't have to mess with recovery efforts in a Whoops! event. Not hard to back up operating systems in compressed files also.
Thanks. If they had been OpenZFS, then there would have been additional options but you will be able to make a fast and accurate copy across two EXT4 partitions using rsync, unless you are dealing with millions of files. I'm not sure where the threshold is but at that level you'd have to split up the transfer into smaller hierarchies.
The result above is from the first one; using second one, nothing reported to transfer based on terminal output --- just zeros show up for 'bytes received' 'speedup'...........
NOTHING SHOWS UP IN DESTINATION DIRECTORY "/mnt/6BLACK.COPY.HDD2"
Correct. That is by design.
Code:
man rsync
sudo rsync -av --dry-run /media/mnt/K/ /mnt/6BLACK.COPY.HDD2/
There are three options there, each explained in the manual page. Even if you don't like to, it is important to look at each of the options at least once in the manual page, especially before trying random formulas from the net.
man rsync
sudo rsync -av --dry-run /media/mnt/K/ /mnt/6BLACK.COPY.HDD2/
There are three options there, each explained in the manual page. Even if you don't like to, it is important to look at each of the options at least once in the manual page, especially before trying random formulas from the net.
Thanks. I didn't think that the command you posted was random - i felt i could trust it at face value.
Thanks. I didn't think that the command you posted was random - i felt i could trust it at face value.
I think everyone here tries, but errors do creep in. The formula has a safety added to reduce the likelihood of damage in the event of an error in either the formula or its application. Again, the idea is that you must take a quick look in the manual page at the program's description and each of the three options before it will actually write.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.