Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to revert half-performed conversion? #33

Open
WeiweiDuan opened this issue Aug 30, 2020 · 18 comments
Open

[Question] How to revert half-performed conversion? #33

WeiweiDuan opened this issue Aug 30, 2020 · 18 comments

Comments

@WeiweiDuan
Copy link

Hi,

I tried to use fsremap to convert the loop file into the device, but I got the error showing in the following screenshot. Any idea about how to solve it. Thanks!
fsremap_error

@cosmos72
Copy link
Owner

The commands are correct, but it seems that mount -r does not work as expected on your /dev/loop0.
Which filesystem does it contain?

@WeiweiDuan
Copy link
Author

Thanks for your response. The filesystem is XFS. I tried to use fstransform command to convert XFS into EXT4, but the /dev/loop0 stored as EXT4 is empty, and the original data converted as loop-file with XFS filesystem.

@cosmos72
Copy link
Owner

Update: there is a mismatch in the paths you're using.

You mount /dev/loop0 to the directory /tmp/weiwei2, but then you attempt to use a file /tmp/fstransform.mount.23404/.fstranform.loop.26458 which is not inside such mount directory.

At least one of the paths you are using is wrong.
Maybe an ls -al /tmp/weiwei2 (while /dev/loop0 is mounted there) would help understanding what are the correct paths to use.

@WeiweiDuan
Copy link
Author

Let me clarify what I want to do. I want to remap the loop-file into original files. According to the instruction in the webpage, I thought I need an empty disk to store the original files. "/dev/loop0" is an empty disk mounted in "/tmp/weiwei2". The data is in "centos_arya-home" disk mounted in "/tmp/fstransform.mount.23404/.fstranform.loop.26458" directory. Please correct me if I misunderstood the fsremap command. If I'm wrong, do you know how to convert the loop-file back to the original files. Thanks a lot for your help.

@cosmos72
Copy link
Owner

cosmos72 commented Aug 31, 2020

Now it's clearer, thanks. You want to undo the half-executed conversion, not to finish it.

If your target disk /dev/loop0 is empty and mounted in /tmp/weiwei2,
and your files are currently inside a file /tmp/fstransform.mount.23404/.fstranform.loop.26458,
where your disk centos_arya-home is mounted on /tmp/fstransform.mount.23404,

there is no need to use fsremap: you can just mount the .fstranform.loop.XXYYZ loop file somewhere to access its contents.

Then a regular cp is enough to copy the contained files:

sudo -s
mkdir /tmp/loop-src
mount -o ro /tmp/fstransform.mount.23404/.fstranform.loop.26458 /tmp/loop-src
cp -av /tmp/loop-src/. /tmp/weiwei2

@cosmos72 cosmos72 changed the title fsremap the error said that that device is not read-only, but the device is read-only [Question] How to revert half-performed conversion? Aug 31, 2020
@WeiweiDuan
Copy link
Author

WeiweiDuan commented Aug 31, 2020

Thanks a lot for your prompt reply. I followed your instruction. But the loop-file becomes two loop files after copying to the disk. Please check the details in the following screenshot. Should I do the instruction again for the two loop files? Really appreciate your help!
image

@cosmos72
Copy link
Owner

cosmos72 commented Aug 31, 2020

It depends, there are a lot of files and mountpoints involved.
Which files are mounted where? The output of mount would help here.

[Update] what you say "do the instruction again for the two loop files" is needed only if you took the half-converted disk and attempted to convert it again.

@WeiweiDuan
Copy link
Author

I mounted loop-file to '/data/loop-src' directory using "mount -o ro /tmp/fstransform.mount.23404/.fstransform.loop.26458 /data/loop-src/". Then copy files in /data/loop-src to '/tmp/weiwei' using "cp -av /data/loop-src/. /tmp/weiwei". Here is the output of mount:
image
image

@cosmos72
Copy link
Owner

cosmos72 commented Aug 31, 2020

Then yes: do the instruction again for the two loop files.

This is because the conversion was attempted again (at least two times) on a half converted disk.

You need to undo all the nesting (russian doll style) created by the multiple conversion attempts.

In othe words, after you have extracted the content of those two .fstransform.loop.XXYYZ files, you may find more of them - repeat the procedure every time until you extract all of them

@WeiweiDuan
Copy link
Author

I have one more question. When I do "cp -av /tmp/loop-src/. /tmp/weiwei2", should the disk mounted in "tmp/weiwei2" be empty. Or can I create a directory and copy the content in /tmp/loop-src into it? Thanks for your help!

@cosmos72
Copy link
Owner

cosmos72 commented Aug 31, 2020

No, there is no need for the destination disk of cp -av SOURCE DESTINATION to be empty.
You can create a directory and copy the content from /tmp/loop-src into it.

The only caveat is: be careful not to run out of space in the destination disk (watch df in another terminal is your friend)

@WeiweiDuan
Copy link
Author

I mount the .fstransform.loop.22262 to '/data/loop-src2' and copied '/data/loop-src2' to '/data/loop-recovery'. But there still the loop-file in the loop-recovery. Should it be the original files?
image

@WeiweiDuan
Copy link
Author

After copying *loop.26458 to a directory, it becomes two loop files (23404, 22262). I tried to mount loop.22262 to a new directory, but the error said that the filesystem is 'null'. Do you have any idea about the error? Thanks for your help!
image

@cosmos72
Copy link
Owner

cosmos72 commented Sep 5, 2020

Some of the .fstransform.loop.XXYYZ files may be empty - it happens if the conversion was interrupted very early.
You can recognize them because the command file will say they are data. For example:

$ file .fstransform.loop.22262
.fstransform.loop.22262: data

If instead it contains a mountable file system, it will be detected:

$ file .fstransform.loop.22263
.fstransform.loop.22263: Linux rev 1.0 ext4 filesystem data, UUID=36f7e75a-0b26-4076-8dc6-cc31ffaf7184 (extents) (64bit) (large files) (huge files)

@WeiweiDuan
Copy link
Author

Thanks for your reply. It turns out that the loop-file is mountable, but when I mounted it, there is an new error. Could you help me check about it? Really thanks for your help.
Here is the screenshot shown that the loop-file is mountable
image
Here is the new error:
image

@cosmos72
Copy link
Owner

cosmos72 commented Sep 7, 2020

You can run a filesystem check, to detect and (where possible) fix errors:

sudo e2fsck /data/loop-src/.fstransform.loop.2262

To fix errors, the file must be inside a writeable file-system (not read-only).

@WeiweiDuan
Copy link
Author

WeiweiDuan commented Sep 8, 2020

Thanks for your response. I did mount and copy successfully. But when I checked the file type of the file after 'cp' command, it is data. What I want is the original files, which should be a directory. Can I convert the intermediate converted files to the original files (the directory)? Here is the file after conversion using 'mount' and 'cp' commands. Thanks for your help.
image

@cosmos72
Copy link
Owner

cosmos72 commented Sep 9, 2020

If mount fails and file says it's raw data, there is not much you can do: it's very likely that the file contains nothing useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants