LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Partition recovery help (https://www.linuxquestions.org/questions/linux-newbie-8/partition-recovery-help-4175636172/)

luke2 08-11-2018 11:37 AM

Partition recovery help
 
I have dual os win10 64bit and ubuntu 18.04 64bit laptop. But ubuntu installed partition is corrupted and hidden from the file manager. It won't appear on gurb menu. So I created a disk image using ubuntu live disk utility and copy to another partition.

Disk Image of sda6 (2018-08-11).img

Please tell me how can I extract this .img file to another ntfs partition. It's called sda3.

Thank you :)

fatmac 08-11-2018 12:29 PM

If memory serves me right....

Code:

sudo mount -o loop 2018-08-11.img /mnt
Then all your files should be available under /mnt.

luke2 08-11-2018 12:38 PM

Quote:

Originally Posted by fatmac (Post 5890602)
If memory serves me right....

Code:

sudo mount -o loop 2018-08-11.img /mnt
Then all your files should be available under /mnt.

I got this error.

Code:

mount: /mnt: wrong fs type, bad option, bad super block on /dev/loop1, missing codepage or helper program, or other error.

michaelk 08-11-2018 01:26 PM

When you installed Ubuntu did you select LVM or encryption?

Did you image the correct partition? Post the output of the command
lsblk

What is the output of the command.

sudo file -s 2018-08-11.img (Does the name actual contain parentheses?)

luke2 08-11-2018 02:20 PM

Quote:

Originally Posted by michaelk (Post 5890619)
When you installed Ubuntu did you select LVM or encryption?

Did you image the correct partition? Post the output of the command
lsblk

What is the output of the command.

sudo file -s 2018-08-11.img (Does the name actual contain parentheses?)

I guess I didn't. I'm noob anyway :(

Code:

ubuntu@ubuntu:~$ lsblk
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  1.3G  1 loop /rofs
sda      8:0    0 931.5G  0 disk
├─sda1  8:1    0  100G  0 part
├─sda2  8:2    0 231.5G  0 part
├─sda3  8:3    0  300G  0 part
├─sda4  8:4    0    1K  0 part
├─sda5  8:5    0  184G  0 part
├─sda6  8:6    0  100G  0 part
└─sda7  8:7    0    16G  0 part [SWAP]
sdb      8:16  1  14.9G  0 disk
└─sdb1  8:17  1  14.9G  0 part /cdrom
sr0    11:0    1  1024M  0 rom 
ubuntu@ubuntu:~$

I've renamed the image file.
Code:

ubuntu@ubuntu:/media/ubuntu/New Volume1$ sudo file -s bkup6.img
bkup6.img: data
ubuntu@ubuntu:/media/ubuntu/New Volume1$ sudo mount -o loop bkup6.img /mnt
mount: /mnt: wrong fs type, bad option, bad superblock on /dev/loop1, missing codepage or helper program, or other error.
ubuntu@ubuntu:/media/ubuntu/New Volume1$

Code:

ubuntu@ubuntu:~$ sudo fdisk -l
Disk /dev/loop0: 1.3 GiB, 1427259392 bytes, 2787616 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xff6f34e2

Device    Boot      Start        End  Sectors  Size Id Type
/dev/sda1            2048  209719295 209717248  100G  7 HPFS/NTFS/exFAT
/dev/sda2        209719296  695228415 485509120 231.5G  7 HPFS/NTFS/exFAT
/dev/sda3        695228416 1324374015 629145600  300G  7 HPFS/NTFS/exFAT
/dev/sda4      1324374016 1953523711 629149696  300G  f W95 Ext'd (LBA)
/dev/sda5      1324376064 1710252031 385875968  184G  7 HPFS/NTFS/exFAT
/dev/sda6  *    1710254080 1919961087 209707008  100G 83 Linux
/dev/sda7      1919969280 1953521663  33552384    16G 82 Linux swap / Solaris




Disk /dev/sdb: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x001576e4

Device    Boot Start      End  Sectors  Size Id Type
/dev/sdb1  *    2048 31116287 31114240 14.9G  c W95 FAT32 (LBA)
ubuntu@ubuntu:~$


michaelk 08-11-2018 02:39 PM

The image file is not recognized as a filesystem which is not good. While I expect the command to fail you need to specify the filesystem type.
It isn't necessary to explicitly use the loop option.

sudo mount -t ext4 bkup6.img /mnt

In addition you can try to see if fsck finds any problems. The command will only find errors.

fsck -t ext4 -n bkup6.img

Others might have more ideas but data recovery might be your only option.

luke2 08-11-2018 02:53 PM

Quote:

Originally Posted by michaelk (Post 5890638)
The image file is not recognized as a filesystem which is not good. While I expect the command to fail you need to specify the filesystem type.
It isn't necessary to explicitly use the loop option.

sudo mount -t ext4 bkup6.img /mnt

In addition you can try to see if fsck finds any problems. The command will only find errors.

fsck -t ext4 -n bkup6.img

Others might have more ideas but data recovery might be your only option.

Got the same error when I try to mount.

fsck -t ext4 -n bkup6.img
Code:

fsck from util-linux 2.30.1

michaelk 08-11-2018 03:26 PM

I assume that fsck isn't getting anywhere.

Without backups I think your only recourse is trying to recover files.

pan64 08-11-2018 03:30 PM

are you sure the disk image was created properly?

luke2 08-11-2018 10:55 PM

Quote:

Originally Posted by michaelk (Post 5890650)
I assume that fsck isn't getting anywhere.

Without backups I think your only recourse is trying to recover files.

How can I do that?

Quote:

Originally Posted by pan64 (Post 5890653)
are you sure the disk image was created properly?

There was an error and it asked me to delete the image.

Please help me to recover sda6 partition if created image is corrupted.

AwesomeMachine 08-12-2018 02:06 AM

If the partition is corrupt as you say, and there was an error imaging it, it's hardly likely to be mountable. You can try to make the image with 'dd':
Code:

$ dd if=/dev/sda3 of=image.img bs=4k conv=noerror,sync
If it outputs I/O error, the drive is probably failing.

You can run
Code:

$ smartctl -a
to check out the condition of the drive hardware. Post the output in quote tags. Ddrescue or foremost could help with recovery.

luke2 08-12-2018 02:34 AM

Quote:

Originally Posted by AwesomeMachine (Post 5890764)
If the partition is corrupt as you say, and there was an error imaging it, it's hardly likely to be mountable. You can try to make the image with 'dd':
Code:

$ dd if=/dev/sda3 of=image.img bs=4k conv=noerror,sync
If it outputs I/O error, the drive is probably failing.

You can run
Code:

$ smartctl -a
to check out the condition of the drive hardware. Post the output in quote tags. Ddrescue or foremost could help with recovery.

bkup6.img 3.8gb file copied to the /home folder
Quote:

ubuntu@ubuntu:~$ sudo dd if=/dev/sda3 of=bkup6.img bs=4k conv=noerror,sync
dd: error writing 'bkup6.img': No space left on device
918837+0 records in
918836+0 records out
3763552256 bytes (3.8 GB, 3.5 GiB) copied, 36.4879 s, 103 MB/s
ubuntu@ubuntu:~$
Quote:

root@ubuntu:~# smartctl -a
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.13.0-21-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

ERROR: smartctl requires a device name as the final command-line argument.


Use smartctl -h to get a usage summary

root@ubuntu:~#

pan64 08-12-2018 07:51 AM

no space left on device: you have no enough space to create that image. You need to select another partition.

luke2 08-12-2018 07:57 AM

Quote:

Originally Posted by pan64 (Post 5890842)
no space left on device: you have no enough space to create that image. You need to select another partition.

I'm on live usb. It's only 16gb.

pan64 08-12-2018 07:59 AM

so you need to find another solution. In your original post you wrote you created a disk image and copied to somewhere else. How could you do that at all?


All times are GMT -5. The time now is 06:25 AM.