disklabel64 man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

DISKLABEL64(8)		  BSD System Manager's Manual		DISKLABEL64(8)

NAME
     disklabel64 — read and write 64 bit disk pack label

SYNOPSIS
     disklabel64 [-r] disk
     disklabel64 -w [-r] [-n] disk disktype/auto [packid]
     disklabel64 -e [-r] [-n] disk
     disklabel64 -R [-r] [-n] disk protofile
     disklabel64 [-NW] disk

     disklabel64 -B [-b boot1 -s boot2] disk [disktype/auto]
     disklabel64 -w -B [-n] [-b boot1 -s boot2] disk disktype/auto [packid]
     disklabel64 -R -B [-n] [-b boot1 -s boot2] disk protofile [disktype/auto]

DESCRIPTION
     The disklabel64 utility installs, examines or modifies a 64 bit label on
     a disk drive or pack.  When writing the label, it can be used to change
     the drive identification, the disk partitions on the drive, or to replace
     a damaged label.  There are several forms of the command that read (dis‐
     play), install or edit the label on a disk.  In addition, disklabel64 can
     install bootstrap code.

   Raw or in-core label
     The disk label resides close to or at the beginning of each disk slice.
     For faster access, the kernel maintains a copy in core at all times.  By
     default, most forms of the disklabel64 command access the in-core copy of
     the label.	 To access the raw (on-disk) copy, use the -r option.  This
     option allows a label to be installed on a disk without kernel support
     for a label, such as when labels are first installed on a system; it must
     be used when first installing a label on a disk.  The specific effect of
     -r is described under each command.

   Disk device name
     All disklabel64 forms require a disk device name, which should always be
     the raw device name representing the disk or slice.  DragonFly uses the
     following scheme for slice numbering: If the disk doesn't use GPT (typi‐
     cally laid out by gpt(8)), but e.g. MBR (typically laid out by fdisk(8)),
     then slice 0, e.g. da0s0, represents the entire disk regardless of any
     DOS partitioning.	Slice 0 is called the compatibility slice, and slice 1
     and onward, e.g. da0s1, represents a BSD slice.  If the disk does use
     GPT, then all slices are BSD slices, slice 0 isn't special, it is just
     the first slice on the disk.  You do not have to include the /dev/ path
     prefix when specifying the device.	 The disklabel64 utility will automat‐
     ically prepend it.

   Reading the disk label
     To examine the label on a disk drive, use disklabel64 without options:

     disklabel64 [-r] disk

     disk represents the raw disk in question, and may be in the form da0s1 or
     /dev/da0s1.  It will display all of the parameters associated with the
     drive and its partition layout.  Unless the -r flag is given, the ker‐
     nel's in-core copy of the label 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 label.	 If the -r flag is given, disklabel64
     reads the label from the raw disk and displays it.	 Both versions are
     usually identical except in the case where a label has not yet been ini‐
     tialized or is corrupt.

   Writing a standard label
     To write a standard label, use the form

     disklabel64 -w [-r] [-n] disk disktype/auto [packid]

     The required arguments to disklabel64 are the drive to be labeled and the
     drive type as described in the disktab(5) file.  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 entries describing each, or to edit the label after
     installation as described below.  The optional argument is a pack identi‐
     fication string, up to 16 characters long.	 The pack id must be quoted if
     it contains blanks.

     If the -n flag is given, no data will be written to the device, and
     instead the disklabel that would have been written will be printed to
     stdout.

     If the -r flag is given, the disk sectors containing the label and boot‐
     strap will be written directly.  A side-effect of this is that any exist‐
     ing bootstrap code will be overwritten and the disk rendered unbootable.
     See the boot options below for a method of writing the label and the
     bootstrap at the same time.  If -r is not specified, the existing label
     will be updated via the in-core copy and any bootstrap code will be unaf‐
     fected.  If the disk does not already have a label, the -r flag must be
     used.  In either case, the kernel's in-core label is replaced.

     For a virgin disk that is not known to disktab(5), disktype can be speci‐
     fied as auto.  In this case, the driver is requested to produce a virgin
     label for the disk.  This might or might not be successful, depending on
     whether the driver for the disk is able to get the required data without
     reading anything from the disk at all.  It will likely succeed for all
     SCSI disks, most IDE disks, and vnode devices.  Writing a label to the
     disk is the only supported operation, and the disk itself must be pro‐
     vided as the canonical name, i.e. not as a full path name.

     For most harddisks, a label based on percentages for most partitions (and
     one partition with a size of ‘*’) will produce a reasonable configura‐
     tion.

     PC-based systems have special requirements in order for the BIOS to prop‐
     erly recognize a DragonFly disklabel.  Older systems may require what is
     known as a “dangerously dedicated” disklabel, which creates a fake DOS
     partition to work around problems older BIOSes have with modern disk
     geometries.  On newer systems you generally want to create a normal DOS
     partition using fdisk and then create a DragonFly disklabel within that
     slice.  This is described later on in this page.

     Installing a new disklabel does not in of itself allow your system to
     boot a kernel using that label.  You must also install boot blocks, which
     is described later on in this manual page.

   Editing an existing disk label
     To edit an existing disk label, use the form

     disklabel64 -e [-r] [-n] disk

     This command reads the label from the in-core kernel copy, or directly
     from the disk if the -r flag is also specified.  The label is written to
     a file in ASCII and then supplied to an editor for changes.  If no editor
     is specified in an EDITOR environment variable, vi(1) is used.  When the
     editor terminates, the label file is used to rewrite the disk label.
     Existing bootstrap code is unchanged regardless of whether -r was speci‐
     fied.  If -n is specified, no data will be written to the device, and
     instead the disklabel that would have been written will be printed to
     stdout.  This is useful to see how a partitioning scheme will work out
     for a specific disk.

   Restoring a disk label from a file
     To restore a disk label from a file, use the form

     disklabel64 -R [-r] [-n] disk protofile

     disklabel64 is capable of restoring a disk label that was previously
     saved in a file in ASCII format.  The prototype file used to create the
     label should be in the same format as that produced when reading or edit‐
     ing a label.  Comments are delimited by ‘#’ and newline.  As when writing
     a new label, any existing bootstrap code will be clobbered if -r is spec‐
     ified and will be unaffected otherwise.  See the boot options below for a
     method of restoring the label and writing the bootstrap at the same time.
     If -n is used, no data will be written to the device, and instead the
     disklabel that would have been written will be printed to stdout.	This
     is useful to see how a partitioning scheme will work out for a specific
     disk.

   Enabling and disabling writing to the disk label area
     By default, it is not possible to write to the disk label area at the
     beginning of a disk.  The disk driver arranges for write(2) and similar
     system calls to return EROFS on any attempt to do so.  If you need to
     write to this area (for example, to obliterate the label), use the form

     disklabel64 -W disk

     To disallow writing to the label area after previously allowing it, use
     the command

     disklabel64 -N disk

   Installing bootstraps
     The final three forms of disklabel64 are used to install bootstrap code,
     which allows boot from a HAMMER(5) or UFS(5) file system.	If you are
     creating a “dangerously-dedicated” slice for compatibility with older PC
     systems, you generally want to specify the compatibility slice, such as
     da0s0.  If you are creating a label within an existing DOS slice, you
     should specify the slice name such as da0s1.  Making a slice bootable can
     be tricky.	 If you are using a normal DOS slice you typically install (or
     leave) a standard MBR on the base disk and then install the DragonFly
     bootblocks in the slice.

     disklabel64 -B [-b boot1 -s boot2] disk [disktype/auto]

     This form installs the bootstrap only.  It does not change the disk
     label.  You should never use this command on the compatibility slice
     unless you intend to create a “dangerously-dedicated” disk, such as
     da0s0.  This command is typically run on a BSD slice such as da0s1.

     disklabel64 -w -B [-n] [-b boot1 -s boot2] disk disktype/auto [packid]

     This form corresponds to the “write label” command described above.  In
     addition to writing a new volume label, it also installs the bootstrap.
     If run on the compatibility slice this command will create a
     “dangerously-dedicated” label.  This command is normally run on a BSD
     slice rather than the compatibility slice.	 If -n is used, no data will
     be written to the device, and instead the disklabel that would have been
     written will be printed to stdout.

     disklabel64 -R -B [-n] [-b boot1 -s boot2] disk protofile [disktype/auto]

     This form corresponds to the “restore label” command described above.  In
     addition to restoring the volume label, it also installs the bootstrap.
     If run on the compatibility slice this command will create a
     “dangerously-dedicated” label.  This command is normally run on a BSD
     slice rather than the compatibility slice.

     The bootstrap commands always access the disk directly, so it is not nec‐
     essary to specify the -r flag.  If -n is used, no data will be written to
     the device, and instead the disklabel that would have been written will
     be printed to stdout.

     The bootstrap code is comprised of two boot programs.  Specify the name
     of the boot programs to be installed in one of these ways:

     1.	  Specify the names explicitly with the -b and -s flags.  -b indicates
	  the primary boot program and -s the secondary boot program.  The
	  boot programs are normally located in /boot.

     2.	  If the -b and -s flags are not specified, but disktype was speci‐
	  fied, the names of the programs are taken from the “b0” and “b1”
	  parameters of the disktab(5) entry for the disk if the disktab entry
	  exists and includes those parameters.

     3.	  Otherwise, the default boot image names are used: /boot/boot1_64 and
	  /boot/boot2_64 for the standard stage1 and stage2 boot images.

   Initializing/Formatting a bootable disk from scratch
     To initialize a disk from scratch the following sequence is recommended.
     Please note that this will wipe everything that was previously on the
     disk, including any non-DragonFly slices.

     1.	  Use gpt(8) or fdisk(8) to initialize the hard disk, and create a GPT
	  or MBR slice table, referred to as the “partition table” in DOS.

     2.	  Use disklabel64 or disklabel32(8) to define partitions on DragonFly
	  slices created in the previous step.

     3.	  Finally use newfs_hammer(8) or newfs(8) to create file systems on
	  new partitions.

     A typical partitioning scheme would be to have an ‘a’ partition of
     approximately 512MB to hold the root file system, a ‘b’ partition for
     swap (usually 4GB), a ‘d’ partition for /var (usually 2GB), an ‘e’ parti‐
     tion for /var/tmp (usually 2GB), an ‘f’ partition for /usr (usually
     around 4GB), and finally a ‘g’ partition for /home (usually all remaining
     space).  If you are tight on space all sizes can be halved.  Your mileage
     may vary.

	   gpt create da0
	   gpt add da0
	   disklabel64 -B -r -w da0s0 auto
	   disklabel64 -e da0s0

