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

Mounting restored partition-images fails. #261

Open
tps800 opened this issue Jan 23, 2025 · 4 comments
Open

Mounting restored partition-images fails. #261

tps800 opened this issue Jan 23, 2025 · 4 comments

Comments

@tps800
Copy link

tps800 commented Jan 23, 2025

Had a partclone produced image restored into a rwa image file using

# cat /media/tps/backup/2025-01-15-10-img/nvme0n1p3.ntfs-ptcl-img.gz.* | gzip -c -d | /sbin/partclone.restore -C -W -s - -O nvme0n1p3.img
Partclone v0.3.27 http://partclone.org
Die Wiederherstellung des Images (-) auf dem Gerät beginnt (nvme0n1p3.img)
Calculating bitmap... Please wait...
done!
Dateisystem: NTFS
Gerätegröße:  211.9 GB = 51744511 Blöcke
Genutzter Raum: 197.2 GB = 48139910 Blöcke
Freiraum:   14.8 GB = 3604601 Blöcke
Block Größe:    4096 Byte
Verstrichen: 01:00:57, Verbleibend: 00:00:00, Abgeschlossen: 100.00%, Geschwindigkeit:   3.24GB/min,
Current block:   51744511, Total block:   51744511, Complete: 100.00%           
Gesamtzeit: 01:00:57, Ave. Rate:   3.24GB/min, 100.00% completed!
Syncing... OK!
Partclone hat das Image (-) erfolgreich auf dem Gerät wiederhergestellt (nvme0n1p3.img)
Cloned successfully.

Now trying to mount this image using:

# mount -o loop,ro nvme0n1p3.img S
Failed to read last sector (413956094): Das Argument ist ungültig
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
Failed to mount '/dev/loop38': Das Argument ist ungültig
The device '/dev/loop38' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

I found some descriptions to work with imagemount from packet partclone-util but this did not work either. I'm assuming descriptions on how to mount such images broken?

@tps800
Copy link
Author

tps800 commented Jan 23, 2025

Since one told me, option -W is not anymore an alias for --restore_raw_file, I've changed the command line to

# cat ./backup/2025-01-15-10-img/nvme0n1p3.ntfs-ptcl-img.gz.* | gzip -c -d | /sbin/partclone.restore --restore_raw_file -C -s - -O nvme0n1p3.img
Partclone v0.3.27 http://partclone.org
Die Wiederherstellung des Images (-) auf dem Gerät beginnt (nvme0n1p3.img)
Calculating bitmap... Please wait...
done!
Dateisystem: NTFS
Gerätegröße:  211.9 GB = 51744511 Blöcke
Genutzter Raum: 197.2 GB = 48139910 Blöcke
Freiraum:   14.8 GB = 3604601 Blöcke
Block Größe:    4096 Byte
Verstrichen: 01:01:38, Verbleibend: 00:00:00, Abgeschlossen: 100.00%, Geschwindigkeit:   3.20GB/min,
Current block:   51744511, Total block:   51744511, Complete: 100.00%           
Gesamtzeit: 01:01:38, Ave. Rate:   3.20GB/min, 100.00% completed!
Syncing... OK!
Partclone hat das Image (-) erfolgreich auf dem Gerät wiederhergestellt (nvme0n1p3.img)
Cloned successfully.

Now trying to mount this image:

# mount -o loop,ro nvme0n1p3.img S
Failed to read last sector (413956094): Das Argument ist ungültig
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
Failed to mount '/dev/loop38': Das Argument ist ungültig
The device '/dev/loop38' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Since Windows 10, Build 1809 can mount this partition and linux live systems could do the same, I'd assume it a correct NTFS.
The image was created using:

# partclone.ntfs --version
Partclone : v0.3.32 (0.3.31-2-g957df07)

Restoring was done with partclone.restore version v0.3.27. May this be the fault?

@Thomas-Tsai
Copy link
Owner

Hi

To check this image, you can try allocating or dd to create a raw file first. The fatlocate is better to create a small raw file.

and also try to do it step by step, NOT use pipe, so we can make sure the image is fine to restore.

-C for you is not necessary.

I have a small test sudo partclone.restore -s ~/tmp/testnifs.img -W -O ./RAWNTFS and it works fine with me.

reference:

fallocate -l 230G simulation_partition
losetup /dev/loop0 simulation_partition
partclone.restore -s YOURIMAGE -o /dev/loop0
mount /dev/loop0 /mnt

@tps800
Copy link
Author

tps800 commented Jan 25, 2025

Since one meant to try it without piping:

