summaryrefslogtreecommitdiff
path: root/doc/parted.texi
blob: 9c9d282188721de6a57079d88857aa3fce47a439 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
\input texinfo    @c -*-texinfo-*-
@c %**start of header
@setfilename parted.info
@settitle Parted User's Manual
@include version.texi
@paragraphindent 2
@c %**end of header

@ifinfo
This file documents the use of GNU Parted, a program for creating
and manipulating partition tables.
@end ifinfo

@ifnottex @c texi2pdf don't understand copying and insertcopying ???
@c modifications must also be done in the titlepage
@copying
Copyright @copyright{} 1999--2022 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts.  A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end copying
@c WTF does the info get the copying output and the plaintext output not ????
@ifplaintext
@insertcopying
@end ifplaintext
@end ifnottex

@dircategory System administration
@direntry
* parted: (parted).                         GNU partitioning software
@end direntry

@titlepage
@title GNU Parted User Manual
@subtitle GNU Parted, version @value{VERSION}, @value{UPDATED}
@author Andrew Clausen @email{clausen@@gnu.org}
@author Richard M. Kreuter @email{kreuter@@anduril.rutgers.edu}
@author Leslie Patrick Polzer @email{polzer@@gnu.org}


@c @page
@c @vskip 0pt plus 1filll

@c modifications must also be done in the copying block
Copyright @copyright{} 1999-2021 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts.  A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end titlepage

@ifnottex
@node Top
@top GNU Parted User Manual

@c WTF doesn't texi2html include the titlepage?
@ifhtml
@insertcopying
@end ifhtml

This file documents the use of GNU Parted, a program for creating
and manipulating partition tables.

This document applies roughly to version @strong{@value{VERSION}} of GNU Parted.

The original version was written by Andrew Clausen in text format.
Richard M. Kreuter translated it into Texinfo format in 2002, to be heavily
edited by Leslie P. Polzer in 2006.
@end ifnottex

@shortcontents

@menu
* Introduction::                Overview
* Using Parted::                Partitioning a Hard Drive
* Related information::         Further reading on related topics
* Copying This Manual::         How to make copies of this manual
* History::                     This manual's history
* Concept index::               Concept index
@end menu

@node    Introduction
@chapter Introduction

@menu
* Overview::                    GNU Parted and prerequisite knowledge
* Software Required::           GNU Parted's software dependencies
* Supported Platforms::         Where you can use GNU Parted
* License::                     What you may and may not do with GNU Parted
* Compiling::                   How to build GNU Parted
@end menu

@node Overview
@section Overview of GNU Parted
@cindex description of parted
@cindex overview
@cindex parted description
@cindex bugs, reporting
@cindex reporting bugs
@cindex contacting developers

GNU Parted is a program for creating and manipulating partition tables.

This documentation is written with the assumption that the reader
has some understanding of partitioning and file systems.

GNU Parted was designed to minimize the chance of data loss.  For
example, it was designed to avoid data loss during interruptions (like
power failure) and performs many safety checks.  However, there could
be bugs in GNU Parted, so you should back up your important files before
running Parted.

The GNU Parted homepage is @uref{https://www.gnu.org/software/parted}.  The
library and frontend themselves can be downloaded from
@uref{https://ftp.gnu.org/gnu/parted}.
You can also find a listing of mailing lists, notes for contributing and
more useful information on the web site.

Please send bug reports to @email{bug-parted@@gnu.org}.  When sending bug
reports, please include the version of GNU Parted.
Please include the output from these commands (for disk @file{/dev/hda}):

@example
@group
# @kbd{parted /dev/hda unit s print free}
@end group
@end example

Feel free to ask for help on this list --- just check that your question
isn't answered here first.  If you don't understand the documentation,
please tell us, so we can explain it better.  General philosophy is:
if you need to ask for help, then something needs to be fixed so you
(and others) don't need to ask for help.

Also, we'd love to hear your ideas :-)

@node Software Required
@section Software Required for the use of Parted
@cindex software dependencies
@cindex required software
@cindex libuuid
@cindex e2fsprogs
@cindex readline
@cindex gettext

If you're installing or compiling Parted yourself, you'll need to
have some other programs installed.  If you are compiling Parted,
you will need both the normal and devel packages of these programs
installed:

@itemize @bullet

@item GNU parted source is available either as a source tarball:

	@uref{https://git.savannah.gnu.org/gitweb/?p=parted.git}

or using git (See the README-hacking instructions):

	@uref{https://git.savannah.gnu.org/gitweb/?p=parted.git}

@item libuuid, part of the e2fsprogs package.  If you don't have this,
you can get it from:

	@uref{http://web.mit.edu/tytso/www/linux/e2fsprogs.html}

If you want to compile Parted and e2fsprogs, note that you will need to
@kbd{make install} and @kbd{make install-libs} e2fsprogs.

@item GNU Readline (optional), available from

	@uref{https://ftp.gnu.org/gnu/readline}

If you are compiling Parted, and you don't have readline, you can
disable Parted's readline support with the @kbd{--disable-readline}
option for @command{configure}.

@item GNU gettext (or compatible software) for compilation, if
internationalisation support is desired.

	@uref{https://ftp.gnu.org/gnu/gettext}

@end itemize

@node Supported Platforms
@section Platforms on which GNU Parted runs
@cindex supported platforms
@cindex platforms, supported

Hopefully, this list will grow a lot.  If you do not have one of these
platforms, then you can use a rescue disk and a static binary of GNU Parted.

@table @asis
@item GNU/Linux
Linux versions 2.0 and up, on Alpha, x86 PCs, PC98, Macintosh PowerPC, Sun hardware.

@item GNU/Hurd
@end table

@node License
@section Terms of distribution for GNU Parted
@cindex license terms
@cindex terms of distribution
@cindex gnu gpl
@cindex gpl

GNU Parted is free software, covered by the GNU General Public License
Version 3, or (at your option) any later version.  This should have been
included with the Parted distribution, in the COPYING file.  If not,
see <http://www.gnu.org/licenses/>.

Libparted is considered part of GNU Parted.  It is covered by the GNU
General Public License.  It is NOT released under the GNU Lesser General
Public License (LGPL).

@node Compiling
@section Building GNU Parted
@cindex compiling parted
@cindex building parted

If you want to compile GNU Parted, this is generally done with:

@example
@group
$ @kbd{./configure}
$ @kbd{make}
@end group
@end example

However, there are a few options for @command{configure}:

@table @code
@item --without-readline
turns off use of readline.  This is useful for making rescue disks,
etc., where few libraries are available.

@item --disable-debug
don't include assertions

@item --disable-nls
turns off native language support.  This is useful for use with old
versions of glibc, or a trimmed down version of glibc suitable for
rescue disks.

@item --disable-shared
turns off shared libraries.  This may be necessary for use with old
versions of GNU libc, if you get a compile error about a ``spilled
register''.  Also useful for boot/rescue disks.

@item --enable-discover-only
support only reading/probing (reduces size considerably)

@item --enable-mtrace
enable malloc() debugging

@item --enable-read-only
disable writing (for debugging)

@end table

@subsection Introduction
If you want to run GNU Parted on a machine without GNU/Linux installed,
or you want to modify a root or boot partition, use GParted Live:
@uref{https://gparted.org/livecd.php}.

@node    Using Parted
@chapter Using Parted
@cindex commands

@menu
* Partitioning::                    Disk partitioning in context
* Running Parted::                  Partitioning with Parted
* Invoking Parted::                 Parted's invocation options and commands
* Command explanations::            Full explanation of parted's commands
@end menu

@node Partitioning
@section Introduction to Partitioning
@cindex partitioning overview

Partitioning is the process of dividing a storage device into local
sections, called partitions, which help organize multiple filesystems
and their associated operating systems.

A storage device presents itself as a sequence of bytes, numbered
starting from zero and increasing until the maximum capacity of the
device is reached. Bytes are normally read and written a sector at a
time, rather than individually. Each sector contains a fixed number
of bytes, with the number determined by the device.

@example
+------------------------------------------------------------+
|            storage device with no partitions               |
+------------------------------------------------------------+
0 start                                                    end
@end example

In order to store multiple filesystems, a storage device can be divided
up in to multiple partitions. Each partition can be thought of as an
area which contains a real filesystem inside of it. To show where these
partitions are on the device a small table is written at the start,
shown as PT in the diagram below. This table is called a partition
table, or disklabel, and also stores the type of each partition and
some flags.

@example
+--+---------------+----------------+------------------------+
|PT|  Partition 1  |  Partition 2   |  Partition 3           |
+--+---------------+----------------+------------------------+
0 start                                                    end
@end example


@node Running Parted
@section Using GNU Parted
@cindex modes of use

Parted has two modes: command line and interactive.  Parted should
always be started with:

@example
# @kbd{parted @var{device}}
@end example

@noindent where @var{device} is the hard disk device to edit.  (If you're
lazy and omit the DEVICE argument, Parted will attempt to guess which
device you want.)

In command line mode, this is followed by one or more commands.  For
example:

@example
# @kbd{parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB }
@end example

@noindent Options (like @kbd{--help}) can only be specified on the
command line.

In interactive mode, commands are entered one at a time at a prompt, and
modify the disk immediately.  For example:

@example
(parted) @kbd{mklabel gpt}
(parted) @kbd{mkpart P1 ext3 1MiB 8MiB }
@end example

@noindent Unambiguous abbreviations are allowed.  For example, you can
type ``p'' instead of ``print'', and ``u'' instead of ``units''.
Commands can be typed either in English, or your native language (if
your language has been translated).  This may create ambiguities.
Commands are case-insensitive.

Numbers indicating partition locations can be whole numbers or decimals.
The suffix selects the unit, which may be one of those described in
@ref{unit}, except CHS and compact.  If no suffix is given, then the default
unit is assumed.  Negative numbers count back from the end of the disk,
with ``-1s'' indicating the sector at the end of the disk.
Parted will compute sensible
ranges for the locations you specify (e.g. a range of +/- 500 MB when you
specify the location in ``G''). Use the sector unit ``s'' to specify exact
locations.  With parted-2.4 and newer,
IEC binary units like ``MiB'', ``GiB'', ``TiB'', etc., specify
exact locations as well.
@xref{IEC binary units}.

If you don't give a parameter to a command, Parted will prompt you for it.
For example:

@example
(parted) @kbd{mklabel}
New disk label type? @kbd{gpt}
@end example

Parted will always warn you before doing something that is potentially
dangerous, unless the command is one of those that is inherently
dangerous (viz., rm, mklabel and mkpart).
Since many partitioning systems have complicated constraints, Parted will
usually do something slightly different to what you asked.  (For example,
create a partition starting at 10.352Mb, not 10.4Mb)
If the calculated values differ too much, Parted will ask you for
confirmation.


@node Invoking Parted
@section Command Line Options
@cindex options at invocation
@cindex commands, overview
@cindex invocation options

When invoked from the command line, Parted supports the following syntax:

@example
# @kbd{parted [@var{option}] @var{device} [@var{command} [@var{argument}]]}
@end example

Available options and commands follow.  For detailed explanations of the
use of Parted commands, see @ref{Command explanations}. Options begin
with a hyphen, commands do not:

Options:

@table @samp
@item -h
@itemx --help
display a help message

@item -l
@itemx --list
lists partition layout on all block devices

@item -m
@itemx --machine
display output in machine parseable format

@item -j
@itemx --json
display output in JSON format

@item -s
@itemx --script
never prompt the user

@item -f
@itemx --fix
automatically answer exceptions with "fix" in script mode, which is useful for:
GPT header not including full disk size; moving the backup GPT table to the end of the disk;
MAC fix missing partition map entry; etc.

@item -a alignment-type
@itemx --align alignment-type
Set alignment for newly created partitions, valid alignment types are:
none, cylinder, minimal and optimal.

@item -v
@itemx --version
display the version
@end table

@node Command explanations
@section Parted Session Commands
@cindex command syntax
@cindex detailed command listing
@cindex commands, detailed listing

GNU Parted provides the following commands:

@menu
* align-check::
* disk_set::
* disk_toggle::
* help::
* mklabel::
* mkpart::
* name::
* print::
* quit::
* rescue::
* resizepart::
* rm::
* select::
* set::
* toggle::
* type::
* unit::
@end menu

Note that after version 2.4, the following commands were removed:
check, cp, mkfs, mkpartfs, move, resize.

@node align-check
@subsection align-check
@cindex align-check, command description
@cindex command description, align-check

@deffn Command align-check @var{align-type} @var{n}

Determine whether the starting sector of partition @var{n}
meets the disk's selected alignment criteria.
@var{align-type} must be @samp{minimal}, @samp{optimal}
or an abbreviation.
When in script mode, if the partition does not meet the alignment
requirement, exit with status 1;  otherwise (including on older
kernels for which alignment data is not available), continue processing
any remaining commands.
Without @option{--script}, print either @samp{@var{N} aligned}
or @samp{@var{N} not aligned}.

Example:

@example
(parted) @kbd{align-check minimal 1}
1 aligned
@end example

@end deffn

@node disk_set
@subsection disk_set
@cindex disk_set, command description
@cindex command description, disk_set

@deffn Command disk_set @var{flag} @var{state}

Changes a flag on the disk.  A flag can be either ``on'' or ``off''.
Some or all of these flags will be available, depending on what disk
label you are using:

@table @samp

@item pmbr_boot
(GPT) - this flag enables the boot flag on the GPT's protective MBR
partition.

@end table

The disk's flags are displayed by the print command on the "Disk Flags:"
line.  They are also output as the last field of the disk information
in machine mode.

@example
(parted) @kbd{disk_set pmbr_boot on}
@end example

Set the PMBR's boot flag.
@end deffn

@node disk_toggle
@subsection disk_toggle
@cindex disk_toggle, command description
@cindex command description, disk_toggle

@deffn Command disk_toggle @var{flag}

Toggle the state of the disk flag.
@end deffn

@node help
@subsection help
@cindex help, command description
@cindex command description, help

@deffn Command help [@var{command}]

Prints general help, or help on @var{command}.

Example:

@example
(parted) @kbd{help mklabel}
@end example

Print help for the mklabel command.
@end deffn

@node mklabel
@subsection mklabel
@cindex mklabel, command description
@cindex command description, mkindex

@deffn Command mklabel @var{label-type}

Creates a new disk label, of type @var{label-type}.  The new disk label
will have no partitions.  This command (normally) won't technically
destroy your data, but it will make it basically unusable,
and you will need to use the rescue command (@pxref{Related information})
to recover any partitions.
Parted works on all partition tables.  @footnote{Everyone seems to
have a different word for ``disk label'' --- these are all the same
thing: partition table, partition map.}

@var{label-type} must be one of these supported disk labels:
@itemize @bullet
@item aix
@item amiga
@item bsd
@item dvh
@item gpt
@item loop (raw disk access)
@item mac
@item msdos
@item pc98
@item sun
@end itemize

Example:

@example
(parted) @kbd{mklabel msdos}
@end example

Create an MS-DOS disk label.  This is still the most common disk label for
PCs.
@end deffn

@node mkpart
@subsection mkpart
@cindex mkpart, command description
@cindex command description, mkpart

@deffn Command mkpart [@var{part-type} @var{name} @var{fs-type}] @var{start} @var{end}

Creates a new partition, @emph{without} creating a new file system on
that partition.  This is useful for creating partitions for file systems
(or LVM, etc.) that Parted doesn't support.  You may specify a file
system type, to set the appropriate partition code in the partition
table for the new partition.  @var{fs-type} is required for data
partitions (i.e., non-extended partitions).  @var{start} and @var{end}
are the offset from the beginning of the disk, that is, the ``distance''
from the start of the disk.

@var{part-type} is one of @samp{primary}, @samp{extended} or @samp{logical},
and may be specified only with @samp{msdos} or @samp{dvh} partition tables.
A @var{name} must be specified for a @samp{gpt} partition table.
Neither @var{part-type} nor @var{name} may be used with a @samp{sun}
partition table.

@var{fs-type} must be one of these supported file systems:
@itemize @bullet
@item btrfs
@item ext2, ext3, ext4
@item fat16, fat32
@item hfs, hfs+, hfsx
@item hp-ufs
@item jfs
@item linux-swap, linux-swap(new,old,v0,v1)
@item nilfs2
@item ntfs
@item reiserfs
@item sun-ufs
@item ufs
@item xfs
@end itemize

For example, the following creates a logical partition that will contain
an ext2 file system.  The partition will start at the beginning of the disk,
and end 692.1 megabytes into the disk.

@example
(parted) @kbd{mkpart logical 0.0 692.1}
@end example

Now, we will show how to partition a low-end flash
device (``low-end'', as of 2011/2012).
For such devices, you should use 4MiB-aligned partitions@footnote{
Cheap flash drives will be with us for a long time to
come, and, for them, 1MiB alignment is not enough.
Use at least 4MiB-aligned partitions.
For details, see Arnd Bergman's article,
@uref{http://lwn.net/Articles/428584/} and its many comments.}.
This command creates a tiny place-holder partition at the beginning, and
then uses all remaining space to create the partition you'll actually use:

@example
$ @kbd{parted -s /dev/sdX -- mklabel msdos \}
@kbd{    mkpart primary fat32 64s 4MiB \}
@kbd{    mkpart primary fat32 4MiB -1s}
@end example

Note the use of @samp{--}, to prevent the following @samp{-1s} last-sector
indicator from being interpreted as an invalid command-line option.
The above creates two empty partitions.  The first is unaligned and tiny,
with length less than 4MiB.
The second partition starts precisely at the 4MiB mark
and extends to the end of the device.

The next step is typically to create a file system in the second partition:

@example
$ @kbd{mkfs.vfat /dev/sdX2}
@end example


@end deffn

@node name
@subsection name
@cindex name, command description
@cindex command description, name

@deffn Command name @var{number} @var{name}

Sets the name for the partition @var{number} (GPT, Mac, MIPS and PC98 only).
The name can be placed in quotes. And depending on the shell may need to also
be wrapped in single quotes so that the shell doesn't strip off the double
quotes.

Example:

@example
(parted) @kbd{name 2 'Secret Documents'}
@end example

Set the name of partition 2 to `Secret Documents'.
@end deffn

@node print
@subsection print
@cindex print, command description
@cindex command description, print

@deffn Command print [@var{print-type}]

Displays the partition table on the device parted is editing, or
detailed information about a particular partition.

@var{print-type} is optional, and can be one of @samp{devices},
@samp{free}, @samp{list}, or @samp{all}.

@table @code

@item devices
display all active block devices

@item free
display information about free unpartitioned space on the current block device

@item list, all
display the partition tables of all active block devices

@end table

Example:

@example
@group
(parted) @kbd{print}
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 2684MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  1000MB  999MB   primary                  boot, lba
 2      1000MB  2300MB  1299MB  primary  ext2            lba
 3      2300MB  2500MB  200MB   primary  linux-swap(v1)  lba
(parted) @kbd{print free}
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 2684MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system     Flags
        16.4kB  1049kB  1032kB           Free Space
 1      1049kB  1000MB  999MB   primary                  boot, lba
 2      1000MB  2300MB  1299MB  primary  ext2            lba
 3      2300MB  2500MB  200MB   primary  linux-swap(v1)  lba
        2500MB  2684MB  185MB            Free Space

@end group
@end example
@end deffn

@node quit
@subsection quit
@cindex quit, command description
@cindex command description, quit

@deffn Command quit

Quits Parted.

@c RMK: generality: the following will apply to any operating system on
@c which parted will run, not only Linux-based ones.
@c clausen: yeah... just that the way hurd and linux work are totally
@c different, and it's actually very hard to speak in general.  Need to
@c discuss this more
It is only after Parted exits that the Linux kernel knows about the changes
Parted has made to the disks.  However, the changes caused by typing your
commands will @emph{probably} be made to the disk immediately after typing a
command.  However, the operating system's cache and the disk's hardware cache
may delay this.
@end deffn

@node rescue
@subsection rescue
@cindex rescue, command description
@cindex command description, rescue

@deffn Command rescue @var{start} @var{end}
Rescue a lost partition that used to be located approximately between
@var{start} and @var{end}.  If such a partition is found, Parted will
ask you if you want to create a partition for it.  This is useful if you
accidentally deleted a partition with parted's rm command, for example.

Example:

@example
(parted) @kbd{print}
@group
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 2684MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  1000MB  999MB   primary                  boot, lba
 2      1000MB  2300MB  1299MB  primary  ext4            lba
@end group
(parted) @kbd{rm}
Partition number? 2
(parted) @kbd{print}
@group
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 2684MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  1000MB  999MB   primary                  boot, lba
@end group
@end example

OUCH!  We deleted our ext4 partition!!!  Parted comes to the rescue...

@example
(parted) @kbd{rescue}
Start? 1000
End? 2684
Information: A ext4 primary partition was found at 1000MB ->
2300MB.  Do you want to add it to the partition table?
Yes/No/Cancel? @kbd{y}
(parted) @kbd{print}
@group
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 2684MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  1000MB  999MB   primary                  boot, lba
 2      1000MB  2300MB  1299MB  primary  ext4            lba
@end group
@end example

It's back!  :)

@end deffn

@node resizepart
@subsection resizepart
@cindex resizepart, command description
@cindex command description, resizepart

@deffn Command resizepart @var{number} @var{end}

Moves the @var{end} position of partition @var{number}.  Note that this
does not modify any filesystem present in the partition.  If you wish to
do this, you will need to use external tools, such as @command{resize2fs}.

When growing a partition you will want to grow the filesystem afterwards,
but when shrinking, you need to shrink the filesystem before the partition.
@end deffn

@node rm
@subsection rm
@cindex rm, command description
@cindex command description, rm


@deffn Command rm @var{number}

Removes the partition with number @var{number}.  If you accidentally delete
a partition with this command, use @pxref{rescue} to
recover it.  Also, you can use the gpart program (@pxref{Related information})
to recover damaged disk labels.

Note for msdos disk labels: if you delete a logical partition, all
logical partitions with a larger partition number will be renumbered.  For
example, if you delete a logical partition with a partition number of 6,
then logical partitions that were number 7, 8 and 9 would be renumbered
to 6, 7 and 8 respectively.  This means, for example, that you have to
update @file{/etc/fstab} on GNU/Linux systems.

Example:

@example
(parted) @kbd{rm 3}
@end example

Remove partition 3.
@end deffn

@node select
@subsection select
@cindex select, command description
@cindex command description, select

@deffn Command select @var{device}

Selects the device, @var{device}, for Parted to edit.  The device can
be a Linux hard disk device, a partition, a software RAID device,
LVM logical volume, or disk image file.

Example:

@example
(parted) @kbd{select /dev/hdb}
@end example

Select @file{/dev/hdb} (the slave device on the first ide controller on
Linux) as the device to edit.
@end deffn

@node set
@subsection set
@cindex set, command description
@cindex command description, set

@deffn Command set @var{number} @var{flag} @var{state}

Changes a flag on the partition with number @var{number}.  A flag can be
either ``on'' or ``off''.  Some or all of these flags will be available,
depending on what disk label you are using:

@table @samp

@item bios_grub
(GPT) - Enable this to record that the selected partition is a
GRUB BIOS partition.

@item legacy_boot
(GPT) - this flag is used to tell special purpose software that the GPT
partition may be bootable.

@item bls_boot
(MS-DOS, GPT) - Enable this to indicate that the selected partition is a
Linux Boot Loader Specification compatible /boot partition.

@item boot
(Mac, MS-DOS, PC98) - should be enabled if you want to boot off the
partition.  The semantics vary between disk labels.  For MS-DOS disk
labels, only one partition can be bootable.  If you are installing LILO
on a partition that partition must be bootable.
For PC98 disk labels, all ext2 partitions must be bootable (this is
enforced by Parted).

@item msftdata
(GPT) - This flag identifies partitions that contain Microsoft filesystems
(NTFS or FAT).  It may optionally be set on Linux filesystems to mimic the
type of configuration created by parted 3.0 and earlier, in which a
separate Linux filesystem type code was not available on GPT disks.  This
flag can only be removed within parted by replacing it with a competing
flag, such as boot or msftres.

@item msftres
(MS-DOS,GPT) - This flag identifies a "Microsoft Reserved" partition, which
is used by Windows.  Note that this flag should not normally be
set on Windows filesystem partitions (those that contain NTFS or FAT
filesystems).

@item irst
(MS-DOS, GPT) - this flag identifies an Intel Rapid Start Technology
partition.

@item esp
(MS-DOS, GPT) - this flag identifies a UEFI System Partition. On GPT
it is an alias for boot.

@item chromeos_kernel
(GPT) - this flag indicates a partition that can be used with the Chrome OS
bootloader and verified boot implementation.

@item lba
(MS-DOS) - this flag can be enabled to tell MS DOS, MS Windows 9x and
MS Windows ME based operating systems to use Linear (LBA) mode.

@item root
(Mac) - this flag should be enabled if the partition is the root device
to be used by Linux.

@item linux-home
(GPT) - Enable this to indicate that the selected partition is a
Linux /home partition.

@item swap
(MS-DOS, GPT, Mac) - this flag should be enabled if the partition is the
swap device to be used by Linux.

@item hidden
(MS-DOS, PC98) - this flag can be enabled to hide partitions from
Microsoft operating systems.

@item raid
(MS-DOS) - this flag can be enabled to tell linux the partition is a
software RAID partition.

@item LVM
(MS-DOS) - this flag can be enabled to tell linux the partition is a
physical volume.

@item PALO
(MS-DOS) - this flag can be enabled so that the partition can be used
by the Linux/PA-RISC boot loader, palo.

@item PREP
(MS-DOS, GPT) - this flag can be enabled so that the partition can be used
as a PReP boot partition on PowerPC PReP or IBM RS6K/CHRP hardware.

@item DIAG
(MS-DOS) - Enable this to indicate that a partition can be used
as a diagnostics / recovery partition.

@end table

The print command displays all enabled flags for each partition.

Example:

@example
(parted) @kbd{set 1 boot on}
@end example

Set the @samp{boot} flag on partition 1.
@end deffn

@node toggle
@subsection toggle
@cindex toggle, command description
@cindex command description, toggle

@deffn Command toggle @var{number} @var{flag}

Toggle the state of @var{flag} on partition @var{number}.

@end deffn

@node type
@subsection type
@cindex type, command description
@cindex command description, type

@deffn Command type @var{number} @var{id} or @var{uuid}

On MS-DOS set the type-id aka partition id to @var{id} on partition
@var{number}. The id is a value between 0x01 and 0xff, e.g. the ID for
Linux is 0x83. A list with some IDs is available at
@uref{https://en.wikipedia.org/wiki/Partition_type}.

On GPT set the type-uuid to @var{uuid} on partition
@var{number}. E.g. the UUID for Linux is
0fc63daf-8483-4772-8e79-3d69d8477de4. A list with some UUIDs is availabe
at @uref{https://en.wikipedia.org/wiki/GUID_Partition_Table}.

@end deffn

@node unit
@subsection unit
@cindex unit, command description
@cindex command description, unit

@deffn Command unit @var{unit}

Selects the current default unit that Parted will use to display
locations and capacities on the disk and to interpret those given
by the user if they are not suffixed by an @var{unit}.

@var{unit} may be one of:

@table @samp
@item s
sector (n bytes depending on the sector size, often 512)

@item B
byte

@item KiB
kibibyte (1024 bytes)

@item MiB
mebibyte (1048576 bytes)

@item GiB
gibibyte (1073741824 bytes)

@item TiB
tebibyte (1099511627776 bytes)

@item kB
kilobyte (1000 bytes)

@item MB
megabyte (1000000 bytes)

@item GB
gigabyte (1000000000 bytes)

@item TB
terabyte (1000000000000 bytes)

@item %
percentage of the device (between 0 and 100)

@item cyl
cylinders (related to the BIOS CHS geometry)

@item chs
cylinders, heads, sectors addressing (related to the BIOS CHS geometry)

@item compact
This is a special unit that defaults to megabytes for input, and picks a
unit that gives a compact human readable representation for output.
@end table

The default unit apply only for the output and when no unit is
specified after an input number.  Input numbers can be followed by
an unit (without any space or other character between them), in
which case this unit apply instead of the default unit for this
particular number, but CHS and cylinder units are not supported as
a suffix.  If no suffix is given, then the default unit is assumed.
Parted will compute sensible ranges for the locations you specify
(e.g., a range of +/- 500 MB when you specify the location in ``G'',
and a range of +/- 500 KB when you specify the location in ``M'')
and will select the nearest location in this range from the one you
wrote that satisfies constraints from both the operation, the
filesystem being worked on, the disk label, other partitions and so
on.  Use the sector unit ``s'' to specify exact locations (if they
do not satisfy all constraints, Parted will ask you for the nearest
solution).  Note that negative numbers count back from the end of
the disk, with ``-1s'' pointing to the last sector of the disk.

@anchor{IEC binary units}
Note that as of parted-2.4, when you specify start and/or end values
using IEC binary units like ``MiB'', ``GiB'', ``TiB'', etc., parted
treats those values as exact, and equivalent to the same number
specified in bytes (i.e., with the ``B'' suffix), in that it provides
@emph{no} ``helpful'' range of sloppiness.  Contrast that with
a partition start request of ``4GB'', which may actually resolve to
some sector up to 500MB before or after that point.
Thus, when creating a partition, you should prefer to specify
units of bytes (``B''), sectors (``s''), or IEC binary units like ``MiB'',
but not ``MB'', ``GB'', etc.

Example:

@example
@group
(parted) unit compact
(parted) print
Disk geometry for /dev/hda: 0kB - 123GB
Disk label type: msdos
Number  Start   End     Size    Type      File system  Flags
1       32kB    1078MB  1077MB  primary   reiserfs     boot
2       1078MB  2155MB  1078MB  primary   linux-swap
3       2155MB  123GB   121GB   extended
5       2155MB  7452MB  5297MB  logical   reiserfs
@end group
@group
(parted) unit chs print
Disk geometry for /dev/hda: 0,0,0 - 14946,225,62
BIOS cylinder,head,sector geometry: 14946,255,63.  Each cylinder
is 8225kB.
Disk label type: msdos
Number  Start       End         Type      File system  Flags
1       0,1,0       130,254,62  primary   reiserfs     boot
2       131,0,0     261,254,62  primary   linux-swap
3       262,0,0     14945,254,62 extended
5       262,2,0     905,254,62  logical   reiserfs
@end group
@group
(parted) unit mb print
Disk geometry for /dev/hda: 0MB - 122942MB
Disk label type: msdos
Number  Start   End     Size    Type      File system  Flags
1       0MB     1078MB  1077MB  primary   reiserfs     boot
2       1078MB  2155MB  1078MB  primary   linux-swap
3       2155MB  122935MB 120780MB extended
5       2155MB  7452MB  5297MB  logical   reiserfs
@end group
@end example

@end deffn

@node Related information
@chapter Related information
@cindex further reading
@cindex related documentation

If you want to find out more information, please see the GNU Parted web site.

These files in the Parted distribution contain further information:

@itemize @bullet

@item @kbd{ABOUT-NLS} - information about using Native Language Support, and the Free Translation Project.

@item @kbd{AUTHORS} - who wrote what.

@item @kbd{ChangeLog} - record of changes made to Parted.

@item @kbd{COPYING} - the GNU General Public License, the terms under which GNU Parted may be distributed.

@item @kbd{COPYING.DOC} - the GNU Free Documentation Licence, the term under
which Parted's documentation may be distributed.

@item @kbd{INSTALL} --- how to compile and install Parted, and most other free
software

@end itemize

@node Copying This Manual
@appendix Copying This Manual

@menu
* GNU Free Documentation License::  License for copying this manual
@end menu

@node GNU Free Documentation License
@appendixsec GNU Free Documentation License
@cindex FDL, GNU Free Documentation License
@include fdl.texi

@node History
@appendix This manual's history
@cindex  history of this manual

This manual was based on the file @kbd{USER} included in GNU Parted version
1.4.22 source distribution.  The GNU Parted source distribution is
available at @uref{https://ftp.gnu.org/gnu/parted}.

Initial Texinfo formatting by Richard M. Kreuter, 2002.

Maintainance by Andrew Clausen from 2002 to 2005 and by Leslie P. Polzer
from July 2005 onwards.

This manual is distributed under the GNU Free Documentation License,
version 1.1 or later, at your discretion, any later version published
by the Free Software Foundation; with no Invariant Sections, with no
Front-Cover Texts, and with no Back-Cover Texts.  @xref{Copying
This Manual}, for details.

@node Concept index
@unnumbered Index
@printindex cp

@bye

@ignore

Notes by RMK:
Notes on possible (unimplemented!) modifications:

The output samples from parted's print command, fdisk's p command, etc.,
might be made into tables (multi-column tables) to ensure spiffy formatting.

I'd like to find a way to make *entry: see *synonym type references in
the index, so, e.g., to refer people looking for Apple to Macintosh, and
PowerPC to Macintosh, etc.  Probably texinfo does this already; I dunno.

Notes by Leslie:

TODO:
     - add "version" command.
     - read through and correct.
     - role of FreeDOS?

@end ignore