I accidentally deleted most of my windows partition table on my dual boot laptop and am trying to fix/recover the faulty partition table.
I have a dual boot laptop: Ubuntu and Windows. Grub still works (I can boot into Ubuntu).
/dev/sdb
/dev/sda
.I accidentally deleted most of my windows partition table on dev/sda
(stupid mistakes happen). Here is what is left according to fdisk
:
$ sudo fdisk -lu /dev/sda
Disk /dev/sda: 465,8 GiB, 500107862016 bytes, 976773168 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: gpt
Disk identifier: 6CAE9467-2FF5-4DB9-8E72-4321E9061C2A
Device Start End Sectors Size Type
/dev/sda2 923648 1128447 204800 100M EFI System
I can still select Windows from grub, but of course now I just get (German for: Recover, the system must be repared):
From my /boot/grub/grub.cfg
on /dev/sdb
:
menuentry 'Windows Boot Manager (on /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-efi-46A6-7D64' {
insmod part_gpt
insmod fat
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 46A6-7D64
else
search --no-floppy --fs-uuid --set=root 46A6-7D64
fi
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
testdisk
results for dev/sda
:
TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
Partition Start End Size in sectors
>P MS Data 2048 923647 921600
P MS Data 923648 1128447 204800 [NO NAME]
D MS Data 1161216 975772594 974611379
D MS Data 974774273 975773696 999424
D MS Data 975773696 976773119 999424
Structure: Ok. Use Up/Down Arrow keys to select partition.
Use Left/Right Arrow keys to CHANGE partition characteristics:
P=Primary D=Deleted
Keys A: add partition, L: load backup, T: change type, P: list files,
Enter: to continue
NTFS, blocksize=4096, 471 MB / 450 MiB
After looking inside each partition using P: list files
(details below) it seems that:
My questions:
L: load backup
)?D
(deleted)? It seems to be corrupted anyway.D
(deleted)? It contains recovery, but there is already a valid recovery located at partition 1.grub
entry to /dev/sda2
points to the correct location?Results from testdisk
after entering each partition with P
:
Partition 1
P MS Data 2048 923647 921600
Directory /
>dr-xr-xr-x 0 0 0 4-Jun-2016 23:48 .
dr-xr-xr-x 0 0 0 4-Jun-2016 23:48 ..
dr-xr-xr-x 0 0 0 4-Jun-2016 23:44 Recovery
dr-xr-xr-x 0 0 0 1-Jun-2016 14:12 System Volume Information
Partition 2
P MS Data 923648 1128447 204800 [NO NAME]
Directory /
>drwxr-xr-x 0 0 0 2-Jun-2016 07:34 EFI
Partition 3
MS Data 1161216 975772594 974611379
Directory /
>dr-xr-xr-x 0 0 0 10-Feb-2017 01:05 .
dr-xr-xr-x 0 0 0 10-Feb-2017 01:05 ..
dr-xr-xr-x 0 0 0 22-Aug-2016 22:54 $GetCurrent
dr-xr-xr-x 0 0 0 2-Jun-2016 10:40 $Recycle.Bin
dr-xr-xr-x 0 0 0 8-Nov-2016 18:54 Intel
dr-xr-xr-x 0 0 0 27-Apr-2016 07:52 Logs
dr-xr-xr-x 0 0 0 16-Jul-2016 13:47 PerfLogs
dr-xr-xr-x 0 0 0 2-Feb-2017 23:13 Program Files
dr-xr-xr-x 0 0 0 2-Feb-2017 23:11 Program Files (x86)
dr-xr-xr-x 0 0 0 22-Aug-2016 22:59 ProgramData
dr-xr-xr-x 0 0 0 27-Dec-2016 15:55 Python36
dr-xr-xr-x 0 0 0 22-Aug-2016 22:38 Recovery
dr-xr-xr-x 0 0 0 20-Jun-2016 22:03 SQL Server 2000 Sample Databases
dr-xr-xr-x 0 0 0 21-Jun-2016 20:06 SQLServer2016Media
dr-xr-xr-x 0 0 0 10-Feb-2017 00:28 System Volume Information
dr-xr-xr-x 0 0 0 22-Aug-2016 22:44 Users
dr-xr-xr-x 0 0 0 10-Feb-2017 01:06 Windows
dr-xr-xr-x 0 0 0 22-Aug-2016 22:54 Windows10Upgrade
dr-xr-xr-x 0 0 0 5-Oct-2016 19:25 _tmp
dr-xr-xr-x 0 0 0 4-Jun-2016 22:23 cloud
dr-xr-xr-x 0 0 0 2-Feb-2017 18:45 projects
dr-xr-xr-x 0 0 0 24-Jul-2016 14:35 tools
-r--r--r-- 0 0 1 30-Oct-2015 08:18 BOOTNXT
-r--r--r-- 0 0 0 27-Dec-2016 15:55 Python36:Win32App_1
-r--r--r-- 0 0 0 20-Jun-2016 22:03 SQL Server 2000 Sample Databases:Win32App_1
-r--r--r-- 0 0 395268 10-Jul-2015 13:00 bootmgr
-r--r--r-- 0 0 2550136832 10-Feb-2017 01:07 pagefile.sys
-r--r--r-- 0 0 16777216 10-Feb-2017 01:07 swapfile.sys
Partition 4
MS Data 974774273 975773696 999424
Can't open filesystem. Filesystem seems damaged.
Partition 5
MS Data 975773696 976773119 999424
Directory /
>dr-xr-xr-x 0 0 0 18-Nov-2016 21:26 .
dr-xr-xr-x 0 0 0 18-Nov-2016 21:26 ..
dr-xr-xr-x 0 0 0 22-Aug-2016 23:36 Recovery
dr-xr-xr-x 0 0 0 4-Jun-2016 22:49 System Volume Information
testdisk.log
:
Thu Feb 16 20:46:55 2017
Command line: TestDisk
TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
OS: Linux, kernel 4.8.0-37-generic (#39-Ubuntu SMP Thu Jan 26 02:27:07 UTC 2017) x86_64
Compiler: GCC 5.3
ext2fs lib: 1.43.3, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.0
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size 976773168 sectors
/dev/sda: user_max 976773168 sectors
/dev/sda: native_max 976773168 sectors
/dev/sda: dco 976773168 sectors
/dev/sdb: LBA, HPA, LBA48, DCO support
/dev/sdb: size 976773168 sectors
/dev/sdb: user_max 976773168 sectors
/dev/sdb: native_max 976773168 sectors
/dev/sdb: dco 976773168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63, sector size=512 - Samsung SSD 850 EVO 500GB, S/N:S1YCNXAGB00962X, FW:EMT02B6Q
Disk /dev/sdb - 500 GB / 465 GiB - CHS 60801 255 63, sector size=512 - Samsung SSD 850 EVO M.2 500GB, S/N:S24CNXAH208296N, FW:EMT21B6Q
Partition table type (auto): EFI GPT
Disk /dev/sda - 500 GB / 465 GiB - Samsung SSD 850 EVO 500GB
Partition table type: EFI GPT
Analyse Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
hdr_size=92
hdr_lba_self=1
hdr_lba_alt=976773167 (expected 976773167)
hdr_lba_start=34
hdr_lba_end=976773134
hdr_lba_table=2
hdr_entries=128
hdr_entsz=128
Current partition structure:
2 P EFI System 923648 1128447 204800 [EFI system partition]
search_part()
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
NTFS at 0/32/33
filesystem size 921600
sectors_per_cluster 8
mft_lcn 38400
mftmirr_lcn 2
clusters_per_mft_record -10
clusters_per_index_record 1
NTFS part_offset=1048576, part_size=471859200, sector_size=512
NTFS partition cannot be added (part_offset<part_size).
NTFS at 0/32/33
filesystem size 921600
sectors_per_cluster 8
mft_lcn 38400
mftmirr_lcn 2
clusters_per_mft_record -10
clusters_per_index_record 1
MS Data 2048 923647 921600
NTFS, blocksize=4096, 471 MB / 450 MiB
FAT32 at 57/126/6
FAT1 : 6654-7422
FAT2 : 7423-8191
start_rootdir : 8192 root cluster : 2
Data : 8192-204799
sectors : 204800
cluster_size : 2
no_of_cluster : 98304 (2 - 98305)
fat_length 769 calculated 769
set_FAT_info: name from BS used
FAT32 at 57/126/6
MS Data 923648 1128447 204800 [NO NAME]
FAT32, blocksize=1024, 104 MB / 100 MiB
NTFS at 72/72/1
filesystem size 974611379
sectors_per_cluster 8
mft_lcn 786432
mftmirr_lcn 2
clusters_per_mft_record -10
clusters_per_index_record 1
NTFS part_offset=594542592, part_size=499001026048, sector_size=512
NTFS partition cannot be added (part_offset<part_size).
NTFS at 72/72/1
filesystem size 974611379
sectors_per_cluster 8
mft_lcn 786432
mftmirr_lcn 2
clusters_per_mft_record -10
clusters_per_index_record 1
MS Data 1161216 975772594 974611379
NTFS, blocksize=4096, 499 GB / 464 GiB
NTFS at 60739/26/24
filesystem size 999424
sectors_per_cluster 8
mft_lcn 41642
mftmirr_lcn 2
clusters_per_mft_record -10
clusters_per_index_record 1
MS Data 974774273 975773696 999424
NTFS found using backup sector, blocksize=4096, 511 MB / 488 MiB
NTFS at 60739/26/24
filesystem size 999424
sectors_per_cluster 8
mft_lcn 41642
mftmirr_lcn 2
clusters_per_mft_record -10
clusters_per_index_record 1
MS Data 975773696 976773119 999424
NTFS, blocksize=4096, 511 MB / 488 MiB
Results
P MS Data 2048 923647 921600
NTFS, blocksize=4096, 471 MB / 450 MiB
P MS Data 923648 1128447 204800 [NO NAME]
FAT32, blocksize=1024, 104 MB / 100 MiB
MS Data 1161216 975772594 974611379
NTFS, blocksize=4096, 499 GB / 464 GiB
MS Data 974774273 975773696 999424
NTFS found using backup sector, blocksize=4096, 511 MB / 488 MiB
MS Data 975773696 976773119 999424
NTFS, blocksize=4096, 511 MB / 488 MiB
Hint for advanced users. dmsetup may be used if you prefer to avoid to rewrite the partition table for the moment:
echo "0 921600 linear /dev/sda 2048" | dmsetup create test0
echo "0 204800 linear /dev/sda 923648" | dmsetup create test1
echo "0 974611379 linear /dev/sda 1161216" | dmsetup create test2
echo "0 999424 linear /dev/sda 974774273" | dmsetup create test3
echo "0 999424 linear /dev/sda 975773696" | dmsetup create test4
ntfs_device_testdisk_io_ioctl() unimplemented
dir_partition inode=5
P MS Data 2048 923647 921600
NTFS, blocksize=4096, 471 MB / 450 MiB
Directory /
5 dr-xr-xr-x 0 0 0 4-Jun-2016 23:48 .
5 dr-xr-xr-x 0 0 0 4-Jun-2016 23:48 ..
37 dr-xr-xr-x 0 0 0 4-Jun-2016 23:44 Recovery
35 dr-xr-xr-x 0 0 0 1-Jun-2016 14:12 System Volume Information
dir_partition inode=0
P MS Data 923648 1128447 204800 [NO NAME]
FAT32, blocksize=1024, 104 MB / 100 MiB
FAT: cluster=2(0x2), pos=931840
Directory /
3 drwxr-xr-x 0 0 0 2-Jun-2016 07:34 EFI
ntfs_device_testdisk_io_ioctl() unimplemented
dir_partition inodentfs_mst_post_read_fixup_warn: magic: 0x00000000 size: 1024 usa_ofs: 0 usa_count: 65535: Invalid argument
Record 0 has no FILE magic (0x0)
Failed to load $MFT: Input/output error
ntfs_mst_post_read_fixup_warn: magic: 0x00000000 size: 1024 usa_ofs: 0 usa_count: 65535: Invalid argument
Record 0 has no FILE magic (0x0)
Failed to load $MFT: Input/output error
=5
MS Data 1161216 975772594 974611379
NTFS, blocksize=4096, 499 GB / 464 GiB
Directory /
5 dr-xr-xr-x 0 0 0 10-Feb-2017 01:05 .
5 dr-xr-xr-x 0 0 0 10-Feb-2017 01:05 ..
132 dr-xr-xr-x 0 0 0 22-Aug-2016 22:54 $GetCurrent
63 dr-xr-xr-x 0 0 0 2-Jun-2016 10:40 $Recycle.Bin
86499 dr-xr-xr-x 0 0 0 8-Nov-2016 18:54 Intel
135457 dr-xr-xr-x 0 0 0 27-Apr-2016 07:52 Logs
184781 dr-xr-xr-x 0 0 0 16-Jul-2016 13:47 PerfLogs
184785 dr-xr-xr-x 0 0 0 2-Feb-2017 23:13 Program Files
192329 dr-xr-xr-x 0 0 0 2-Feb-2017 23:11 Program Files (x86)
192466 dr-xr-xr-x 0 0 0 22-Aug-2016 22:59 ProgramData
279327 dr-xr-xr-x 0 0 0 27-Dec-2016 15:55 Python36
174888 dr-xr-xr-x 0 0 0 22-Aug-2016 22:38 Recovery
546406 dr-xr-xr-x 0 0 0 20-Jun-2016 22:03 SQL Server 2000 Sample Databases
210433 dr-xr-xr-x 0 0 0 21-Jun-2016 20:06 SQLServer2016Media
82311 dr-xr-xr-x 0 0 0 10-Feb-2017 00:28 System Volume Information
192686 dr-xr-xr-x 0 0 0 22-Aug-2016 22:44 Users
193184 dr-xr-xr-x 0 0 0 10-Feb-2017 01:06 Windows
17780 dr-xr-xr-x 0 0 0 22-Aug-2016 22:54 Windows10Upgrade
136591 dr-xr-xr-x 0 0 0 5-Oct-2016 19:25 _tmp
463 dr-xr-xr-x 0 0 0 4-Jun-2016 22:23 cloud
170100 dr-xr-xr-x 0 0 0 2-Feb-2017 18:45 projects
300 dr-xr-xr-x 0 0 0 24-Jul-2016 14:35 tools
389125 -r--r--r-- 0 0 1 30-Oct-2015 08:18 BOOTNXT
279327 -r--r--r-- 0 0 0 27-Dec-2016 15:55 Python36:Win32App_1
546406 -r--r--r-- 0 0 0 20-Jun-2016 22:03 SQL Server 2000 Sample Databases:Win32App_1
19844 -r--r--r-- 0 0 395268 10-Jul-2015 13:00 bootmgr
34 -r--r--r-- 0 0 2550136832 10-Feb-2017 01:07 pagefile.sys
82325 -r--r--r-- 0 0 16777216 10-Feb-2017 01:07 swapfile.sys
ntfs_device_testdisk_io_ioctl() unimplemented
ntfs_device_testdisk_io_ioctl() unimplemented
MS Data 974774273 975773696 999424
NTFS found using backup sector, blocksize=4096, 511 MB / 488 MiB
Can't open filesystem. Filesystem seems damaged.
ntfs_device_testdisk_io_ioctl() unimplemented
dir_partition inode=5
MS Data 975773696 976773119 999424
NTFS, blocksize=4096, 511 MB / 488 MiB
Directory /
5 dr-xr-xr-x 0 0 0 18-Nov-2016 21:26 .
5 dr-xr-xr-x 0 0 0 18-Nov-2016 21:26 ..
35 dr-xr-xr-x 0 0 0 22-Aug-2016 23:36 Recovery
40 dr-xr-xr-x 0 0 0 4-Jun-2016 22:49 System Volume Information
interface_write()
1 P MS Data 2048 923647 921600
2 P MS Data 923648 1128447 204800 [NO NAME]
simulate write!
TestDisk exited normally.
User contributions licensed under CC BY-SA 3.0