# cat nvme0n1p3.ntfs-ptcl-img.gz.* > nvme0n1p3.ntfs-ptcl-img.gz
# gzip -d -c nvme0n1p3.ntfs-ptcl-img.gz > nvme0n1p3.ntfs-ptcl.img
# partclone.restore -W -s nvme0n1p3.ntfs-ptcl.img -o nvme0n1p3.raw -L ./nvme0n1p3.log
Partclone v0.3.27 http://partclone.org
Die Wiederherstellung des Images (nvme0n1p3.ntfs-ptcl.img) auf dem Gerät beginnt (nvme0n1p3.raw)
Calculating bitmap... Please wait...
done!
Dateisystem: NTFS
Gerätegröße:  211.9 GB = 51744511 Blöcke
Genutzter Raum: 197.2 GB = 48139910 Blöcke
Freiraum:   14.8 GB = 3604601 Blöcke
Block Größe:    4096 Byte
Verstrichen: 01:16:45, Verbleibend: 00:00:00, Abgeschlossen: 100.00%, Geschwindigkeit:   2.57GB/min,
Current block:   51744511, Total block:   51744511, Complete: 100.00%           
Gesamtzeit: 01:16:45, Ave. Rate:   2.57GB/min, 100.00% completed!
Syncing... OK!
Partclone hat das Image (nvme0n1p3.ntfs-ptcl.img) erfolgreich auf dem Gerät wiederhergestellt (nvme0n1p3.raw)
Cloned successfully.

No errors so far!
The file size is exactly the same using pipes or doing all jobs one after one: 211945517056

# ls -l nvme0n1p3.raw
-rw-------+ 1 root root 211945517056 Jan 25 01:08 nvme0n1p3.raw
# mount -o loop,ro nvme0n1p3.raw S
Failed to read last sector (413956094): Das Argument ist ungültig
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
Failed to mount '/dev/loop36': Das Argument ist ungültig
The device '/dev/loop36' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Gives the same error.

@tps800
Copy link
Author

tps800 commented Feb 9, 2025

It worked restoring the whole Disk within a virtual machine. The partition was mountable afterwards via network block devices:

$ sudo modprobe nbd max_part=8
$ sudo qemu-nbd --connect /dev/nbd0 /home/tps/virt/IMAGES/bcl2353-muc.qcow2 
$ sudo mount -o ro,uid=1000,gid=1000 /dev/nbd0p3 /home/tps/S

Afterwards an ls gave:

$ mount-bcl2353-muc m
tps@ivory:~$ ll S
total 1.6G
drwxrwxrwx   1 tps tps 8.0K Jan 25 06:47  ./
drwxr-xr-x 220 tps tps  24K Feb  9 10:46  ../
drwxrwxrwx   1 tps tps 3.0M Jan 10 14:51  Config.Msi/
drwxrwxrwx   1 tps tps    0 Nov 27 18:40  DB/
lrwxrwxrwx   2 tps tps   17 Nov 13  2023 'Dokumente und Einstellungen' -> /home/tps/S/Users/
drwxrwxrwx   1 tps tps 4.0K Jan  9 10:19  INSTALL/
drwxrwxrwx   1 tps tps  16K Jan  9 08:47  PRGS/
drwxrwxrwx   1 tps tps    0 Nov 15  2023  PerfLogs/
drwxrwxrwx   1 tps tps 8.0K Dec 16 17:18  ProgramData/
lrwxrwxrwx   2 tps tps   25 Nov 13  2023  Programme -> '/home/tps/S/Program Files'/
drwxrwxrwx   1 tps tps  12K Jan  8 18:16 'Program Files'/
drwxrwxrwx   1 tps tps 8.0K Dec 16 16:52 'Program Files (x86)'/
drwxrwxrwx   1 tps tps    0 Nov 13  2023  Recovery/
drwxrwxrwx   1 tps tps    0 Nov 13  2023  SMSTSLog/
drwxrwxrwx   1 tps tps 4.0K Jan 13 10:28 'System Volume Information'/
drwxrwxrwx   1 tps tps 4.0K Nov 27 19:20  Users/
drwxrwxrwx   1 tps tps  24K Dec 20 10:10  Windows/
drwxrwxrwx   1 tps tps 4.0K Apr 25  2024 '$Recycle.Bin'/
-rwxrwxrwx   2 tps tps 1.0K Nov 13  2023  .rnd*
-rwxrwxrwx   2 tps tps 250K Jan 10 14:51  ConfigMgrAdminUISetup.log*
-rwxrwxrwx   2 tps tps 1.9M Jan 10 14:51  ConfigMgrAdminUISetupVerbose.log*
-rwxrwxrwx   1 tps tps  179 May 23  2022  Network.bat*
-rwxrwxrwx   1 tps tps 1.3G Feb  2 15:08  pagefile.sys*
-rwxrwxrwx   1 tps tps 256M Feb  2 15:08  swapfile.sys*

Breaking it down it revealed that the Disk had two partition tables: one mbr, the second gpt and these were not in sync. It looks like partclone takes only one of these to determine which partitions it should save. Leading to some obscure disk backup that might or might not work trying to restore and mount only one partition out of a bunch. It seems that at begin and end are missing some blocks, saved to images for other partitions and therefore only restored if all partitions are restored.

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