Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
DISKLABEL(8)		FreeBSD	System Manager's Manual		  DISKLABEL(8)

NAME
     disklabel -- read and write disk pack label

SYNOPSIS
     disklabel [-Acdtv]	[-h | -p unit] [-T file] disk
     disklabel -w [-Acdnv] [-T file] disk disktype [packid]
     disklabel -e [-Acdnv] [-T file] disk
     disklabel -E [-Acdnv] [-F|-f file]	[-T file] disk
     disklabel -R [-nv]	[-F|-f file] disk protofile

DESCRIPTION
     The disklabel utility can be used to install, examine, or modify the la-
     bel on a disk drive or pack.  The disk label contains information about
     disk characteristics (size, type, etc.) and the partition layout, stored
     on	the disk itself.  It is	used by	the operating system to	optimize disk
     I/O and locate the	filesystems resident on	the disk.

     disklabel supports	15 configurable	partitions, `a'	through	`p', excluding
     `c'.  The `c' partition describes the entire physical disk, is automati-
     cally created by the kernel, and cannot be	modified or deleted by
     disklabel.	 By convention,	the `a'	partition of the boot disk is the root
     partition,	and the	`b' partition of the boot disk is the swap partition,
     but all other letters can be used in any order for	any other partitions
     as	desired.

     The options are as	follows:

     -A	     Automatically allocate all	the disk space in the OpenBSD portion
	     of	the disk in the	recommended manner.  See AUTOMATIC DISK
	     ALLOCATION, below.

     -c	     Clear the system's	in-core	copy of	the label and update it	based
	     on	the on-disk label.

     -d	     Use the default label.  This ignores any existing OpenBSD disk
	     label on the disk.

     -E	     Use the built-in command-driven label editor described below.

     -e	     Edit an existing disk label using the editor specified in the
	     EDITOR environment	variable, or vi(1) if none is specified.

     -F	file
	     Write entries to file in fstab(5) format for any partitions for
	     which mount point information is known.  The entries will be
	     written using disklabel UIDs.  The	-F flag	is only	valid when
	     used in conjunction with the -E or	-R flags.  If file already ex-
	     ists, it will be overwritten.

     -f	file
	     The same as -F except that	entries	will be	written	using disk de-
	     vice names.

     -h	     Print partition sizes in human readable format.

     -n	     Make no permanent changes to the disklabel	(useful	for debugging
	     purposes).

     -p	unit
	     Print partition sizes in unit instead of sectors.	Valid units
	     are b(ytes), c(ylinders), k(ilobytes), m(egabytes), g(igabytes)
	     and t(erabytes).

     -R	     Restore a disk label that was formatted in	a prior	operation and
	     saved in an ASCII file.

     -T	file
	     Read the template for automatic allocation	from file instead of
	     using the builtin one.  See AUTOMATIC DISK	ALLOCATION below for
	     the format.

     -t	     Format the	label as a disktab(5) entry.

     -v	     Print additional information during operation (verbose mode).

     -w	     Write a standard label on the designated drive.

     disk    Specify the disk to operate on.  It can be	specified by its full
	     pathname, by an abbreviated disk form, or by its disklabel	UID.
	     In	its abbreviated	form, the path to the device, the `r' denoting
	     "raw device", and the partition letter, can all be	omitted.  For
	     example, the first	IDE disk can be	specified as either
	     /dev/rwd0c, /dev/wd0c, or wd0.

     disktype
	     Specify a disktype	entry from the disktab(5) database.

     packid  Specify a pack identification string for the device (see below).

     protofile
	     Used with the restore option (-R) to specify a file to read an
	     ASCII label from.

     The first form of the command (read) is used to examine the label on the
     named disk	drive.	It will	display	all of the parameters associated with
     the drive and its partition layout.  The kernel's in-core copy of the la-
     bel is displayed; if the disk has no label, or the	partition types	on the
     disk are incorrect, the kernel may	have constructed or modified the la-
     bel.

     The second	form of	the command (write) is used to write a standard	label
     on	the designated drive.  The drive parameters and	partitions are taken
     from that file.  If different disks of the	same physical type are to have
     different partitions, it will be necessary	to have	separate disktab en-
     tries describing each, or to edit the label after installation as de-
     scribed below.  The optional argument is a	pack identification string, up
     to	16 characters long.  The pack ID must be quoted	if it contains blanks.
     The existing label	will be	updated	via the	in-core	copy.

     In	the third form of the command (edit), the label	is read	from the in-
     core kernel copy and then supplied	to an editor for changes.  If no edi-
     tor is specified in an EDITOR environment variable, vi(1) is used.	 When
     the editor	terminates, the	formatted label	is reread and used to rewrite
     the disk label.

     The built-in label	editor (fourth form) provides a	simple interactive la-
     bel editor.  The editor prompt contains information about the state of
     the edit process.

	   disk*>

     Where disk	is the name of the disk	being edited, `*' means	that the in-
     memory copy of the	partition table	has been modified but not yet written
     to	disk and the `>' is replaced by	`#' when the editor is in expert mode.

     Some commands or prompts take an optional unit.  Available	units are `b'
     for bytes,	`c' for	cylinders, `k' for kilobytes, `m' for megabytes, `g'
     for gigabytes, and	`t' for	terabytes.  If no unit is given, the default
     is	to use sectors (usually	512 bytes).

     Quantities	are rounded to the nearest cylinder when units are specified
     for sizes (or offsets).  At prompts that request a	size, `*' may be en-
     tered to indicate the rest	of the available space,	`%' for	percentage of
     total, and	`&' for	percentage free.  Commands may be aborted by entering
     `^D' (Control-D).	Entering `^D' at the main prompt will exit the editor.

     The editor	commands are as	follows:

     ? | h	Display	help message with all available	commands.  There is
		also (simple) context-sensitive	help available at most
		prompts.

     A		Allocate all the disk space in the recommended manner.	See
		AUTOMATIC DISK ALLOCATION, below.

     a [part]	Add new	partition.  This option	adds a new partition to	the
		disk label.  If	no partition letter is specified (a-p),	the
		user will be prompted for one.

     b		Set OpenBSD disk boundaries.  This option tells	disklabel
		which parts of the disk	it is allowed to modify.  This option
		is probably only useful	for ports with fdisk(8)	partition ta-
		bles where the ending sector in	the MBR	is incorrect.  The
		user may enter `*' at the "Size" prompt	to indicate the	entire
		size of	the disk (minus	the starting sector).  This is useful
		for disks where	the fdisk partition table is incapable of
		storing	the real size.	Note: data may become corrupted	if
		boundaries are extended	such that they overlap with other res-
		ident operating	systems.

     c [part]	Change the size	of an existing partition.  If no partition is
		specified, the user will be prompted for one.  The new size
		may be in terms	of the aforementioned units and	may also be
		prefixed with `+' or `-' to change the size by a relative
		amount.

     D		Sets the disk label to the default values as reported by the
		kernel.	 This simulates	the case where there is	no disk	label.

     d [part]	Delete an existing partition (or `*' to	delete all parti-
		tions).	 If no partition is specified, the user	will be
		prompted for one.

     e		Edit drive parameters.	This option is used to set the follow-
		ing parameters:	disk type, a descriptive label string, sec-
		tors/track, tracks/cylinder, sectors/cylinder, number of
		cylinders, total sectors, rpm, and interleave.

     g [d | u]	Set disk geometry based	on what	the disk or user thinks	(the
		user geometry is simply	what the label said before disklabel
		made any changes).

     i		Change the disklabel UID, specified as a 16-character hexadec-
		imal string.  If set to	all zeros, a new UID will automati-
		cally be allocated when	the disklabel is written to disk.

     l [unit]	Print the disk label header.

     M		Display	this manual page.  The manual page is piped through
		the pager specified by the PAGER environment variable or
		'less' if PAGER	is not set.

     m [part]	Modify parameters for an existing partition.  If no partition
		is specified, the user will be prompted	for one.  This option
		allows the user	to change the filesystem type, starting	off-
		set, partition size, and mount point for the specified parti-
		tion.  If expert mode is enabled (see X	below),	then block
		fragment size, block size, and cylinders per group can also be
		modified.  Note	that not all parameters	are configurable for
		non-BSD	partitions.

     n [part]	Name the mount point for an existing partition.	 If no parti-
		tion is	specified, the user will be prompted for one.  This
		option is only valid if	disklabel was invoked with the -f
		flag.

     p [unit]	Print the current partition list.  If a	unit is	given, the
		size and offsets are displayed in terms	of the specified unit.
		If the unit is `*' it is automatically determined by the size
		of the smallest	partition.

     q		Quit the editor.  If any changes have been made, the user will
		be asked whether or not	to save	the changes to the on-disk la-
		bel.

     R [part]	Resize a partition in an automatically allocated label,	com-
		pacting	unused space between partitions	with a higher offset.
		The last partition will	be shrunk if necessary.	 Works only
		for automatically allocated labels with	no spoofed partitions.

     r		Recalculate free space.	 This command displays all the free
		areas on the disk and the total	number of free sectors.

     s [path]	Save the label to a file in ASCII format (suitable for loading
		via the	-R option).  If	no path	is specified, the user will be
		prompted for one.

     U		Undo all changes made since entering the editor.

     u		Undo (or redo) last change.  Entering u	once will undo the
		last change.  Entering it again	will restore the change.

     w		Write the label	to disk.  This option will commit any changes
		to the on-disk label.

     X		Toggle "expert mode".  By default, some	settings are reserved
		for experts only (such as the block and	fragment size on ffs
		partitions).  While in expert mode the command line prompt
		will end with `#' instead of `>'.

     x		Exit the editor	without	saving any changes to the on-disk la-
		bel.

     z		Zero out the existing partition	table and mount	point informa-
		tion, leaving only the 'c' partition.  The drive parameters
		are not	changed.

     In	the restore form of the	command	(fifth form), the prototype file used
     to	create the label should	be in the same format as that produced when
     reading or	editing	a label.  Comments are delimited by # and newline.

     Note that when a disk has no real BSD disklabel, the kernel creates a de-
     fault label so that the disk can be used.	This default label will	in-
     clude other partitions found on the disk if they are supported on your
     architecture.  For	example, on systems that support fdisk(8) partitions
     the default label will also include DOS and Linux partitions.  However,
     these entries are not dynamic, they are fixed at the time disklabel is
     run.  That	means that subsequent changes that affect non-OpenBSD parti-
     tions will	not be present in the default label, though they may be	up-
     dated by hand.  To	see the	default	label, run disklabel with the -d flag.
     disklabel can then	be run with the	-e flag	and any	entries	pasted as de-
     sired from	the default label into the real	one.

AUTOMATIC DISK ALLOCATION
     The -A option and the editor command A automatically create a disklabel
     with a set	of partitions suitable for a majority of OpenBSD installa-
     tions.  Any existing OpenBSD disklabel on the disk	is ignored, but	native
     partitions	that would normally be spoofed are preserved in	the disklabel,
     and are not modified during the allocation	process.

     Disk size determines the set of partitions	which are created.  Each par-
     tition is allocated space between a specified minimum and maximum.	 Ini-
     tially, each partition is allocated its minimum space; remaining space is
     split between the partitions according to the given percentages, up to
     their maximum allowed space.  Space left after all	partitions have
     reached their maximum size	is left	unallocated.  The sizes	below are ap-
     proximations, and may vary	from architecture to architecture.

     Disks >= 10 Gigabytes
	   /		    5% of disk.	 150M -	1G
	   swap		   10% of disk.	  80M -	2x max physical	memory
	   /tmp		    8% of disk.	 120M -	4G
	   /var		   13% of disk.	  80M -	2x size	of crash dump
	   /usr		   10% of disk.	1500M -	6G
	   /usr/X11R6	    3% of disk.	 384M -	1G
	   /usr/local	   15% of disk.	   1G -	20G
	   /usr/src	    2% of disk.	1300M -	2G
	   /usr/obj	    4% of disk.	   5G -	6G
	   /home	   30% of disk.	   1G -	300G

     Disks > 2.5 Gigabytes
	   /		    5% of disk.	 800M -	2G
	   swap		   10% of disk.	  80M -	2x max physical	memory
	   /usr		   78% of disk.	1300M -	3G
	   /home	    7% of disk.	 256M -	2G

     Disks > 700 Megabytes
	   /		   95% of disk.	700M - 4G
	   swap		    5% of disk.	  1M - 2x max physical memory

     A template	for the	automatic allocation can be passed to disklabel	using
     the -T option.  The template consists of one line per partition, with
     each line giving mount point, min-max size	range, and percentage of disk,
     space-separated.  Max can be unlimited by specifying '*'.	If only	mount
     point and min size	are given, the partition is created with that exact
     size.

	   /		   250M
	   swap		   80M-256M 10%
	   /tmp		   120M-4G 8%
	   /var		   80M-4G  13%
	   /usr		   1.5G-3G 5%
	   /usr/X11R6	   512M-1G 3%
	   /usr/local	   2G-10G  10%
	   /usr/src	   1G-2G   2%
	   /usr/obj	   1.3G-2G 4%
	   /home	   1G-*	   45%

FILES
     /etc/disktab		       Disk description	file.

EXAMPLES
     Display the in-core label for sd0 as obtained via /dev/rsd0c:

	   # disklabel sd0

     Create a label for	sd0 based on information for "sd2212" found in
     /etc/disktab:

	   # disklabel -w /dev/rsd0c sd2212 foo

     Read the on-disk label from a disk	with DUID 3eb7f9da875cb9ee, edit it
     and reinstall in-core as well as on-disk:

	   # disklabel -E 3eb7f9da875cb9ee

     Restore the on-disk and in-core label for sd0 from	information in
     mylabel:

	   # disklabel -R sd0 mylabel

DIAGNOSTICS
     The kernel	device drivers will not	allow the size of a disk partition to
     be	decreased or the offset	of a partition to be changed while it is open.
     Some device drivers create	a label	containing only	a single large parti-
     tion if a disk is unlabeled; thus,	the label must be written to the `a'
     partition of the disk while it is open.  This sometimes requires the de-
     sired label to be set in two steps, the first one creating	at least one
     other partition, and the second setting the label on the new partition
     while shrinking the `a' partition.

SEE ALSO
     disklabel(5), disktab(5), installboot(8), scan_ffs(8)

CAVEATS
     The maximum disk and partition size is 64PB.

     On	some machines, such as Sparc64,	partition tables may not exhibit the
     full functionality	described above.

FreeBSD	13.0			April 23, 2020			  FreeBSD 13.0

NAME | SYNOPSIS | DESCRIPTION | AUTOMATIC DISK ALLOCATION | FILES | EXAMPLES | DIAGNOSTICS | SEE ALSO | CAVEATS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=disklabel&sektion=8&manpath=OpenBSD+6.9>

home | help