From: Karel Zak <kzak@redhat.com>
To: Marc MERLIN <marc@merlins.org>
Cc: util-linux@vger.kernel.org
Subject: Re: Severe fdisk problem leading to data loss?
Date: Mon, 25 Nov 2013 11:31:24 +0100 [thread overview]
Message-ID: <20131125103124.GQ5572@x2.net.home> (raw)
In-Reply-To: <20131124135226.GH11389@merlins.org>
On Sun, Nov 24, 2013 at 05:52:26AM -0800, Marc MERLIN wrote:
> Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
> 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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: 0x0b8ccbaa
>
> Device Boot Start End Blocks Id System
> /dev/sda1 2048 1050623 524288 83 Linux
> /dev/sda2 1050624 105908223 52428800 0 Empty
^^^^^^^^^^
Congratulation, you found very old fdisk bug as well as GNU Parted bug :-)
The problem is that the partition has no set partition type, and
fdisk in some situations interprets such partition as unused.
So it lists the partition (print command), but the "add new
partition" command interprets this partition as unused.
> Command (m for help): n
> Partition type:
> p primary (1 primary, 0 extended, 3 free)
> e extended
> Select (default p): p
> Partition number (1-4, default 3):
> Using default value 3
> First sector (1050624-1953525167, default 1050624): 105908224 << eek default is bad
Yep.
It seems that GNU Parted is more consistent, it ignores the partition
at all :-), for example:
# fdisk -l /dev/sdb
...
Device Boot Start End Blocks Id System
/dev/sdb1 2048 22527 10240 83 Linux
/dev/sdb2 22528 227327 102400 0 Empty
# parted /dev/sdb print
...
Number Start End Size Type File system Flags
1 1049kB 11.5MB 10.5MB primary
This is definitely bug too, because Linux does not care about
partition type and kernel is able to use this partition:
# lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 600M 0 disk
├─sdb1 8:17 0 10M 0 part
└─sdb2 8:18 0 100M 0 part
Note, don't use -S and -H, fdisk does not care about CHS by default
(you have to enable obsolete DOS mode ('c' command)).
I'm going to make fdisk more robust and prepare also a patch for GNU
parted.
Thanks!
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2013-11-25 10:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20131118102051.GA31813@merlins.org>
2013-11-24 13:52 ` Severe fdisk problem leading to data loss? Marc MERLIN
2013-11-25 10:31 ` Karel Zak [this message]
2013-11-25 11:59 ` Marc MERLIN
2013-11-27 14:46 ` Phillip Susi
2013-11-27 14:58 ` Karel Zak
2013-11-27 18:25 ` Phillip Susi
2013-11-27 19:58 ` Curtis Gedak
2013-11-27 20:08 ` Phillip Susi
2013-11-27 20:23 ` Curtis Gedak
2013-11-27 21:05 ` Phillip Susi
2013-11-27 21:07 ` Curtis Gedak
2013-11-27 23:02 ` Ángel González
2013-11-27 20:07 ` Karel Zak
2013-11-27 20:19 ` Phillip Susi
2013-11-27 21:09 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131125103124.GQ5572@x2.net.home \
--to=kzak@redhat.com \
--cc=marc@merlins.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox