You are not logged in.

#1 2012-05-16 07:53:36

raxbg
Member
Registered: 2011-04-05
Posts: 105

How to rebuild partition table

Hi, everyone
Two months ago I broke my partition table by trying to install windows 8. I had it repaired with "test-disk" , but the problem is that gparted now sees my disk as a whole 300Gb unpartitioned space, fdisk however recognizes the partition table. I was wondering what will happen if I press 'w' in fdisk big_smile will this format the partitions and erase everything, or will it just try to do something similar to what test-disk did? I want to do this because now I have a 50 gig partition left for windows and I want to add this to my / partition. Before the problems I used to do this kind of operations with gparted.
Thanks smile

Offline

#2 2012-05-16 16:37:50

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: How to rebuild partition table

"w" writes any changes you've made to disk, so yes, it will reformat the partition if that's what you've selected.  Were I in your shoes, I'd have made a backup before trying to install Win8, and restored that after problems emerged.  You did make a backup before installing highly unstable software onto your machine, right?

Offline

#3 2012-05-16 16:41:47

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,612

Re: How to rebuild partition table

If you have another drive laying around, I highly recommend making an image of your drive prior to doing anything.   If you use dd, the normal warnings apply -- one misstep, and you can easily "destroy data" .  Then go ahead and write the partition table.  If things go awry, you can restore from your image,


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#4 2012-05-16 16:53:45

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: How to rebuild partition table

In its normal operation*, fdisk only touches the partition table.  It does not "format" in the filesystem sense, nor does it have any other affect on the actual data.  It affects your ability to access the data, not the data itself.

That said, I think incorrect partition boundaries can lead to data corruption if the partition is mounted and written to.

*As opposed 'expert mode'.

Last edited by alphaniner (2012-05-16 16:56:21)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#5 2012-05-16 17:05:14

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

No, I didn't make backup of anything. I know it's pretty stupid big_smile but I've never been into backups. Can u tell me how to backup just the arch partitions? Do you mean to just copy everything from / ?(without run of course) This will take ages big_smile I cannot backup the whole drive, cause I don't have another big enough drive sad
Thanks

Offline

#6 2012-05-16 17:07:27

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,612

Re: How to rebuild partition table

alphaniner wrote:

In its normal operation*, fdisk only touches the partition table.  It does not "format" in the filesystem sense, nor does it have any other affect on the actual data.  It affects your ability to access the data, not the data itself.

That said, I think incorrect partition boundaries can lead to data corruption if the partition is mounted and written to.

Kind of like tearing up the map.  If you lose the map, you will never reliably find your data.

As someone once said, "On a clear disk, you can seek forever"


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#7 2012-05-16 17:09:07

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

I won't touch it when mounted. I plan to use arch minimal install CD smile The partition table which fdisk shows me when I use the p option looks good. And the filemanager also recognizes the different partitions, I can browse them etc. but gparted for some reason can't see the partition table. Is there any other tool like gparted and which is at least as reliable as gparted?

Last edited by raxbg (2012-05-16 17:16:04)

Offline

#8 2012-05-16 18:19:28

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: How to rebuild partition table

ewaller wrote:

Kind of like tearing up the map.

That's why you zerox of the map (dd ... bs=440 count=1 or at least fdisk -l /dev/... >somefile) before you rip it up.  The latter is all I needed to save my butt when I borked a PT.  As long as you use your head, there is no reason dicking with the partition table particularly warrants a full data backup.

That said, you can bet your @$$ I'd backup even "reaquirable" data in this situation, unless doing so was more trouble than reaquiring it would be.  "An ounce of prevention" and such.  Unique data, fugeddaboudit.  I have at least three copies of stuff I can't replace and don't want to lose.

Last edited by alphaniner (2012-05-16 18:20:32)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#9 2012-05-16 18:55:15

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: How to rebuild partition table

gparted is just a pretty front-end for the tools that actually do the work i.e. parted and the various filesystem utilities. Personally, I prefer using those directly on the cli.

Offline

#10 2012-05-16 19:16:45

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

tomk I'm aware of that, but since it's just a front end what will be the difference if I use the cli version?

Offline

#11 2012-05-16 19:21:08

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: How to rebuild partition table

