FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux General Discussion

 
 
LinkBack Thread Tools
 
Old 03-17-2010, 09:45 PM
Linas
 
Default fdisk vs cfdisk... And is my drive borked or what?

Joe(theWordy)Philbrook wrote:

Any way I only mention it because When I got around to installing Arch on
one of the two partitions I recovered from Sabayon, I skipped the
installation step of letting cfdisk touch my partitions and simply selected
the partition I previously prepared for it with mkfs.ext3. But later as
working my way through the beginners guide in the wiki, the clear
explanation of why distro's like to use UUID instead of /dev/Xdx# sold me
on using persistent (BUT HUMAN READABLE!!!) entries like:
"/dev/disk/by-label/Arch_lap-7"& "/dev/disk/by-label/SWP_lap-12"
Especially since there was a wealth of how-to info right there in the
wiki... But in the process I happened to do an:
fdisk /dev/sda

Which complained about a dos compatibility flag and that I should
change the display/entry units to sectors. This showed me a small bit of unused
space above my last logical partition (/dev/sda12)...

It shows those two warnings with the default call. AFAIK it is unrelated
to your

actual partition contents.


Anyway I decided to look at it with cfdisk (which I haven't used in years
but remembered as being easier to work with than fdisk...) But all I got
from cfdisk was.

=> FATAL ERROR: Bad primary partition 3: Partition ends after end-of-disk
=> Press any key to exit cfdisk

Which considering the recent "testdisk" repair, frightened be a bit. But it
also frustrated me. Especially since fdisk didn't show anything like that...

Unless maybe: When "cfdisk /dev/sda" says "partition 3:" is it counting from 0?
That is, does it mean "/dev/sda4" ???

Because that's my extended partition... And a close look at the ending
cylinder/sector of /dev/sda4 is a slightly higher number than it reports
the total cylinders/sectors to be...


Could be.


I've pasted both the sector and cylinder views of my part table below, Is
this anything I should be worried about??? Is there a way to fix this
without destroying everything in the extended partition??? (That's a LOT of
backing up to dvd, and I don't have room anyplace else...)


Caveat emptor: you should have a backup before touching partitions
That said, you only want to "truncate" the partitions, and since your last
partition is the swap, that should be pretty safe. The process of unmounting
swap partition, delete partition with fdisk, create with fdisk,
reformat swap

/shouldn't/ affect your data.

I find an oddity on your paritition table, though. You say that
/dev/sda4 is an
extended partition (and you do have logical partitions) but it is listed
by fdisk as
having type 0xf (W95 Ext'd (LBA)) instead of 0x5 (Extended). I suspect
that after

testdisk restoring, some old entries got loaded?
If that's really a wrong entry, you can do the fdisk delete/recreate tip
to force its
length to be inside the disk limits. However, fdisk won't allow you to
set a partition

type of 5, which is a pity when you *really* know what you are doing.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 
Old 03-18-2010, 08:10 AM
"Joe(theWordy)Philbrook"
 
Default fdisk vs cfdisk... And is my drive borked or what?

It would appear that on Mar 17, Linas did say:

> Joe(theWordy)Philbrook wrote:
> > fdisk /dev/sda
> >
> > Which complained about a dos compatibility flag and that I should
> > change the display/entry units to sectors. This showed me a small bit of
> > unused space above my last logical partition (/dev/sda12)...

> It shows those two warnings with the default call. AFAIK it is unrelated to
> your actual partition contents.

I'll buy that... The odd thing is the fdisk from my other distros doesn't
bother... So the warnings got my attention.

> > Anyway I decided to look at it with cfdisk (which I haven't used in years
> > but remembered as being easier to work with than fdisk...) But all I got
> > from cfdisk was.
> >
> > => FATAL ERROR: Bad primary partition 3: Partition ends after end-of-disk
> > => Press any key to exit cfdisk
> >
> > When "cfdisk /dev/sda" says "partition 3:" is it counting from 0?
> > That is, does it mean "/dev/sda4" ???
>
> Could be.
>
> > I've pasted both the sector and cylinder views of my part table below, Is
> > this anything I should be worried about??? Is there a way to fix this
> > without destroying everything in the extended partition??? (That's a LOT of
> > backing up to dvd, and I don't have room anyplace else...)
> >
> Caveat emptor: you should have a backup before touching partitions
> That said, you only want to "truncate" the partitions, and since your last
> partition is the swap, that should be pretty safe. The process of unmounting
> swap partition, delete partition with fdisk, create with fdisk, reformat swap
> /shouldn't/ affect your data.

I hadn't intended to touch the partitions. I only gave the malfunctioning
installer permission to reformat an existing ext2 partition as ext3.
That's an mkfs job that shouldn't have led to ANY table rewrite, never mind
writing to the table of a different drive...

Also, backing up everything isn't always practical. I really don't
have the spare storage space. So backing up 4 Linux installations would
eat a *LOT* of time and several DVD's... I do have enough room on my usb
drive to back up the personal data partitions. But if I bork up the drive
while fixing this I'm going to have to do a *LOT* of reinstalling from
scratch. Which leads to a *LOT* of painful configuring... But I note
that while the ending sector of the extended partition apparently
exceeds the drive's ending sector... The ending sector of the last
logical partition within it does not... So I don't think I need to redo
the swap. but rather (and for me more problematic) just the extended
partition that contains it. {I'll have more on that in my reply to Mauro below.}

It would appear that on Mar 17, Mauro Santos did say:

> On 03/17/2010 10:45 PM, Linas wrote:
> > Joe(theWordy)Philbrook wrote: {quote tag re-inserted by Joe...}
> >> => FATAL ERROR: Bad primary partition 3: Partition ends after
> >> end-of-disk
> >> => Press any key to exit cfdisk
>
> cfdisk can complain if _anything_ isn't as it wants it to be. cfdisk is
> easier to use than fdisk but complains a lot if the partition table
> deviates a little from the most compatible "format" possible.

So I noticed... But I think it does have a point.

> >> Because that's my extended partition... And a close look at the ending
> >> cylinder/sector of /dev/sda4 is a slightly higher number than it reports
> >> the total cylinders/sectors to be...
>
> I take it that the first listing is in sectors, if you look closely you
> will see that your last partition (swap) end before the end of the disk
> so you're safe, the extended partition is just a placeholder for other
> partitions, so if the partitions do not try to use space that doesn't
> exist it should be ok. However I would still try to rectify the ending
> of the extended partition. Backup all your data and try to shrink that
> extended partition until it fits in your disk.

I can backup all my personal data... But I don't have the room to back up
all my Linux installations. Rebuilding them all from scratch, all at once
would be a nightmare. But it's a risk I'll have to take. I'm not so sure
how to shrink the extended partition itself. cfdisk won't touch it. And if
I remember right, to do it with fdisk I basically have to delete and then
recreate the said extended partition using the correct sectors... But that
would, I think mean I'd have to delete the logical partitions first, and
then recreate them with their correct sector information within the
correctly recreated extended partition.
(And pray I got it "right" before I "write" the rebuilt table.)

I've never used gparted (unless maybe it was used as a backend for the "set
up your partitions manually" section of some Linux installer???
But does it have the ability to resize a NON-empty extended partition?
If not, is there something I can get from pacman that does?

And is it any more risky than the tedious fdisk process I described above?

> > I find an oddity on your paritition table, though. You say that
> > /dev/sda4 is an extended partition (and you do have logical partitions)
> > but it is listed by fdisk as having type 0xf (W95 Ext'd (LBA)) instead of
> > 0x5 (Extended). I suspect that after testdisk restoring, some old entries
> > got loaded? If that's really a wrong entry, you can do the fdisk
> > delete/recreate tip to force its length to be inside the disk limits.
> > However, fdisk won't allow you to set a partition type of 5, which is a
> > pity when you *really* know what you are doing.

Actually while I don't think the ending sector of the extended partition used
to be past the end of the drive before testdisk rebuilt my drive's table
for me. I'm quite sure the (W95 Ext'd (LBA)) part has been there forever.
The first thing I did when I got this laptop that was destined for at least
dual booting was to use the vista cd to repartition the drive into one much
smaller ntfs, two fat, and one extended partition(s) before I reinstalled
vista. Then I used Linux tools to add the logical drives. And eventually
turn the smaller fat into an ext2 /boot partition.

> Type 0xf is also ok, it all depends on which program created the
> partition table initially, I'm not sure but I think gparted used to set
> extended partitions to 0xf and so do many other programs.
> fdisk should be able to change the type to 5 but if it can't then give
> sfdisk a try but make sure all your data is safe.
>

0xf, 5, Who cares which it's called? As long as it contains the logical
partitions... But the ending sector thing will bug me if I don't fix it.
So for my piece of mind I'm gonna have to do something...
 
Old 03-19-2010, 05:34 PM
"Joe(theWordy)Philbrook"
 
Default fdisk vs cfdisk... And is my drive borked or what?

It would appear that on Mar 18, Mauro Santos did say:

> Gparted (which is just a frontend for parted) may be able to resize your
> extended partition without touching any of the logical partitions inside
> (you may need to delete your last partition first though, it all depends
> on what alignment gparted will try to use), however I try not to use
> gparted because once it wrecked havoc during a resize operation, because
> of that and because I have a big enough spare disk, I always do a full
> backup before any major partition changes.

Tried it... Gparted didn't like my existing partition table any better than
cfdisk did... It refused to use the table data. But unlike cfdisk it was
willing to proceed in case I wanted to recreate the whole thing from
scratch...

> Your primary partitions are safe but the logical ones can just vanish if
> things go wrong. I guess that if you take note of the start and end
> sectors for all partitions you can recreate the layout if anything goes
> wrong (I have never tried it though so I can't say how well that will work).

I can now certify that rebuilding them with fdisk works... {see below}

It would appear that on Mar 18, Guus Snijders did say:

> To be safe, first make an *exact* note (on paper) of the current partition
> table. If anything goes wrong, you can boot a rescue CD and recreate the
> partition table from this note.
> You could also make a copy of the first sector with dd and store that on some
> media (USB hdd comes to mind), but i would still make the paper note.

I did print the partition table data... I'm not good with dd. I've got
explicit notes on using it to backup/restore the mbr, and have a copy of
that on the usb drive (is that what you mean?) but using it back-up the rest
of the partition table is beyond me.

> After that, just change the end sector of the extended partition to match the
> end sector of your swap partition and you should be fine.
> (try starting cfdisk at this point to see if the error still exists).
Basically that's what I did with fdisk. I had a text file with the table
data in it on the usb drive. which I opened in one window while I ran fdisk
in another. It let me delete the old extended partition without explicitly
deleting the logical partitions, But of course when I recreated it, I
pasted the ending value from the swap partition. Then proceeded to recreate
the logical partitions the same way. (I had used the fdisk "u" to set units
to sectors:
1)type "n" copy the default beginning sector to clipboard
2)switch to the window with the text file open with vim
3)paste number next to old starting value to confirm values match
4)copy the ending sector from the old data to the clipboard
5)switch windows to the fdisk session
6)paste in the ending sector.
7)repeat 1-6 until all logical partitions had been recreated
8)use "t" to reset the type of the swap partition back to "82"
"w" write table...

