On the use of DISKPART within Windows

I have been requested (by dvhenry) to provide some examples of using DISKPART to show partition information within Windows. Knowledge of the utility could potentially be useful for those advising Linux newcomers desiring a Windows/openSUSE dualboot who are having difficulties with fdisk -l. The utility is started within the console (which can be obtained within Windows 7 by searching' for cmd’). Note that the console text can be copied from the menu obtained by right-clicking the title bar -> Edit -> Select All. Then RMB -> Edit -> Copy.

To begin a diskpart session, type diskpart on the console. Then to list the available disk drives type `list disk’:

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          698 GB  3072 KB
  Disk 1    Online          223 GB    12 MB

To select a specific disk drive type `select disk=n’, where n is the Disk number.

DISKPART> select disk=0

Disk 0 is now the selected disk.

To list the partitions of the selected drive, the size, and locations, type `list partitions’:

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 0    Extended           585 GB   101 MB
  Partition 4    Logical             31 GB   102 MB
  Partition 5    Logical             31 GB    31 GB
  Partition 6    Logical             31 GB    62 GB
  Partition 7    Logical            492 GB    93 GB
  Partition 1    Primary             64 GB   586 GB
  Partition 2    Primary             16 GB   650 GB
  Partition 3    Primary             32 GB   666 GB

To obtain more information about a specific partition, it must first be selected:

DISKPART> select partition=1

Partition 1 is now the selected partition.

Once, selected, more information can be obtained - how much depends on whether it’s a recognised Windows format:

DISKPART> detail partition

Partition 1
Type  : 07
Hidden: No
Active: Yes
Offset in Bytes: 629251506176

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 5     C   WIN64        NTFS   Partition     64 GB  Healthy    System

The disk drive selected above (disk 0) is my Windows hard drive. You will now see how the information differs if a partition from my Linux hard drive is selected.


DISKPART> select disk=1

Disk 1 is now the selected disk.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary           1027 MB  1024 KB
  Partition 2    Primary            127 GB  1028 MB
  Partition 0    Extended            95 GB   128 GB
  Partition 3    Logical             64 GB   128 GB
  Partition 4    Logical             31 GB   192 GB

DISKPART> select partition=2

Partition 2 is now the selected partition.

DISKPART> detail partition

Partition 2
Type  : 83
Hidden: Yes
Active: No
Offset in Bytes: 1077936128

There is no volume associated with this partition.

HTH

Command Prompt can also be opened I believe:

Start menu > All programs > Accessories, right click on Command Prompt and select Run as administrator.

I am a bit confused about that partition numbering.

In the first example (disk 0, would be our sda I presume), has numbers starting with 0. This leads me to the conclusion that we have to add one to get our fdisk numbering. And that would give:
partition 1: extended (unusual, but possible);
partition 2-4: primary
partition 5-7: logical
All within the correct numbering possibilities.

But disk 1 (we would see that as sdb) after adding 1 to the partition numbers would make:
partition 1-2: primary
partition 0: extended (out of sequence? again not usual but possible)
partition 4 logical! This is an impossible number for a logical. They have to be 5 (4 in the Windows numbering) or above.
partition 5 logical

The numbers do not map to /dev/sdX:

Oops, unbelievable!

On 01/17/2013 11:26 AM, hcvv wrote:
>
> Oops, unbelievable!

It is probably that bad; however, here is the comparison for my dull-boot system
of openSUSE 12.2 and Win 7:


finger@linux-vrao:~> sudo fdisk -l
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: 0x1bfc1bfc

Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2          206848   104859647    52326400    7  HPFS/NTFS/exFAT
/dev/sda3   *   104859648   312576704   103858528+   5  Extended
/dev/sda5       104859711   146818034    20979162   83  Linux
/dev/sda6       146818098   151027064     2104483+  82  Linux swap / Solaris
/dev/sda7       151027128   312576704    80774788+  83  Linux
finger@linux-vrao:~>

In the above, sda1 is the Windows boot partition, sda2 contains Windows, sda5 is
/ for Linux, and sda7 is /home.

On Windows, DISKPART shows the following for Disk 0 (Sorry for the transcription
by hand, but capturing Windows command-line text is not something I remember how
to do):


Partition #		 Type		 Size		 Offset
1		Primary		100 MB		1024 KB
2		Primary		 49 GB		 101 MB
0		Extended	 99 GB		  50 GB
3		Logical		 20 GB		  50 GB
4		Logical        2055 MB		  70 GB
5		Logical		 77 GB		  72 GB

With both sets of data available, it is easy to see the correspondence; however,
if I were given only the DISKPART listing, I’m not sure I could deduce much
about the fdisk listing, and this is an easy case where the partitions are in
disk order.

On 2013-01-17 16:56, flymail wrote:
>
> I have been requested (by dvhenry) to provide some examples of using

Yes, but you could have posted it as a continuation of the equivalent
thread I started in the submissions forums some days ago. Now we have
two different threads on diskpart.


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

I am glad I asked. Because at the first sight it is a very good idea. But it only works if we (I) can “translate” that DISKPART information into trustworthy fdisk equivalents. Else our advise would be build on the same thin air as the fairy tales many people now tell about their partition schemes. :frowning:

True. And?

If you look really really carefully, you might notice that the partitions listed by fdisk and diskpart are identically ordered since they are ordered by physical locatio. This makes equivalence determination trivial by utility of common sense. Or am I missing something?

I see this in lwfinger’s example. I do not know (and he also expresses his doubts) if that is allways the case.

As said earlier, I value it when we can instruct somebody locked in in Windows to post something we can use. But then we, locked out of Windows, must be sure what it means and what is to be trusted. That is what I try to find out. Thus when you confirm that the sequence in all cases is the sequence on disk, I do believe that from you. I guess you have either the documentation or the experience. I have none.

Having no begin/end addresses I am still wondering what when there are holes between partitions? And I may be very dumb here, but I still can not real make out what the OFFSET is. Offset to what?

In short, while some of you may realy write down an fdisk list out of the info from DISKPART, I am afraid I have to do more excersizes :frowning:

On 2013-01-17 19:56, flymail wrote:
>
> robin_listas;2519240 Wrote:
>>
>> Yes, but you could have posted it as a continuation of the equivalent
>> thread I started in the submissions forums some days ago. Now we have
>> two different threads on diskpart.
>>
>
>
> True. And?

And? :-?


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

I think the extended partition always has number 0 in DISKPART. And the important thing to know is that DISKPART is not able to activate this partition (unlike another regular regular primary). Thus it can not be used to set the bootflag back on the extended partition when the Grub boot loader is installed there - which is a common case for openSUSE.

If it had this feature, it would be pretty useful, as it would allow to fix a simple boot problem many Windows dualbooters encounter (after repairing Windows or installing a service pack or whatever) , whithout even needing to boot a Linux live system (and certainly without reinstalling Grub if it wasn’t installed in MBR before, because this would be a hack, not a solution).

I agree. DISKPART is not such an indispensable tool that it deserves two threads in a Linux forum. lol!
OK, OK, just kidding.

BTW, Carlos, I mentioned diskpart years ago … but you don’t read my posts. I know, you read them but you don’t remember. I also suggested that it could be used to reset the boot flag … until I realized it could not (on the extended partition at least).

Windows and openSuse 11.4 dual boot problem

I have been requested (by dvhenry) to provide some examples of using DISKPART to show partition information within Windows.

Actually, I was replying in a different thread to a post by @robin_listas regarding the use of DISKPART my request, i thought, was that you contribute to that thread.

RTFM is of no use to me, as I don’t have an installed windows system to compare output between fdisk and DISKPART.
A discussion by those who can make those comparisons, such as on this thread and https://forums.opensuse.org/english/get-technical-help-here/how-faq-forums/unreviewed-how-faq/482268-windows-7-diskpart-output.htmlis however very useful.

Actually, I was replying in a different thread to a post by @robin_listas regarding the use of DISKPART my request, i thought, was that you contribute to that thread.

I realize now that you were referring to an earlier post on that same thread, so ignore that part of the above post.

Having the both start and end block addresses is clearly useful; I agree this is a deficiency. But it can worked out (well at least approximately) since the end address = start address + partition size.

It’s the same variable as fdisk’s START, except expressed in units of kb/Mb/Gb.

It depends how much you want to make life easier for the Linux newcomer who wants a dualboot with Windows. Empathise for a moment. You can either ask them to download a Live Linux version to boot from USB, change the BIOS order to boot from USB (assuming the motherboard support it) for the sole purpose of outputting the results from fdisk -l. Or you can ask them just to type diskpart' at the Windows console and output the result of list partition’.

I’m probably misunderstanding you. Why would want to boot from the extended partition outside a logical partition? I wouldn’t suggest (to a Linux user)
using DISKPART for anything other than displaying information. For borked Windows installations however it can be very useful.

I have to do aome more calculations I guess before I understand.

That is exactly (and I hope that I expressed that earlier) why I see this thread and the aboive description as usefull. But my opinion is then that this thread should contain as much documentation as possible to make me able to interprete the output. Else I only ask the poor Windows user to post something and then I have to admit that I do not understand what the posted output means.

And no, I am not going to buy some Windows system even when it is only for getting access to the documentation of DISKPART (if that doscmentation is available on such a system, does Windows have man pages?). When that is needed, I will continue to ask for fdisk listings from live/rescue/demonstration CDs/DVDs.

I don’t know TBH. I’m far to undisciplined to read manuals on every program I use :). Microsoft does however haveful useful online support pages that provide more detailed documentation: e.g. A Description of the Diskpart Command-Line Utility

I think you missed what I said about holes.
The problem is that people come here with all sorts of partitioning, you never dreamt of in your worst nightmares. And you only will see this when you have a good listing. The people themselves have no idea what they are talking about and there will not b the slightest warning in their original posts about such things.

Until now there is but one rule when people come with partitioning problems/questions: “show an fdisk -l”, because the tell nuts.
When a Windows tool could give the same information for the (until that moment in time) Windows only user, that would be perfect. But only when it would give the same information.

Thanks for the link.