Format с в линукс

Format с в линукс

format enables you to format, label, repair, and analyze disks on your system. Unlike previous disk maintenance programs, format runs under SunOS. Because there are limitations to what can be done to the system disk while the system is running, format is also supported within the memory-resident system environment. For most applications, however, running format under SunOS is the more convenient approach.

format first uses the disk list defined in data-file if the -x option is used. format then checks for the FORMAT_PATH environment variable, a colon-separated list of filenames and/or directories. In the case of a directory, format searches for a file named format.dat in that directory; a filename should be an absolute pathname, and is used without change. format adds all disk and partition definitions in each specified file to the working set. Multiple identical definitions are silently ignored. If FORMAT_PATH is not set, the path defaults to /etc/format.dat .

disk-list is a list of disks in the form c?t?d? or /dev/rdsk/c?t?d?s? . With the latter form, shell wildcard specifications are supported. For example, specifying /dev/rdsk/c2* causes format to work on all drives connected to controller c2 only. If no disk-list is specified, format lists all the disks present in the system that can be administered by format .

Removable media devices are listed only when users execute format in expert mode (option -e ). This feature is provided for backward compatibility. Use rmformat (1) for rewritable removable media devices.

OPTIONS

The following options are supported:

-d disk-name Specify which disk should be made current upon entry into the program. The disk is specified by its logical name (for instance, -d c0t1d0 ). This can also be accomplished by specifying a single disk in the disk list.

-e Enable SCSI expert menu. Note this option is not recommended for casual use.

-f command-file Take command input from command-file rather than the standard input. The file must contain commands that appear just as they would if they had been entered from the keyboard. With this option, format does not issue continue? prompts; there is no need to specify y(es) or n(o) answers in the command-file . In non-interactive mode, format does not initially expect the input of a disk selection number. The user must specify the current working disk with the -d disk-name option when format is invoked, or specify disk and the disk selection number in the command-file .

-l log-file Log a transcript of the format session to the indicated log-file , including the standard input, the standard output and the standard error.

-m Enable extended messages. Provides more detailed information in the event of an error.

-M Enable extended and diagnostic messages. Provides extensive information on the state of a SCSI device’s mode pages, during formatting.

-p partition-name Specify the partition table for the disk which is current upon entry into the program. The table is specified by its name as defined in the data file. This option can be used only if a disk is being made current, and its type is either specified or available from the disk label.

Читайте также:  Linux awk replace string

-s Silent. Suppress all of the standard output. Error messages are still displayed. This is generally used in conjunction with the -f option.

-t disk-type Specify the type of disk which is current upon entry into the program. A disk’s type is specified by name in the data file. This option can only be used if a disk is being made current as described above.

-x data-file Use the list of disks contained in data-file .

USAGE

When you invoke format with no options or with the -e , -l , -m , -M , or -s options, the program displays a numbered list of available disks and prompts you to specify a disk by list number. If the machine has more than 10 disks, press SPACE to see the next screenful of disks.

You can specify a disk by list number even if the disk is not displayed in the current screenful. For example, if the current screen shows disks 11-20, you can enter 25 to specify the twenty-fifth disk on the list. If you enter a number for a disk that is not currently displayed, format prompts you to verify your selection. If you enter a number from the displayed list, format silently accepts your selection.

After you specify a disk, format displays its main menu. This menu enables you to perform the following tasks:

analyze Run read, write, compare tests, and data purge. The data purge function implements the National Computer Security Center Guide to Understanding Data Remnance ( NCSC-TG-025 version 2) Overwriting Algorithm. See NOTES.

backup Search for backup labels.

cache Enable, disable, and query the state of the write cache and read cache. This menu item only appears when format is invoked with the -e option, and is only supported on SCSI devices..

current Display the device name, the disk geometry, and the pathname to the disk device.

defect Retrieve and print defect lists. This option is supported only on SCSI devices. IDE disks perform automatic defect management. Upon using the defect option on an IDE disk, you receive the message:

Controller does not support defect management or disk supports automatic defect management.

disk Choose the disk that will be used in subsequent operations (known as the current disk.)

fdisk Run the fdisk (1M) program to create a fdisk partition for Solaris software (x86 based systems only).

format Format and verify the current disk. This option is supported only on SCSI devices. IDE disks are pre-formatted by the manufacturer. Upon using the format option on an IDE disk, you receive the message:

Cannot format this drive. Please use your manufacturer-supplied formatting utility.

inquiry Display the vendor, product name, and revision level of the current drive.

label Write a new label to the current disk.

partition Create and modify slices.

quit Exit the format menu.

repair Repair a specific block on the disk.

save Save new disk and slice information.

type Select (define) a disk type.

verify Read and display labels. Print information such as the number of cylinders, alternate cylinders, heads, sectors, and the partition table.

volname Label the disk with a new eight character volume name.

Читайте также:  Загружаемые модули linux имеют следующие отличительные особенности

ENVIRONMENT VARIABLES

FORMAT_PATH a colon-separated list of filenames and/or directories of disk and partition definitions. If a directory is specified, format searches for the file format.dat in that directory.

FILES

/etc/format.dat default data file

ATTRIBUTES

See attributes (5) for descriptions of the following attributes:

ATTRIBUTE TYPEATTRIBUTE VALUE
AvailabilitySUNWcsu

SEE ALSO


x86 Only


WARNINGS

When the format function is selected to format the Maxtor 207MB disk, the following message displays:

Mode sense page(4) reports rpm value as 0, adjusting it to 3600

This is a drive bug that may also occur with older third party drives. The above message is not an error; the drive will still function correctly.

Cylinder 0 contains the partition table (disk label), which can be overwritten if used in a raw disk partition by third party software.

format supports writing EFI -compliant disk labels in order to support disks or LUN s with capacities greater than one terabyte. However, care should be exercised since many software components, such as filesystems and volume managers, are still restricted to capacities of one terabyte or less. See the System Administration Guide: Basic Administration for additional information.

By default, on an unlabeled disk, EFI labels will be written on disks larger than 2 TB. When format is invoked with the -e option, on writing the label, the label type can be chosen. Booting is not currently supported on a disk with an EFI label.

NOTES

format provides a help facility you can use whenever format is expecting input. You can request help about what information is expected by simply entering a question mark ( ? ) and format prints a brief description of what type of input is needed. If you enter a ? at the menu prompt, a list of available commands is displayed.

For SCSI disks, formatting is done with both Primary and Grown defects list by default. However, if only Primary list is extracted in defect menu before formatting, formatting will be done with Primary list only.

Changing the state of the caches is only supported on SCSI devices, and not all SCSI devices support changing or saving the state of the caches.

The NCSC-TG-025 algorithm for overwriting meets the DoD 5200.28-M ( ADP Security Manual) Eraser Procedures specification. The NIST Guidelines for Media Sanitization ( NIST SP 800-88) also reference this algorithm.

Источник

How to Format Disk Partitions in Linux

A disk partition must be formatted and mounted before use. The formatting process can also be done for several other reasons, such as changing the file system, fixing errors, or deleting all data.

In this tutorial, you will learn how to format and mount disk partitions in Linux using ext4, FAT32, or NTFS file system.

How to Format Disk Partitions in Linux

  • A system running Linux
  • A user account with sudo or root privileges
  • Access to a terminal window / command line (Activities >Search >Terminal)

Checking the Partitions

Before formatting, locate a partition you wish to format. To do so, run the lsblk command that displays block devices. Block devices are files that represent devices such as hard drives, RAM disks, USB drives, and CD/ROM drives.

The terminal prints out a list of all block devices as well as information about them:

  • NAME – Device names
  • MAJ:MIN – Major or minor device numbers
  • RM – Whether the device is removable (1 if yes, 0 if no)
  • SIZE – The size of the device
  • RO – Whether the device is read-only
  • TYPE – The type of the device
  • MOUNTPOINT – Device’s mount point

We will use the /dev/sdb1 partition as an example.

Locating partitions with lsblk command.

The lsblk command without additional options does not display information about the devices’ file systems.

To display a list containing file system information, add the -f option:

The terminal prints out the list of all block devices. The partitions that do not contain information on the file system in use are non-formatted partitions.

Locating non-formatted partitions with lsblk -f command.

Note: Consider learning how to create partitions in Linux.

Formatting Disk Partition in Linux

There are three ways to format disk partitions using the mkfs command, depending on the file system type:

The general syntax for formatting disk partitions in Linux is:

mkfs [options] [-t type fs-options] device [size]

Formatting Disk Partition with ext4 File System

1. Format a disk partition with the ext4 file system using the following command:

2. Next, verify the file system change using the command:

The terminal prints out a list of block devices.

3. Locate the preferred partition and confirm that it uses the ext4 file system.

The process of formatting disk partition using the ext4 file system in Linux.

Formatting Disk Partition with FAT32 File System

1. To format a disk with a FAT32 file system, use:

2. Again, run the lsblk command to verify the file system change and locate the preferred partition from the list.

Formatting disk partition using FAT32 file system in Linux.

Formatting Disk Partition with NTFS File System

1. Run the mkfs command and specify the NTFS file system to format a disk:

The terminal prints a confirmation message when the formatting process completes.

2. Next, verify the file system change using:

3. Locate the preferred partition and confirm that it uses the NFTS file system.

Formatting a partition with NTFS file system in Linux.

Mounting the Disk Partition in Linux

Before using the disk, create a mount point and mount the partition to it. A mount point is a directory used to access data stored in disks.

1. Create a mount point by entering:

2. After that, mount the partition by using the following command:

sudo mount -t auto /dev/sdb1 [mountpoint]

Note: Replace [mountpoint] with the preferred mount point (example: /usr/media ).

There is no output if the process completes successfully.

The process of creating mount point and mounting.

3. Verify if the partition is mounted using the following command:

Verifying formatting and mounting partition process.

Understanding the Linux File System

Choosing the right file system before formatting a storage disk is crucial. Each type of file system has different file size limitations or different operating system compatibility.

The most commonly used file systems are:

Their main features and differences are:

File System Supported File Size Compatibility Ideal Usage
FAT32 up to 4 GB Windows, Mac, Linux For maximum compatibility
NTFS 16 EiB – 1 KB Windows, Mac (read-only), most Linux distributions For internal drives and Windows system file
Ext4 16 GiB – 16 TiB Windows, Mac, Linux (requires extra drivers to access) For files larger than 4 GB

Note: Refer to our Introduction to Linux File System article to learn more about the evolution and features of different Linux file systems.

After following this tutorial, you should be able to format and mount a partition in Linux in various file systems. Partition manipulation is essential for efficient data management, and next, we recommend learning how to delete a partition in Linux.

Источник

Оцените статью
Adblock
detector