What dd command do i use to convert a 1TB image file back to files/directories?
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.
I know it should be the opposite of the command i used to create it, but that was a long time ago and i do not know which command was used.
In this case, first find out what kind of image it is. If it is a filesystem image, follow rkelsen's suggestion.
You could use the file command to guess what kind of file it is. The filename may also provide a clue. Once you have an idea of the file's format, you will know which tools to use to open it.
I copied a whole hdd that was fat formatted, but I copied it in linux to an ext4 formatted hdd as a single image.
I want to get all of the thousands of file/directories back in a NON image format and save it to a new directory on my hdd which does not take up the whole hdd or, ideally, have to create a new partition. rather, use the existing partition and just make a new directory to transfer the files to.
I copied a whole hdd that was fat formatted, but I copied it in linux to an ext4 formatted hdd as a single image.
Then that image contains a FAT filesystem. Use the above mount commands to try accessing it. You can add the option -t vfat, but mount should be able to figure out the filesystem type automatically.
If /dev/sdx# is a devicefile, this doesn't work. If it is a directory, you will just copy the image to another file under /dev. This will fill up the /dev filesystem almost immediately. In other words, don't do this.
If this is indeed a filesystem image, you don't need to copy it to a partition. Just mount it as suggested above.
Last edited by berndbausch; 11-27-2020 at 04:06 AM.
Reason: typos
if you copied the entire drive to an image file the only way to restore via the dd command would be to another physical hard drive of the same size. By the way the file size of the entire drive would be 1 TB. As suggested you can mount a partition from the image file and then copy the desired files to an existing directory assuming you have enough free space.
Before you can mount an existing partition from the image file you need to know the byte offset of a partition from the beginning of the drive since you can not mount an entire drive image. The kpartx utility does all that for you and automatically creates the loop devices.
Code:
kpartx -a -v myfiles.img
mount /dev/mapper/loop0p1 /mnt/myfiles
To unmount and release loop devices.
umount /mnt/myfiles
kpartx -d -v myfiles.img
In this case, first find out what kind of image it is. If it is a filesystem image, follow rkelsen's suggestion.
You could use the file command to guess what kind of file it is. The filename may also provide a clue. Once you have an idea of the file's format, you will know which tools to use to open it.
the source (fat) hdd says "fuse" filesystem. i copied this hdd using following command: for sure
You can use dd to write the image back to disk, but you'd have to be careful to not overwrite partition boundaries, etc.
If I write it back to disk, what dd command would I use? I have to check the reccs already given, but for the moment, i'll assume i'm not sure which one. thx
Then that image contains a FAT filesystem. Use the above mount commands to try accessing it. You can add the option -t vfat, but mount should be able to figure out the filesystem type automatically.
If /dev/sdx# is a devicefile, this doesn't work. If it is a directory, you will just copy the image to another file under /dev. This will fill up the /dev filesystem almost immediately. In other words, don't do this.
If this is indeed a filesystem image, you don't need to copy it to a partition. Just mount it as suggested above.
correction: it was probably "/media/directory.name" and then it put the image in there with its former filename (name from source hdd)
You can't use the dd command to restore the files and if you do not want to over write the drive then as suggested mount the filesystem image file and copy the files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.