LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-26-2013, 10:38 AM   #1
zedmelon
Member
 
Registered: Jun 2004
Location: colorado, USA
Distribution: slack, oBSD
Posts: 119

Rep: Reputation: 24
rebuild partitions/label from existing partitions - used parted on wrong drive


After seeing a GPT warning on a 500G drive I wanted to assimilate, I used parted on the wrong drive--my OS drive. Is there a way to reconstruct what I've broken?

The drive I wanted to use
Code:
fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
My confusion began while I inspected the drive for any remaining Winfiles I wanted to keep. I ran parted while the drive was still mounted; it complained, I unmounted the drive, and then I used parted and mklabel msdos.

Unfortunately, I ran it on /dev/sda and not /dev/sdb. When it complained again about being in use, I figured it was a residual tag or something. Not noticing I'd typed the wrong drive letter, I verified in another console that the drive was indeed unmounted. It was, I proceeed, and now I am fearful to reboot.

The drive before I killed it
Code:
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 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 identifier: 0xe643427f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63    35150219    17575078+   7  HPFS/NTFS/exFAT
/dev/sda2        35150220    93739274    29294527+   7  HPFS/NTFS/exFAT
/dev/sda3        93739275    95699204      979965   83  Linux
/dev/sda4        95699205   312581807   108441301+   5  Extended
/dev/sda5        95699268   113274314     8787523+  83  Linux
/dev/sda6       113274378   125965664     6345643+  83  Linux
/dev/sda7       125965728   127925594      979933+  83  Linux
/dev/sda8       127925658   129885524      979933+  83  Linux
/dev/sda9       129885588   132809354     1461883+  83  Linux
/dev/sda10      132809418   142576874     4883728+  83  Linux
/dev/sda11      142576938   304769114    81096088+  83  Linux
/dev/sda12      304769178   312581807     3906315   82  Linux swap
After I broke it, no partitions are listed:
Code:
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 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 identifier: 0x00077593

   Device Boot      Start         End      Blocks   Id  System
Afterward, I saw a warning that listed all these partitions which were removed, but the kernel wasn't notified. WHAT?!? Oh, crap. At least I still have a scrollback record of what they should be. I've already archived everything from the "disqualified" partitions in case I've royally hosed myself.

Ugh. I've begun a lovely pattern; my last LQ post began with a typo as well, and it bore a strikingly similar theme.
:-(

Is there a way to reinstate from the still-running partitions?
/n00b
 
Old 07-26-2013, 10:53 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4865Reputation: 4865Reputation: 4865Reputation: 4865Reputation: 4865Reputation: 4865Reputation: 4865Reputation: 4865Reputation: 4865Reputation: 4865Reputation: 4865
You can just use fdisk to recreate the partitions with the exact same blocks (gladly you have the start- and end-sectors), or you could install Testdisk and let it scan for your partitions.
 
Old 07-26-2013, 04:03 PM   #3
zedmelon
Member
 
Registered: Jun 2004
Location: colorado, USA
Distribution: slack, oBSD
Posts: 119

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by TobiSGD View Post
You can just use fdisk to recreate the partitions with the exact same blocks
I thought of this but--unlike my brazen efforts to format a relatively unimportant drive--I first wanted an active second opinion instead of passive Google results, just to ensure against further breakage.

Quote:
Originally Posted by TobiSGD View Post
(gladly you have the start- and end-sectors)
Yeah, as soon as I saw
Code:
/dev/sda1 won't be reported to kernel
/dev/sda2 won't be reported to kernel
...
(or similar), I immediately copied relevant scrollback to ensure I had as much forensics material as possible.

Quote:
Originally Posted by TobiSGD View Post
install Testdisk and let it scan for your partitions.
Haven't heard of Testdisk; I'll check it out. Thanks Tobi.
 
Old 07-26-2013, 04:08 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,455

Rep: Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601
Quote:
/dev/sda1 won't be reported to kernel
/dev/sda2 won't be reported to kernel
...
so your automounting partitions
disable automount !
or
use a live dvd/cd like gparted livd cd
or
System Rescue CD
 
Old 07-26-2013, 04:42 PM   #5
zedmelon
Member
 
Registered: Jun 2004
Location: colorado, USA
Distribution: slack, oBSD
Posts: 119

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by John VV View Post
so your automounting partitions
well, sorta. These partitions automount, but they're my OS drive, so they should.

I ran the parted utility on the wrong drive with a typo and therefore processed partitions which were still mounted in the first place--I'd already unmounted the drive I intended to impact. I'm not at home right now so am paraphrasing the message it actually gave**. It was something along the lines of
Code:
partition /dev/sda1 has been rewritten, but this has not yet been reported to the kernel, please reboot for changes to take effect
(repeat eleven more times)

** I also can't unequivocally mark this thread as solved, since only a reboot will verify the fix worked, and I'm not going to try that remotely. I may run with scissors, but I'm not going to do it in the dark!
:-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mdadm: Rebuild a software raid from drives with existing partitions Boeby Linux - Server 3 04-26-2011 02:32 PM
parted and formatting partitions WarNinja Linux - Server 7 09-21-2010 12:38 PM
listing partitions with parted Skaperen Linux - Software 6 03-23-2010 12:38 PM
gpt label in parted, partitions look OK. GrUB not booting 64bit OS on 8th primary digital8doug Linux - Newbie 1 12-31-2008 03:20 PM
/proc/partitions showing wrong partitions netstv Linux - General 1 07-10-2006 02:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration