You are not logged in.

#1 2015-07-22 14:15:20

tawayee
Member
Registered: 2015-07-22
Posts: 13

[SOLVED] accidentally deleted two partitions

Hi,

I was trying to delete three partitions on a USB drive however I forgot to select the right device so I ended up deleting partitions on my hard-drive!
I used following command to delete partitions:
-----------------------
(parted) rm 2
(parted) rm 3
(parted) rm 4
-----------------------

then I used "rescue" command to restore the lost partitions and now my hard-disk partition looks like this:

---------------------------
(parted) print
Model: ATA WDC WD5000AAKX-0 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number    Start               End                      Size                  File system        Name               Flags
1              1049kB           1050MB               1049MB             ntfs                                           hidden, msftdata
2              1087MB          1360MB               273MB               fat32                                         msftdata
3              1456MB          487GB                 486GB               ntfs                                           msftdata
5              487GB            488GB                 472MB               ntfs                                           hidden, diag
6              488GB            500GB                 12.4GB              ntfs                                           hidden, diag

----------------------

It was Window 8 installed in the hard-disk.

However when tried to boot from the hard-disk, the BIOS seems not be able to find the hard-disk.

I can mount /dev/sda1 (Windows Recovery)  and /dev/sda3 (Windows system and data)  and looks like all the data is safe.

I'm wondering why I can't boot from the harddisk and how to fix it?

I'm new to Arch Linux and this is my first question in this forum. thanks in advance for any instruction.

Last edited by tawayee (2015-07-23 13:14:04)

Offline

#2 2015-07-22 14:19:46

tawayee
Member
Registered: 2015-07-22
Posts: 13

Re: [SOLVED] accidentally deleted two partitions

BTW, I tried following commands and they didn't work:

(parted) set 1 boot on
(parted) set 1 legacy_boot on
(parted) set 3 boot on
(parted) set 3 legacy_boot on
(parted) disk_set pmbr_boot on

Offline

#3 2015-07-22 14:23:18

shulamy
Member
From: israel
Registered: 2010-09-11
Posts: 455

Re: [SOLVED] accidentally deleted two partitions

Offline

#4 2015-07-22 14:36:57

tawayee
Member
Registered: 2015-07-22
Posts: 13

Re: [SOLVED] accidentally deleted two partitions

thanks for pointing to this tool. I'll try it when I get home tonight.
In the meanwhile, does anyone have any idea to fix it with the tool that Archlinux boot CD provides, such as 'parted' ?

Offline

#5 2015-07-22 16:00:34

alex.theoto
Member
From: Athens Greece
Registered: 2014-11-30
Posts: 307

Re: [SOLVED] accidentally deleted two partitions

pacman -S testdisk
testdisk /dev/sdX
photorec /dev/sdX

tetsdisk may not help you if you deleted the partitions but try [Quick Search] option if it will find the deleted files.
Also, take a look here

Last edited by alex.theoto (2015-07-22 16:12:32)

Offline

#6 2015-07-22 16:32:33

Chazza
Wiki Maintainer
Registered: 2013-06-02
Posts: 506

Re: [SOLVED] accidentally deleted two partitions

Please correct me if I'm wrong, but isn't this essentially a Windows issue? You've messed up the drive and now you can't boot Windows?

If you have access to a Windows recovery console, the commands described here might be of some help.

Offline

#7 2015-07-22 16:51:55

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: [SOLVED] accidentally deleted two partitions

May I make a strong suggestion?  You say the data are appear to be safe.  I gather you do not have backups.

If my assertion is correct, stop.  Back up the data before you do anything else.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#8 2015-07-22 17:16:07

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: [SOLVED] accidentally deleted two partitions

Is this a UEFI system?  Which bootloader were you using?
I assume it has been UEFI because of Windows 8.  But you refer to BIOS and to legacy boot.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#9 2015-07-22 18:10:53

tawayee
Member
Registered: 2015-07-22
Posts: 13

Re: [SOLVED] accidentally deleted two partitions

ewaller wrote:

Is this a UEFI system?  Which bootloader were you using?
I assume it has been UEFI because of Windows 8.  But you refer to BIOS and to legacy boot.

Yes. It's UEFI. I'm just too used to saying BIOS...

Offline

#10 2015-07-22 18:14:21

tawayee
Member
Registered: 2015-07-22
Posts: 13

Re: [SOLVED] accidentally deleted two partitions

Chazza wrote:

Please correct me if I'm wrong, but isn't this essentially a Windows issue? You've messed up the drive and now you can't boot Windows?

If you have access to a Windows recovery console, the commands described here might be of some help.

You are right, it's not a Linux issue and I should have simply resolve the issue by using a Windows CD except I don't have it. But since I made this mistake during installation of Arch and I'm hoping to resolve the problem with a Linux tool, maybe I'm a bit justified ?

Offline

#11 2015-07-22 18:16:26

tawayee
Member
Registered: 2015-07-22
Posts: 13

Re: [SOLVED] accidentally deleted two partitions

ewaller wrote:

May I make a strong suggestion?  You say the data are appear to be safe.  I gather you do not have backups.

If my assertion is correct, stop.  Back up the data before you do anything else.


thanks for the kind warning.

Offline

#12 2015-07-22 18:18:37

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: [SOLVED] accidentally deleted two partitions

Partition 2 is where the EFI stuff should be.  Can you mount that partition, and are the EFI files intact?  Is your kernel there?
Are you using a bootloader (Grub? Gummiboot?) or are you using EFI stub to boot linux?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#13 2015-07-22 18:30:36

tawayee
Member
Registered: 2015-07-22
Posts: 13

Re: [SOLVED] accidentally deleted two partitions

ewaller wrote:

Partition 2 is where the EFI stuff should be.  Can you mount that partition, and are the EFI files intact?  Is your kernel there?
Are you using a bootloader (Grub? Gummiboot?) or are you using EFI stub to boot linux?

I couldn't mount sda2. The error message is "can't read superblock". I got this partition back by using parted rescue command. I got sda3 back using the same command and I can mount sda3 and see the files.
I'm not having dual system in the hard disk so whatever the bootloader in the hard-disk I don't know. I expect the same loader is still in the disk and can boot the windows for me.
I boot archlinux from a ISO CD.

Offline

#14 2015-07-22 19:17:36

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: [SOLVED] accidentally deleted two partitions

tawayee wrote:

BTW, I tried following commands and they didn't work:

(parted) set 1 boot on
(parted) set 1 legacy_boot on
(parted) set 3 boot on
(parted) set 3 legacy_boot on
(parted) disk_set pmbr_boot on

Un-do these settings.

You need the EFI system partition (sda2) to be flagged as such.

Load up gdisk

# gdisk /dev/sda

Use "t" to change partition "2" to type "EF00" and use "p" to check -- /dev/sda2 should be listed under the "Name" column as "EFI System" -- then use "w" to write the changes to the disk.

You also have to set the boot flag:

# parted /dev/sda set 2 boot on

Once this is done, look at the contents of /dev/sda2 and check if there is a bootmgfw.efi file present (I think it's in Microsoft/EFI but I'm not sure):

# mount /dev/sda2 /mnt
# find /mnt -name bootmgfw.efi

Offline

#15 2015-07-23 01:00:36

tawayee
Member
Registered: 2015-07-22
Posts: 13

Re: [SOLVED] accidentally deleted two partitions

I got my disk back!

Head_on_a_Stick 's tip is most helpful, I would have never thought about changing the partition type.

But that tip doesn't solve the problem that /dev/sda2 can't be mounted. I blindly tried to delete the partition 2 again and got it back using "parted rescue", and this time it returns with a different ending size. After this I can mount /dev/sda2 and see the EFI directory! I really don't know why this would work but i'm happy that it works...

and Head_on_a_Stick you are right, the bootmgfw.efi is under EFI/Microsfot/Boot directory.

After these the Windows is found at the boot up and it triggers some auto-repair process and now I got my full system back and everything is intact.

thanks to every one again for your tips!

Offline

#16 2015-07-23 09:38:36

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: [SOLVED] accidentally deleted two partitions

Yay!
smile

Please add "[SOLVED]" to the thread title for the benefit of others.

Offline

Board footer

Powered by FluxBB