Probably nothing... unless something is wrong with gparted.  Pretty front-end = more code = more bugs.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#12 2012-05-16 22:45:33

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: How to rebuild partition table

alphaniner wrote:

That's why you zerox of the map (dd ... bs=440 count=1 or at least fdisk -l /dev/... >somefile) before you rip it up.

That would be backing up only the boot code that resides in the MBR and not the partition table, which is not the idea I guess.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#13 2012-05-16 23:31:16

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: How to rebuild partition table

Doh! You're right.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#14 2012-05-17 13:09:38

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

I took a deep breathe and pressed the 'w' but nothing's changed sad I noticed something strange though, if I try to open the drive with cfdisk I am getting this error "Bad primary partition 4: Partition ends after end-of-disk". Huh I don't remember having 4 primary partitions only 2 or 3 and 1 extended. Wtf ?!? big_smile

Last edited by raxbg (2012-05-17 13:10:28)

Offline

#15 2012-05-17 13:50:17

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: How to rebuild partition table

The extended partition counts as a primary partition.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#16 2012-05-17 14:11:21

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

When I look at fdisk I see that the end of the extended partition is far after the end of the last partition. What will happen if I try to reduce it big_smile Is there a way to set the end to something closer to to the end of the last partition?

Device Boot      Start         End      Blocks   Id  System
/dev/sda4        99329895   625153409   262911757+   f  W95 Ext'd (LBA)
/dev/sda10      245966848   625139711   189586432    7  HPFS/NTFS/exFAT

Last edited by raxbg (2012-05-17 15:07:48)

Offline

#17 2012-05-17 15:32:04

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

What if I delete all partitions after the third and recreate them, with only changing the end sector of the extended partition, and then write down the new table?

Last edited by raxbg (2012-05-17 15:32:28)

Offline

#18 2012-05-17 17:43:26

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: How to rebuild partition table

You should backup the data you have on the offending partition, delete it with whatever program you choose, fdisk will be fine, then recreate the partition and check it ends within the disk boundaries, format and copy your data back.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#19 2012-05-17 21:00:25

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

Why do I have to format? I will preserve the start and end points of the other partitions.

Offline

#20 2012-05-18 17:13:43

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: How to rebuild partition table

If you delete 1 partition, then recreate it with different boundaries you probably want to create a new filesystem there aka format the partition.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#21 2012-05-18 18:16:46

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: How to rebuild partition table

If you're not going to put the logical partitions back exactly as they are, I think you should be safe.  But you should still backup your data if you aren't willing to risk losing it.  Also, don't take this the wrong way, but you could benefit from following the link in ewaller's sig...


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#22 2012-05-19 10:45:34

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

Haha well I am probably one of the worst "forumers", I never look at people's signatures sad. Shame on me. I am sorry for the bad English smile One more thing to ask. Since the goal is just to expand my / partition, do I have to go through so much pain? Isn't there another way to transfer the space allocated for windows back to the / partition? This is all I want, I don't really care that the partition table is a little messed up since everything is working.

And really sorry for responding so slow, but I have a lot of work these days.

Last edited by raxbg (2012-05-19 10:46:45)

Offline

#23 2012-05-19 17:50:41

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: How to rebuild partition table

I've learned the hard way that it is better to do a full backup before doing any operations with partitions. And you really should get all problems related to partitions sorted out, in my opinion it is a bad idea to have any program complain about the partition table, as it might cause so problems later on.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#24 2012-05-19 21:08:29

raxbg
Member
Registered: 2011-04-05
Posts: 105

Re: How to rebuild partition table

Ok I will copy everything to external drive. If I use just "sudo cp / <destination>" and then If something go wrong when messing with the partitions, if I just copy back everything will I have the same system as now?

Offline

#25 2012-05-20 20:09:39

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: How to rebuild partition table

Usually I do full disk images, I prefer that to copying individual files, If anything goes wrong it's just a matter of restoring the full disk image, at most you will end in an equal state as when you started.

If copying file by file I would use rsync but I guess it may be a matter of preference. I do use rsync but only when copying files from the backup image to newly created partitions, using cp -r should work too but I don't have experience with that.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

Board footer

Powered by FluxBB