You are not logged in.

#1 2021-03-15 19:39:10

Socerest
Member
From: New Jersey
Registered: 2020-11-07
Posts: 3
Website

Mounting Issue

Hello, I have accidentally formatted my hard drive. I was able to recover a img file by using ddrescue. But while trying to mount it, I have been getting issues.

When I try to run
`mount -o loop test.img /mnt/recovery`

I get the output
`mount: /mnt/recovery: failed to setup loop device for test.img`

Few things:
Yes /mnt/recovery is a directory.
I have loop installed and have done modprobe loop

Thanks for the help in advance

Offline

#2 2021-03-15 21:01:21

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,552

Re: Mounting Issue

Is "test.img" the image of a filesystem (partition) or a (partitioned) drive?
For the latter, "man losetup" - you want to use the -P flag to create loop devices for the partitions and mount those.

Offline

#3 2021-03-16 11:32:46

ponyrider
Member
Registered: 2014-11-18
Posts: 112

Re: Mounting Issue

Just because you have recovered an img file, doesn't mean you have a working partition

If you have reformatted the drive, and not merely deleted the partition, i am afraid you may have to accept that your data is gone for good

Offline

#4 2021-03-16 12:12:10

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,552

Re: Mounting Issue

Luckily "reformat" is not a fixed term.

If he only repartitioned the drive he actually only needs to restore the former partition table - data and even filesystem headers will all be still there.

If he created a new filesystem it gets a bit more complicated.
If he replaced the old FS on the same partition, the FS is gone, but unless the new FS was used, testdisk/photorec will be able to recover most data.
If he repartitioned and created new FS's, the old FS headers will still be there aligned w/ the former partition, but the new FS entries may have damaged some of the existing data.

Ideally the image is a drive dump before he screwed up his drive (aka "backup").

"formatting" à la DOS "full format" ie. overriding every sector doesn't happen easily, but in that case and if the image is just a copy of the old drive, he's pretty much screwed.
Professional services *MIGHT* be able to recover *SOME* data from a HDD (if only 0-bytes were written and not dev/urandom) - but this is very expensive and the results are typically not great.

Offline

#5 2021-03-16 12:53:36

ponyrider
Member
Registered: 2014-11-18
Posts: 112

Re: Mounting Issue

OP please keep in mind that ddrescue/photorec is not a silver bullet, it may say its found some files, but in my experience much of it is corrupted or unusable

depending on what the img file actually is you may need
losetup

  -o, --offset offset
              The data start is moved offset bytes into the specified file or device.  The  offset  may  be
              followed by the multiplicative suffixes; see above.

       --sizelimit size
              The  data  end  is set to no more than size bytes after the data start.  The size may be fol‐
              lowed by the multiplicative suffixes; see above.

       -b, --sector-size size
              Set the logical sector size of the loop device in bytes (since Linux 4.14). The option may be
              used  when  create  a new loop device as well as stand-alone command to modify sector size of
              the already existing loop device.

Last edited by ponyrider (2021-03-16 12:54:10)

Offline

#6 2021-03-16 12:59:50

ponyrider
Member
Registered: 2014-11-18
Posts: 112

Re: Mounting Issue

I just want to add that everything Seth says is correct.

OP can you post more information about what command you used to 'delete' your drive

Offline

Board footer

Powered by FluxBB