And it worked.

> If you're feeling brave, you could also recreate the entire partition table
> from scratch. It's just a table listing which partitions are where. Nothing
> more.

I could have done that. But why mess with the 1st 3 partitions???

> If you don't fully trust the process, you could try mounting the data
> partitions after the change. If that succeeds without errors, it should be ok.

I trust it better now...

It would appear that on Mar 18, Linas did say:

> It works. But you should copy the values *in sectors*. It's amazing how
> different tools interpret the same values on different actual positions.

Well I could have recreated the whole table from scratch with gparted. But I
felt more secure using fdisk, since it was fdisk that provided the sector
data...

The good news is afterwards, I rebooted (successfully) And then tested
cfdisk, which no longer complains. I figure if cfdisk is willing to work on
it, my partition table must now be nearly perfect...

--
| --- ___
| <0> <-> Joe (theWordy) Philbrook
| ^ J(tWdy)P
| ~\___/~ <<jtwdyp@ttlc.net>>
 
Old 03-19-2010, 07:16 PM
Guus Snijders
 
Default fdisk vs cfdisk... And is my drive borked or what?

On 19-03-10 19:34, Joe(theWordy)Philbrook wrote:

[ fixing a partition table ]


I can now certify that rebuilding them with fdisk works... {see
below}


Good work.
On a funny note; i read today that fdisk also has an option to "fix" an
existing partition table (under expert options)...



It would appear that on Mar 18, Guus Snijders did say:


To be safe, first make an *exact* note (on paper) of the current
partition table. If anything goes wrong, you can boot a rescue CD
and recreate the partition table from this note. You could also
make a copy of the first sector with dd and store that on some
media (USB hdd comes to mind), but i would still make the paper
note.


I did print the partition table data... I'm not good with dd. I've
got explicit notes on using it to backup/restore the mbr, and have a
copy of that on the usb drive (is that what you mean?) but using it
back-up the rest of the partition table is beyond me.


Looks like the partition table is stored on the first sector of the
disk, so restoring a copy of that sector also restores the table.

But yes; storing a copy of the MBR on an external disk is what i meant.


After that, just change the end sector of the extended partition to
match the end sector of your swap partition and you should be
fine. (try starting cfdisk at this point to see if the error still
exists).

Basically that's what I did with fdisk. I had a text file with the
table data in it on the usb drive. which I opened in one window while
I ran fdisk in another.

[...]


And it worked.


Great, that's good news.


If you're feeling brave, you could also recreate the entire
partition table from scratch. It's just a table listing which
partitions are where. Nothing more.


I could have done that. But why mess with the 1st 3 partitions???


You're right, it wasn't neccesary in this case, but it sometimes happens
that the order of partitions get messed up. On such occasion it might be
worthwhile to just recreate the whole table.



mvg,
Guus
 

Thread Tools




All times are GMT. The time now is 04:04 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org