Everything about diskpart commands in windows 10

Windows 10のDiskPartコマンドの代替ソフト

ご覧のように、Windows 10のDiskPartコマンドはディスク&パーティションの管理にとても役立ちますが、パソコン初心者にとって、依然として複雑かもしれません。

この場合、誰でも簡単に使えるAOMEI Partition Assistant StandardはDiskPartコマンドの代わりになります。このパーティション管理フリーソフトは、DiskPartよりも多くの強力な機能を提供します。完全無料ですし、Windows 10だけでなく、Windows 8.1/8、7、Vista、XPにも対応します。

▼パーティションやボリュームを操作するために、目的のオブジェクトを右クリックし、実行したい項目を選択します。AOMEI Partition Assistantによってサポートされた機能は次のように:

▼ディスク管理に対する操作またはウィザードは次のように:

そのほかのAOMEI製品・おすすめ~ブータブルディスクの作成、HDDのパーティション分割、ディスクの消去、論理ドライブとプライマリパーティション間での変換など、もっと高度な機能を使用したい場合、AOMEI PA Standard無料版をAOMEI Partition Assistant Professional版にアップグレードしてください。(割引&ギフト)そのほか、Windows Server 2019、2016、2012(R2)向けServer版(有料)及びLite版(無料)、台数無制限のコンピュータで使用可能なUnlimited版、クライアントに有償技術サービスを提供するIT専門家や技術者向けTechnician版もあります。異なるバージョンの比較ヾ(*´∀`*)ノ高級版を購入する前に無料体験版をダウンロードして試みることができます!無料体験

BUGS

*

The program compiles correctly only on Linux, FreeBSD, Mac OS X, and Windows.
Linux versions for x86-64 (64-bit), x86 (32-bit), and PowerPC (32-bit) have been
tested, with the x86-64 version having seen the most testing. Under FreeBSD,
32-bit (x86) and 64-bit (x86-64) versions have been tested. Only 32-bit
versions for Mac OS X and Windows have been tested by the author, although
I’ve heard of 64-bit versions being successfully compiled.

*

The FreeBSD version of the program can’t write changes to the partition
table to a disk when existing partitions on that disk are mounted. (The
same problem exists with many other FreeBSD utilities, such as
gpt, fdisk, and dd.) This limitation can be overcome
by typing sysctl kern.geom.debugflags=16 at a shell prompt.

*

The fields used to display the start and end sector numbers for partitions
in the ‘p’ command are 14 characters wide. This translates to a limitation
of about 45 PiB. On larger disks, the displayed columns will go out of
alignment.

*

In the Windows version, only ASCII characters are supported in the
partition name field. If an existing partition uses non-ASCII UTF-16
characters, they’re likely to be corrupted in the ‘i’ and ‘p’ menu options’
displays; however, they should be preserved when loading and saving
partitions. Binaries for Linux, FreeBSD, and OS X support full UTF-16
partition names.

*

The program can load only up to 128 partitions (4 primary partitions and
124 logical partitions) when converting from MBR format. This limit can
be raised by changing the #define MAX_MBR_PARTS line in the
basicmbr.h source code file and recompiling; however, such a change
will require using a larger-than-normal partition table. (The limit
of 128 partitions was chosen because that number equals the 128 partitions
supported by the most common partition table size.)

*

Converting from MBR format sometimes fails because of insufficient space at
the start or (more commonly) the end of the disk. Resizing the partition
table (using the ‘s’ option in the experts’ menu) can sometimes overcome
this problem; however, in extreme cases it may be necessary to resize a
partition using GNU Parted or a similar tool prior to conversion with
gdisk.

*

MBR conversions work only if the disk has correct LBA partition
descriptors. These descriptors should be present on any disk over 8 GiB in
size or on smaller disks partitioned with any but very ancient software.

*

BSD disklabel support can create first and/or last partitions that overlap
with the GPT data structures. This can sometimes be compensated by
adjusting the partition table size, but in extreme cases the affected
partition(s) may need to be deleted.

*

Because of the highly variable nature of BSD disklabel structures,
conversions from this form may be unreliable — partitions may be dropped,
converted in a way that creates overlaps with other partitions, or
converted with incorrect start or end values. Use this feature with
caution!

*

Booting after converting an MBR or BSD disklabel disk is likely to be
disrupted. Sometimes re-installing a boot loader will fix the problem, but
other times you may need to switch boot loaders. Except on EFI-based
platforms, Windows through at least Windows 7 doesn’t support booting
from GPT disks. Creating a hybrid MBR (using the ‘h’ option on the recovery &
transformation menu) or abandoning GPT in favor of MBR may be your only
options in this case.

Examples

Tip

You must have root access for this command to work.

fdisk -l

List the partition information of the computer you’re logged into. Below is an example of what this output may look like:

Disk /dev/sda: 250.0 GB, 250059350016 bytes 255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device     Boot  Start  End    Blocks      Id  System
/dev/sda1  *     1      191    1534176     83  Linux
/dev/sda2        192    2231   16386300    83  Linux
/dev/sda3        2232   3506   10241437+   83  Linux
/dev/sda4        3507   30401  216034087+  5   Extended
/dev/sda5        3507   3767   2096451     82  Linux swap / Solaris
/dev/sda6        3768   3832   522081      83  Linux
/dev/sda7        3833   30401  213415461   83  Linux Disk
/dev/sdb: 250.0 GB, 250059350016 bytes 255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device     Boot  Start  End    Blocks      Id  System
/dev/sdb1  *     1      30401  244196001   83  Linux

Free alternative to Windows 10 DiskPart Utility

As DiskPart alternative, AOMEI Partition Assistant Standard is a free partition manager software and disk management tool, which provides more features than DiskPart. It not only supports Windows 10, but also supports Windows 8.1/8, Windows 7, Vista and XP. With a user-friendly interface, it is very easy to use.

To perform an operation on a partition, you just need to right-click on it. The operations supported by AOMEI Partition Assistant Standard are as below:

The operations of disk management and step-by-step wizards are as below:

DiskPart in Windows 10 can meet the basic requirement of most users. And the free AOMEI Partition Assistant is more advanced than it and provides more amazing features. For example, it can extend/shrink both FAT32 and NTFS partition. For extending a partition, its “Merge partition” allows users to add non-adjacent unallocated space into the target partition. It is able to format large partition (2TB at most) to FAT32 file system. For partition style conversion, it can convert data disk between MBR and GPT without deleting partitions.

You can download this freeware and have a try. To get more advanced features, such as converting dynamic disk into basic without losing data, recovering lost partition, you can upgrade AOMEI Partition Assistant Standard to Professional version.

Download Freeware

Win 10/8.1/8/7/XP

What Is FDISK

Some users who have not heard about FDISK may wonder: what is FDISK, what is it for? Let’s see FDISK’s definition on Wikipedia.

Originally, FDISK is one kind of DOS program so it can only work in DOS. With FDISK, you can divide disk into one primary partition and multiple logical partitions. After dividing, you need to format partition and allocate file systems for partitions.

However, earlier FDISK has no format function so that partitioning and formatting need to be done step by step, which means more operations and more DOS commands. For users who are not familiar with DOS, they are likely to operate with errors.

Finally, with continuous developing, FDISK has been added with FDISK format tool besides FDISK partition tool. After FDISK has been improved in compatibility with operating systems, disk size, and partition size, many users choose FDISK to manage partition.

About Fdisk

What is Fdisk? Fdisk is an advanced command line tool that was part of earlier
versions of Windows according to Microsoft. The latest version of Windows that comes
with Fdisk program was Windows 98 with a DOS shell. Fdisk was used to create,
delete, and format partitions on hard disks that were formatted using the FAT32 and
other FAT file systems.

Fdisk doesn’t work with partitions or hard disks that are formatted using NTFS file
system. Therefore it has been replaced by diskpart.exe in Windows 7 (both 32 bit and
64 bit) and in later OS like Windows 8/8.1/10 which comes with NTFS file system.
Even though today’s technology supports to convert NTFS to
FAT32, it is still removed. One possible reason is Fdisk hard drive in
Windows 7 is much more risky because its operations are almost irreversible. Another
one is Fdisk is incompatible with large size hard disks.

See drives in MS-DOS and the Windows command line

Windows Vista, 7, 8, and 10 command line users

If you’re using Windows Vista, 7, or 8, use the wmic command at the Windows command line to view available drives on the computer. At the prompt, type the following command.

wmic logicaldisk get name

Or, for a little more information, such as volume size, use this command:

wmic logicaldisk list brief

See our wmic command page for further information and examples on this command.

Other Windows command line and MS-DOS version users

Unfortunately, there is no easy way to list all available drives on the computer through the MS-DOS prompt with one command. Below are different recommendations for viewing drives.

Change drive letter

Change the drive to an alternate drive letter to determine if a drive is available and ready if no error message is received.

Fdisk

Running the fdisk command allows you to view how the hard drives are set up and configured on the computer. However, this command is only possible if you’re running a version of MS-DOS or Windows that supports fdisk.

See the fdisk command page for additional information about this command.

vol

Running the vol command on a drive displays the drive label and serial number if available. This command allows you to see what drives are detected.

See the vol command page for additional information and help with this command.

Secret fdisk switches

Disclaimer: Below is a listing of secret or undocumented MS-DOS fdisk commands and switches. Use these commands at your risk.

Command Information
FDISK /MBR Command used to rewrite the master boot record, see: Do you have additional information on fdisk /mbr?
FDISK /CMBR <DISK> Recreates the master boot record on the specified disk. Performs the same functions as FDISK /MBR except can be used on other disk drives.
FDISK 1/PRI:100 Creates a 100 MB DOS partition on the hard drive.
FDISK 1/EXT:500 Creates a 500 MB meg extended DOS partition on the hard drive.
FDISK 1/LOG:250 Creates a 250 MB logical drives on the hard drive.
FDISK /Q Prevents fdisk from booting the system automatically after exiting fdisk.
FDISK /STATUS Shows you the current status of your hard drives.
FDISK /ACTOK Makes fdisk not check the disk integrity allowing the drives to be created faster.
FDISK /FPRMT Prevent the prompt for FAT32 support and allows FDISK to be forced into using FAT32 on drives smaller than 540 MB. By default, FDISK does not use FAT32 on any drive smaller than 540 MB. Finally, this command can only be used with FDISK that supports FAT32.

Options

-b sectorsize

Specify the sector size of the disk. Valid values are 512, 1024, 2048 or 4096. Recent kernels know the sector size. Use this only on old kernels or to override the kernel’s ideas. Since util-linux-2.17, fdisk differentiates between logical and physical sector size. This option changes both sector sizes to sectorsize.

-c[=mode]

Specify the compatibility mode, ‘dos‘ or ‘nondos‘. The default is non-DOS mode. For backward compatibility, it is possible to use the option without the mode argument; in that case, the default is used. Note that the optional mode argument cannot be separated from the -c option by a space, the correct form is, for example, ‘-c=dos‘.

-C cyls

Specify the number of cylinders of the disk. This would be a very strange thing to want to do, but if so desired, this option will get it done.

-H heads

Specify the number of heads of the disk. Not the physical number, but the number used for partition tables. Reasonable values are 255 and 16.

-S sects

Specify the number of sectors per track of the disk. Not the physical number, but the number used for partition tables. A reasonable value is 63.

-h

Print help and then exit.

-l

List the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used.

-u[=unit]

When listing partition tables, show sizes in ‘sectors‘ or in ‘cylinders‘. The default is to show sizes in sectors. For backward compatibility, it is possible to use the option without the units argument; in this case, the default is used. Note that the optional unit argument cannot be separated from the -u option by a space; the correct form is, for example, ‘-u=cylinders‘.

-v

Print version information, and exit.

OPTIONS

-a, —append

Don’t create a new partition table, but only append the specified partitions.
-b, —backup

Back up the current partition table sectors before starting the partitioning.
The default backup file name is ~/sfdisk-<device>-<offset>.bak; to use another
name see option -O, —backup-file.
—color[=when]

Colorize the output. The optional argument when
can be auto, never or always. If the when argument is omitted,
it defaults to auto. The colors can be disabled; for the current built-in default
see the —help output. See also the COLORS section.
-f, —force

Disable all consistency checking.
—Linux

Deprecated and ignored option. Partitioning that is compatible with
Linux (and other modern operating systems) is the default.
-n, —no-act

Do everything except writing to the device.
—no-reread

Do not check through the re-read-partition-table ioctl whether the device is in use.
—no-tell-kernel

Don’t tell the kernel about partition changes. This option is recommended together
with —no-reread to modify a partition on used disk. The modified partition
should not be used (e.g. mounted).
-O, —backup-file path

Override the default backup file name. Note that the device name and offset
are always appended to the file name.
—move-data[=path]

Move data after partition relocation, for example when moving the beginning
of a partition to another place on the disk. The size of the partition has
to remain the same, the new and old location may overlap. This option requires
option -N in order to be processed on one specific partition only.

The path overrides the default log file name
(the default is ~/sfdisk-<devname>.move). The log file contains information
about all read/write operations on the partition data.

Note that this operation is risky and not atomic. Don’t forget to backup your data!

In the example below, the first command creates a 100MiB free area before
the first partition and moves the data it contains (e.g. a filesystem),
the next command creates a new partition from the free space (at offset 2048),
and the last command reorders partitions to match disk order
(the original sdc1 will become sdc2).

echo ‘+100M,’ | sfdisk —move-data /dev/sdc -N 1

echo ‘2048,’ | sfdisk /dev/sdc —append

sfdisk /dev/sdc —reorder

-o, —output list

Specify which output columns to print. Use
—help

to get a list of all supported columns.

The default list of columns may be extended if list is
specified in the format +list (e.g. -o +UUID).

-q, —quiet

Suppress extra info messages.
-u, —unit S

Deprecated option. Only the sector unit is supported. This option is not
supported when using the —show-size command.
-X, —label type

Specify the disk label type (e.g. dos, gpt, …). If this option
is not given, then sfdisk defaults to the existing label, but if there
is no label on the device yet, then the type defaults to dos. The default
or the current label may be overwritten by the «label: <name>» script header
line. The option —label does not force sfdisk to create empty
disk label (see the EMPTY DISK LABEL section below).
-Y, —label-nested type

Force editing of a nested disk label. The primary disk label has to exist already.
This option allows to edit for example a hybrid/protective MBR on devices with GPT.

-w, —wipe when

Wipe filesystem, RAID and partition-table signatures from the device, in order
to avoid possible collisions. The argument when can be auto,
never or always. When this option is not given, the default is
auto, in which case signatures are wiped only when in interactive mode;
except the old partition-table signatures which are always wiped before create
a new partition-table if the argument when is not never. In all
cases detected signatures are reported by warning messages before a new
partition table is created. See also
wipefs(8)

command.

-W, —wipe-partitions when

Wipe filesystem, RAID and partition-table signatures from a newly created
partitions, in order to avoid possible collisions. The argument when can
be auto, never or always. When this option is not given, the
default is auto, in which case signatures are wiped only when in
interactive mode and after confirmation by user. In all cases detected
signatures are reported by warning messages after a new partition is created.
See also
wipefs(8)

command.

-v, —version

Display version information and exit.
-h, —help

Display help text and exit.

Windows 7でのFdiskツールの代替

MicrosoftはWindows 7でFdiskを削除して以来、Fdiskを別のユーティリティに置き換えました。Windows 7のの検索ボックスに「fdisk」と入力すると、オプションが表示されます。こ
のオプションを選択したら、新しい追加機能を使用するようになります。

「ディスクの管理」はGUI(グラフィカルユーザーインターフェイス)形式であり、diskpart.exeはCUI(コマンド/キャラクタユーザインタフェースユーザーインターフェイス)形式のためFdiskに似ています。Windows
7で[ファイル名を指定して実行]ボックスに「diskpart.exe」と入力し、Enterキーを押すだけでdiskpart.exeを開くことができます。

これらの2つの代替品を使用すると、お使いのコンピュータで多くのオブジェクト(ディスク、パーティションまたはボリューム)を管理できます。例えば、シンプルボリュームの新規作成、ボリュームの拡張、ボリュームの縮小、パーティションフォーマット、およびパーティションの削除など。

しかし、これらの基本的なディスク管理機能は、もはやWindowsユーザーのニーズを満たしません。例えば、パーティションの結合、即ちデータを失うことなく、パーティションを結合するという機能です。「ディスクの管理」でパーティションを結合するには、ボリュームを1つ削除し、残りのボリュームを拡張する必要があります。だが、データが失われる可能性があります。そして、未割り当て領域が隣接していない限り、ボリュームを拡張できません。

Windows 7でFdiskを代替するもう1つツールはAOMEI Partition Assistant Proです。このソフトはWindows 7/8/10とWindows
XP/Vistaをサポートする全面的なパーティション管理ツールです。AOMEI Partition Assistantを使用すると、上述した問題を簡単に処理できます。

前述の2つのツールとは異なり、このソフトウェアを使用すると、結果をプレビューするし、実行した操作を元に戻すことができます。一般的なWindowsユーザーにとっては、AOMEI Partition Assistant無料版がもう十分です。これをダウンロードしてお使いのハードディスクを管理しましょう!(ここでは、未割り当て領域をCドライブに結合することを例とします)。

無料ダウンロード

Win 10/8.1/8/7/XP

FDISK Is Replaced by Diskpart

As FDISK is too difficult for common users, FDISK has been replaced by Diskpart, a command-line disk partitioning utility included in Windows 2000 and later. Diskpart is simpler than FDISK. Users can use Diskpart to partition hard drive, delete partition, format partition and so on.

Although Diskpart has satisfied users’ demands for partition management to some extent, it is still a little complicated to manage for users who are not familiar with DOS commands.

In this case, it is strongly suggested to use MiniTool Partition Wizard that has a graphical interface and simpler operations. With MiniTool Partition Wizard, you can create, delete or format partition in just a few clicks. Besides, it also provides high-end features like Copy disk, Partition Recovery etc. It’s a perfect Diskpart and FDISK alternative.

Create New Partitions from Shell Script (Non-interactive Method)

One of the great benefit of sfdisk is that you can create partition on-the-fly from command-line without any interaction from sfdisk.

This is very helpful when you want to automate the partition creation from a shell-script.

Currently, as you see from the following output, the sdf device is currently empty. This doesn’t have any partitions.

# sfdisk -l /dev/sdf

Disk /dev/sdf: 1044 cylinders, 255 heads, 63 sectors/track
Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdf1          0       -       0          0    0  Empty
/dev/sdf2          0       -       0          0    0  Empty
/dev/sdf3          0       -       0          0    0  Empty
/dev/sdf4          0       -       0          0    0  Empty

Now, execute the following command, which will automatically create three partitions (sdf1, sdf2, sdf3) using the values provided below.

# sfdisk /dev/sdf <<EOF
0,512
,512
;
;
EOF

In the above:

  • There should be 4 lines in the above input for all 4 primary partitions.
  • The first line indicates that it should start from 1st cylinder until 512 to create 1st partition (i.e sdf1)
  • The second line indicates that it should start from the last available cylinder as the first cylinder and from there use +512 cylinders to create the 2nd partition (i.e sdf2)
  • The third line has semi-colon, which indicates that use the default values, and don’t prompt anything from the user for the 3rd partition. In this case, it will use all remaining cylinders on the disk and create 3rd partition (i.e sdf3)
  • The fourth line has semi-colon, which indicates that use the default values, and don’t prompt anything from the user for the 4th partition. In this case, since there is no space left, it will not create anything for 4th partition (i.e sdf4)

The following is the output of the above sfdisk command. Please note that this is not asking for any input from the user.

Checking that no-one is using this disk right now ...
OK

Disk /dev/sdf: 1044 cylinders, 255 heads, 63 sectors/track
Old situation:
Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdf1          0       -       0          0    0  Empty
/dev/sdf2          0       -       0          0    0  Empty
/dev/sdf3          0       -       0          0    0  Empty
/dev/sdf4          0       -       0          0    0  Empty
New situation:
Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdf1          0+    511     512-   4112639+  83  Linux
/dev/sdf2        512    1023     512    4112640   83  Linux
/dev/sdf3       1024    1043      20     160650   83  Linux
/dev/sdf4          0       -       0          0    0  Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

Verify that the three partitions got created automatically using the provided values.

# sfdisk -l /dev/sdf

Disk /dev/sdf: 1044 cylinders, 255 heads, 63 sectors/track
Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdf1          0+    511     512-   4112639+  83  Linux
/dev/sdf2        512    1023     512    4112640   83  Linux
/dev/sdf3       1024    1043      20     160650   83  Linux
/dev/sdf4          0       -       0          0    0  Empty

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook 
  • Awk Introduction – 7 Awk Print Examples
  • Advanced Sed Substitution Examples
  • 8 Essential Vim Editor Navigation Fundamentals
  • 25 Most Frequently Used Linux IPTables Rules Examples
  • Turbocharge PuTTY with 12 Powerful Add-Ons

DOS 6.x warning

The DOS 6.x FORMAT command looks for some information in the first sector of the data area of the partition, and treats this information as more reliable than the information in the partition table. DOS FORMAT expects DOS FDISK to clear the first 512 bytes of the data area of a partition whenever a size change occurs. DOS FORMAT will look at this extra information even if the /U flag is given: this is considered to be a bug in DOS FORMAT and DOS FDISK.

The bottom line is that if you use cfdisk or fdisk to change the size of a DOS partition table entry, then you must also use dd to zero the first 512 bytes of that partition before using DOS FORMAT to format the partition. For example, if you were using cfdisk to make a DOS partition table entry for /dev/sda1, then (after exiting fdisk or cfdisk and rebooting Linux so that the partition table information is valid) you would use the command «dd if=/dev/zero of=/dev/sda1 bs=512 count=1» to zero the first 512 bytes of the partition.

Warning

BE EXTREMELY CAREFUL if you use the dd command, a small typo can make all of the data on your disk useless.

For best results, you should always use an OS-specific partition table program. For example, you should make DOS partitions with the DOS FDISK program and Linux partitions with the Linux fdisk or Linux cfdisk program.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector