Usage of sfdisk and parted in linux

Source: Internet
Author: User
Usage of sfdisk and parted in linux SFDISK: sfdisk [-? Tvx] [-d & lt; hard disk & gt;] [-g & lt; hard disk & gt;] [-l & lt; hard disk & gt;] [-s & lt; Partition & gt;] [-V & lt; hard disk & gt;] sfdisk is a hard disk partition tool program that displays partition settings, and check whether the partition is normal. Parameter: sfdisk and parted usage in www.2cto linux SFDISK: sfdisk [-? Tvx] [-d <硬盘> ] [-G <硬盘> ] [-L <硬盘> ] [-S <分区> ] [-V <硬盘> ] Sfdisk is a hard disk partition tool program that displays the partition settings and checks whether the partition is normal. Parameter: www.2cto.com -? Or -- help to display help. -D <硬盘> Displays the hard disk partition settings. -G <硬盘> Or -- show-geometry <硬盘> Display the CHS parameters of the hard disk. -L <硬盘> Settings of hard disk partitions after display. -S <分区> Displays the partition size, in blocks. -T or -- list-types displays the IDs of all file systems that sfdisk can recognize. -V or -- version displays version information. -V <硬盘> Or -- verify <硬盘> Check whether the hard disk partition is normal. -X or -- show-extend shows the logical partitions in the extended partitions. PARTED: during work, we will find that we cannot create partitions larger than 2 TB using the usual partitioning tool fdisk. is it not supported by linux? No. Currently, the Linux kernel supports Large Block Device, you can use a block device larger than 2 TB to create a partition larger than 2 TB using parted. assume that the/dev/sdb is 7 TB-sized storage device parted/dev/sdb print to view the partition information, find the option of the starting position command line mode. when you call command line mode, the Parted syntax is as follows: # parted [option] device [command [argument] has several options for you to use. Option: '-H'' -- help' displays the help information '-I' -- interactive 'enters the interaction mode'-V'' -- version', and displays the commands of the software version in Parted interactive mode. GNU Parted provides the following commands: check format: check number to check whether the specified file system has any errors .. Example: (parted) check 1 check the file system on partition 1. cp (copy) format: cp [from-device] from-number to-number completely copies the file system on the from-number partition to the to-number partition. All data on the partition to-number will be deleted. You can specify the device name of the source disk from-device to specify the hard disk where the source partition is located. This command supports the following file systems: * ext2, ext3 (the provided destination partition must be larger than the source partition) * fat16, fat32 * linux-swap (equivalent to executing the mkswap command in the target partition) * reiserfs (if the libreiserfs Library is installed) example: (parted) cp/dev/hdb 2 3. copy the content of the second partition on/dev/hdb to the Third Partition. Help (help) format: help [command] outputs a command help information example: (parted) help resize outputs the help information of the rezize command. Mklabel format: mklabel label-type creates a disk partition table of the label-type. The new partition table does not have any partitions. This command usually does not destroy your data, but it may make your data unreadable. You need to use the rescue command to restore partitions. For the rescue command usage, see the following. Parted can work on various partition tables. Label-type must be of the following types: * bsd * loop (raw disk access) * gpt * mac * msdos * pc98 * sun example: (parted) mklabel msdos creates a partition table in MS-DOS format. This is a very common operation for PCs. Mkfs format: mkfs number fs-type creates a specified file system on the specified partition. This command will destroy all data in the partition. This command supports the following file systems: * ext2 * fat16, fat32 * linux-swap * reiserfs (if the libreiserfs Library is installed) example: (parted) mkfs 2 fat32 creates a file system in the FAT32 format on the second partition. Mkpart (create new partition) format: mkpart part-type [fs-type] start end create a new partition. To create a non-extended partition, it is best to use fs-type to specify the file system. Start and end are the locations where the new partition starts and ends. Part-type is one of the following types: primary (primary partition), extended (extended partition), and logical (logical partition). extended partitions and logical partitions are only valid for msdos and dvh partition tables. Fs-type must be the following file system: * ext2 * fat16, fat32 * hfs, hfs +, hfsx * linux-swap * NTFS * reiserfs * ufs example: (parted) mkpart logical 0.0 692.1 creates a logical partition that contains the ext2 file system. its location ranges from the starting position of the disk (0.0) to 692.1M. Mkpartfs format: mkpartfs part-type fs-type start end creates a new partition and a file system is created on it. Similar to mkpart, the partition is located between begin and end. the default unit is MB .. Do not use this command to restore a deleted partition (mkpart should be used ). Part-type is one of the following types: primary (primary partition), extended (extended partition), and logical (logical partition). extended partitions and logical partitions are only valid for msdos and dvh partition tables. Fs-type must be the following file system: * ext2 * fat16, fat32 * linux-swap * reiserfs (if the libreiserfs Library is installed) example: (parted) mkpartfs logical ext2 440 670 creates a logical partition that contains an ex2 format file system. The starting position is 440 MB, and the ending position is 670 MB. Move format: move number start end this command can move the selected partition in the hard disk. Start specifies the starting position of a new partition. However, you cannot move one partition to another. That is to say, you can only move partitions in idle places. If you want to change the partition size, the command you need is resize. In addition, although the partition is moved, its partition number will not change. This command supports the following file systems: * ext2, ext3 (the provided destination partition must be larger than the source partition) * fat16, fat32 * linux-swap * reiserfs (if the libreiserfs Library is installed) example: (parted) move 2 150 M 500 M move the partition numbered 2 to the location of M to M on the hard disk. Name format: name number name is the name of the specified partition (only GPT, Mac, MIPS, and PC98 partitions are supported ). The name can be enclosed in quotation marks. Print (output information) format: print [number] outputs partition table information of the hard disk being operated by parted, or information of a specific partition. Quit (exit) format: quit exits Parted. only after Parted exits will the Linux kernel know that the disk settings have been changed. But as soon as you execute a command, the change will be immediately written to the disk. However, the disk cache may delay write operations. Rescue (recovery) format: rescue start end if you accidentally use the Parted rm command to delete a partition, this command can help you recover. You need to give the approximate start and end position of the accidentally deleted partition. Parted will search for the partition in the disk area you provided. if this partition is found, Parted will ask you if you want to re-create the partition. Resize (resize) format: resize number start end adjusts the size of the partition specified by the number. The start and end positions of a partition are determined by start and end. Resize does not change the partition number. Note: If you change the size of the extended partition, you must ensure that the new partition size can accommodate the logical partitions in it. In addition, you do not need to fragment the partition before adjusting the size. This command supports the following file systems: * ext2, ext3-limit: the start position of the new partition must be the same as the original start position. That is to say, you can only extend the partition size backward. * Fat16, fat32 * hfs, hfs +, and hfsx-restrictions: the start position of the new partition must be the same as the original start position. And the new end must be smaller than the original end. That is to say, you can only narrow down the partition. * Linux-swap * reiserfs (if the libreiserfs Library is installed) example: www.2cto.com (parted) resize 3 200 M 850 M change the size of the partition numbered 3. The new location is between 850 MB and MB. Rm (delete partition) format: rm number deletes the specified partition. If you accidentally delete a partition, you can use mkpart to save it (instead of mkpartds ). Note: If you are using a partition table in MSDOS format, if you delete a logical partition, the number of the logical partition following the partition will change accordingly. For example, if you delete a logical partition numbered 6, the numbers of the logical partitions numbered 7 and 8 will change to 6 and 7 respectively. In Linux. This means you may need to change the/etc/fstab file. For example, (parted) rm 3 deletes the partition numbered 3. Select (select device) format: select device select the disk device to be edited by Parted. This disk device can be a Linux hard disk device, a floppy disk, a soft RAID disk array, or an LVM Logical Volume. Example: (parted) select/dev/hdb as the device to be edited by Parted. Set (set Tag) format: set number flag state changes the tag of the partition specified by the number. Which tags are available depends on your partition table. Two states are marked: on (effective) or off (invalid ). 'Boot' (for Mac, MS-DOS, PC98 partition tables)-If you want to boot from a partition, you should set the boot flag for this partition to on. For MS-DOS partition tables, only one partition on a hard disk is bootable. If you load LILO to a partition, the partition must be bootable (that is, you should set the boot tag of the partition with LILO installed to on ). For a PC98 partition table, all ext3 partitions must be set as bootable. (Parted will force this operation) 'lba' (for MS-DOS partition tables)-this tag can tell systems such as ms dos, MS Windows 9x, and MS Windows ME to use lba (Logic Block Addressing) mode. 'Root' (for Mac partition tables)-if a partition is the root partition of the Linux system, enable this flag for the partition. 'Swap '(for Mac partition tables)-if a partition is a swap partition in Linux, enable this flag for the partition. 'Ddden '(for MS-DOS, PC98 partition tables)-enable this flag to hide a partition. (Only for Microsoft operating systems) www.2cto.com 'raid '(for MS-DOS partition tables)-enabling this tag can tell Linux systems that this is a soft raid disk array. 'Lvm '(for MS-DOS partition tables)-enabling this flag tells Linux systems that this is an LVM logic. Use the print command to display all usable tags. For example, (parted) set 1 boot on sets the boot tag of the partition numbered 1 to the on (effective) unit (set unit) format: unit: Select a unit that indicates the disk size for Parted. After that, all the numbers about the disk location (such as the start position of the partition) use this unit, and you don't need to give the unit suffix. (For example, if you select MB as the unit, 512 represents 512 MB, and you don't need to add more MB or something.) you can use the following unit: www.2cto.com's ': slice (usually the size of one slice is 512 bytes) 'B' byte 'KB' kilobyte (1000 bytes) 'mb' megabyte (1000000 bytes) 'GB' gigabyte (1000000000 bytes) 'TB' terabyte (1000000000000 bytes) '%' indicates the percentage of the entire disk device (obviously, this number must be between 0 and 100) 'cyl' cylinders (the specific position is related to the BIOS's CHS address), cylinders, head (heads), and sectors) (the specific location is related to the BIOS's CHS address) 'comput' is a strange unit. The input uses MB as the unit, and the output unit may be different, but it ensures that the output unit allows users to see the disk size at a glance, instead of making complex conversions silently. (For example. It uses 1 GB instead of 1024 MB, and 2 MB instead of 2048KB.) in general, Parted only uses the default unit for output, unless you do not provide the suffix of a number during input. You can add a unit after the entered number to replace the default unit (there is no space between the unit and number ).
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.