ALIGNMENT
     When a virgin disklabel64 is laid down a DragonFly 2.5 or later kernel
     will align the partition start offset relative to the physical drive
     instead of relative to the slice start.  This overcomes the issue of
     fdisk creating a badly aligned slice by default.  The kernel will use a
     1MiB (1024 * 1024 byte) alignment.	 The purpose of this alignment is to
     match swap and cluster operations against the physical block size of the
     underlying device.

     Even though nearly all devices still report a logical sector size of 512,
     newer hard drives are starting to use larger physical sector sizes and,
     in particular, solid state drives (SSDs) use a physical block size of 64K
     (SLC) or 128K (MLC).  We choose a 1 megabyte alignment to cover our bases
     down the road.  64-bit disklabels are not designed to be put on ultra-
     tiny storage devices.

     It is worth noting that aligning cluster operations is particularly
     important for SSDs and doubly so when swapcache(8) is used with a SSD.
     Swapcache is able to use large bulk writes which greatly reduces the
     degree of write magnification on SSD media and it is possible to get
     upwards of 5x more endurance out of the device than the vendor spec sheet
     indicates.

FILES
     /boot/boot1_64  Default stage1 boot image.
     /boot/boot2_64  Default stage2 boot image.
     /etc/disktab    Disk description file.

SAVED FILE FORMAT
     The disklabel64 utility uses an ASCII version of the label when examin‐
     ing, editing, or restoring a disk label.  The format is:

	 # /dev/ad4s4:
	 #
	 # Informational fields calculated from the above
	 # All byte equivalent offsets must be aligned
	 #
	 # boot space:	    32768 bytes
	 # data space:	121790552 blocks # 118936.09 MB (124713525248 bytes)
	 #
	 diskid: 5e3ef4db-4e24-11dd-8318-010e0cd0bad1
	 label:
	 boot2 data base:      0x000000001000
	 partitions data base: 0x000000009000
	 partitions data stop: 0x001d0981f000
	 backup label:	       0x001d0981f000
	 total size:	       0x001d09820000	 # 118936.12 MB
	 alignment: 4096
	 display block size: 1024	 # for partition display only

	 16 partitions:
	 #	    size     offset    fstype	fsuuid
	   a:	  524288	  0    4.2BSD	 #     512.000MB
	   b:	 4194304     524288	 swap	 #    4096.000MB
	   d:	 2097152    4718592    4.2BSD	 #    2048.000MB
	   e:	 2097152    6815744    4.2BSD	 #    2048.000MB
	   f:	 4194304    8912896    4.2BSD	 #    4096.000MB
	   g:	 4194304   13107200    4.2BSD	 #    4096.000MB
	   h:	94003288   17301504    HAMMER	 #   91800.086MB
	   i:	 5242880  111304792	  ccd	 #    5120.000MB
	   j:	 5242880  116547672	vinum	 #    5120.000MB
	   a-stor_uuid: 4370efdb-4e25-11dd-8318-010e0cd0bad1
	   b-stor_uuid: 4370eff4-4e25-11dd-8318-010e0cd0bad1
	   d-stor_uuid: 4370f00b-4e25-11dd-8318-010e0cd0bad1
	   e-stor_uuid: 4370f024-4e25-11dd-8318-010e0cd0bad1
	   f-stor_uuid: 4370f03a-4e25-11dd-8318-010e0cd0bad1
	   g-stor_uuid: 4370f053-4e25-11dd-8318-010e0cd0bad1
	   h-stor_uuid: 4370f06a-4e25-11dd-8318-010e0cd0bad1
	   i-stor_uuid: 4370f083-4e25-11dd-8318-010e0cd0bad1
	   j-stor_uuid: 4370f099-4e25-11dd-8318-010e0cd0bad1

     Lines starting with a ‘#’ mark are comments.  The specifications which
     can be changed are:

     label is an optional label, set by the packid option when writing a
     label.

     the partition table is the UNIX partition table, not the DOS partition
     table described in fdisk(8).

     The partition table can have up to 16 entries.  It contains the following
     information:

     #	     The partition identifier is a single letter in the range ‘a’ to
	     ‘p’.

     size    The size of the partition in sectors, K (kilobytes - 1024), M
	     (megabytes - 1024*1024), G (gigabytes - 1024*1024*1024), % (per‐
	     centage of free space after removing any fixed-size partitions),
	     * (all remaining free space after fixed-size and percentage par‐
	     titions).	Lowercase versions of K, M, and G are allowed.	Size
	     and type should be specified without any spaces between them.

	     Example: 2097152, 1G, 1024M and 1048576K are all the same size
	     (assuming 512-byte sectors).

     offset  The offset of the start of the partition from the beginning of
	     the drive in sectors, or * to have disklabel64 calculate the cor‐
	     rect offset to use (the end of the previous partition plus one.

     fstype  Describes the purpose of the partition.  The example shows all
	     currently used partition types.  For UFS(5) file systems, use
	     type 4.2BSD.  For HAMMER(5) file systems, use type HAMMER.	 For
	     ccd(4) partitions, use type ccd.  For Vinum drives, use type
	     vinum.  Other common types are swap and unused.  The disklabel64
	     utility also knows about a number of other partition types, none
	     of which are in current use.  (See fstypenames in <sys/dtype.h>
	     for more details).

     The remainder of the line is a comment and shows the size of the parti‐
     tion in MB.

EXAMPLES
	   disklabel64 da0s1

     Display the in-core label for the first slice of the da0 disk, as
     obtained via /dev/da0s1.  (If the disk is “dangerously-dedicated”, the
     compatibility slice name should be specified, such as da0s0.)

	   disklabel64 da0s1 > savedlabel

     Save the in-core label for da0s1 into the file savedlabel.	 This file can
     be used with the -R option to restore the label at a later date.

	   disklabel64 -w -r /dev/da0s1 da2212 foo

     Create a label for da0s1 based on information for “da2212” found in
     /etc/disktab.  Any existing bootstrap code will be clobbered and the disk
     rendered unbootable.

	   disklabel64 -e -r da0s1

     Read the on-disk label for da0s1, edit it, and reinstall in-core as well
     as on-disk.  Existing bootstrap code is unaffected.

	   disklabel64 -e -r -n da0s1

     Read the on-disk label for da0s1, edit it, and display what the new label
     would be (in sectors).  It does not install the new label either in-core
     or on-disk.

	   disklabel64 -r -w da0s1 auto

     Try to auto-detect the required information from da0s1, and write a new
     label to the disk.	 Use another disklabel64 -e command to edit the parti‐
     tioning information.

	   disklabel64 -R da0s1 savedlabel

     Restore the on-disk and in-core label for da0s1 from information in
     savedlabel.  Existing bootstrap code is unaffected.

	   disklabel64 -R -n da0s1 label_layout

     Display what the label would be for da0s1 using the partition layout in
     label_layout.  This is useful for determining how much space would be
     allotted for various partitions with a labelling scheme using %-based or
     * partition sizes.

	   disklabel64 -B da0s1

     Install a new bootstrap on da0s1.	The boot code comes from
     /boot/boot1_64 and possibly /boot/boot2_64.  On-disk and in-core labels
     are unchanged.

	   disklabel64 -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212

     Install a new label and bootstrap.	 The label is derived from disktab
     information for “da2212” and installed both in-core and on-disk.  The
     bootstrap code comes from the files newboot1 and newboot2.

	   dd if=/dev/zero of=/dev/da0 bs=512 count=32
	   fdisk -BI da0
	   dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
	   disklabel64 -w -B da0s1 auto
	   disklabel64 -e da0s1

     Completely wipe any prior information on the disk, creating a new
     bootable disk with a DOS partition table containing one “whole-disk”
     slice.  Then initialize the slice, then edit it to your needs.  The dd
     commands are optional, but may be necessary for some BIOSes to properly
     recognize the disk.

	   disklabel64 -W da0s1
	   dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
	   disklabel -r -w da0s1 auto
	   disklabel -N da0s1

     Completely wipe any prior information on the slice, changing label format
     to 32 bit.	 The wiping is needed as disklabel and disklabel64, as a
     safety measure, won't do any operations if label with other format is
     already installed.

     This is an example disklabel that uses some of the new partition size
     types such as %, M, G, and *, which could be used as a source file for

	   disklabel64 -R ad0s1 new_label_file

	 # /dev/ad4s4:
	 #
	 # Informational fields calculated from the above
	 # All byte equivalent offsets must be aligned
	 #
	 # boot space:	    32768 bytes
	 # data space:	121790552 blocks # 118936.09 MB (124713525248 bytes)
	 #
	 diskid: b1db58a3-4e26-11dd-8318-010e0cd0bad1
	 label:
	 boot2 data base:      0x000000001000
	 partitions data base: 0x000000009000
	 partitions data stop: 0x001d0981f000
	 backup label:	       0x001d0981f000
	 total size:	       0x001d09820000	 # 118936.12 MB
	 alignment: 4096
	 display block size: 1024	 # for partition display only

	 16 partitions:
	 #	    size     offset    fstype	fsuuid
	   a:	    512M	  0    4.2BSD
	   b:	      4G	  *	 swap
	   d:	      2G	  *    4.2BSD
	   e:	   2048M	  *    4.2BSD
	   f:	      4G	  *    4.2BSD
	   g:	      4G	  *    4.2BSD
	   h:	       *	  *    HAMMER
	   i:	      5g	  *	  ccd
	   j:	   5120m	  *	vinum

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
     desired 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
     dd(1), uuid(3), ccd(4), disklabel64(5), disktab(5), boot0cfg(8),
     diskinfo(8), disklabel32(8), fdisk(8), gpt(8), newfs(8), newfs_hammer(8),
     vinum(8)

BUGS
     For the i386 architecture, the primary bootstrap sector contains an
     embedded fdisk table.  The disklabel64 utility takes care to not clobber
     it when installing a bootstrap only (-B), or when editing an existing
     label (-e), but it unconditionally writes the primary bootstrap program
     onto the disk for -w or -R, thus replacing the fdisk table by the dummy
     one in the bootstrap program.  This is only of concern if the disk is
     fully dedicated, so that the BSD disklabel starts at absolute block 0 on
     the disk.

     The disklabel64 utility does not perform all possible error checking.
     Warning is given if partitions overlap; if an absolute offset does not
     match the expected offset; if a partition runs past the end of the
     device; and a number of other errors; but no warning is given if space
     remains unused.

BSD			      September 28, 2009			   BSD
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net