Last update at :2024-05-20,Edit by888u
parted command introduction
The parted command can divide a single partition into GPT format partitions larger than 2T, or it can divide ordinary MBR partitions. The fdisk command cannot divide partitions larger than 2T, so you cannot use fdisk to see the GPT format partitions divided by parted.
The Parted command is divided into two modes: command line mode and interactive mode.
- Command line mode: parted [option] device [command]. This mode can partition the disk directly under the command line, which is more suitable for programming applications.
- Interactive mode: parted [option] device is similar to using fdisk /dev/xxx
- MBR: Everyone is familiar with the MBR partition table (ie, master boot record). The maximum volume supported: 2T, and there are restrictions on partitions: up to 4 primary partitions or 3 primary partitions plus one extended partition
- GPT: GPT (GUID Partition Table). It is a newer disk partition table structure standard derived from the EFI standard and will be the main form of disk partitioning in the future. Compared with MBR partitioning method, it has the following advantages. Breaking through the MBR 4 primary partition limit, each disk supports up to 128 partitions. Supports partitions larger than 2T, and the maximum volume can reach 18EB.
parted is a tool that can partition and adjust partitions. It can create, destroy, move, copy, and adjust ext2 linux-swap fat fat32 reiserfs type partitions. It can create, adjust, and move Macintosh HFS partitions and detect jfs. , ntfs, ufs, xfs partition.
Usage: parted [options] [device [command [options...]...]]
options -h displays help information -l displays partitions on all block devices device operates on which block device, if not specified, the first block device is used command [options...] check partition does a simple check on the partition cp [source-device] source dest Copies the source partition on the source-device device to the dest partition of the current device mklabel label-type creates a new partition table type. Label-type can be: "bsd", "dvh", "gpt", "loop", "mac", "msdos", "pc98", or "sun" General PCs are all in msdos format. If the partition is larger than 2T, you need to use a gpt format partition table. mkfs partition fs-type creates a fs-type file system on the partition partition. fs-type can be: "fat16", "fat32", "ext2", "linux-swap", "reiserfs". Note that the ext3 format is not supported. The file system can only be partitioned first and then formatted using proprietary commands. mkpart part-type [fs-type] start end Create a partition of type part-type. Part-type can be: "primary", "logical", or "extended". If fs-type is specified, it will be done at the same time as the partition is created. format. start and end refer to the starting position of the partition, and the default unit is M. e.g.: mkpart primary 0 -1 0 indicates the beginning of the partition -1 indicates the end of the partition, which means dividing the entire hard disk space into primary partitions mkpartfs part-type fs-type start end creates a part-type partition of fs-type type. It is not recommended. It is best to format it with mke2fs after the mkpart partition is completed. name partition name Set a name for the partition. This setting can only be used on Mac, PC98, and GPT type partition tables. The name should be enclosed in quotes when setting. select device When there are multiple hard disks on the machine, select which hard disk to operate. resize partition start end resize partition rm partition deletes a partition rescue start end rescues a partition between stat and end unit unit In the previous partition, the default unit of the value in the partition is M. This parameter can change the default unit, "kB", "MB", "GB", "TB" move partition start end move partition partition print displays partition table information quit quit partedPractical drill
Initial disk information
The server adds three 4TB hard drives
fdisk -l Disk /dev/sdd: 4000.8 GB, 4000787030016 bytes 255 heads, 63 sectors/track, 486401 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb: 4000.8 GB, 4000787030016 bytes 255 heads, 63 sectors/track, 486401 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdc: 4000.8 GB, 4000787030016 bytes 255 heads, 63 sectors/track, 486401 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sda: 146.8 GB, 146815733760 bytes 255 heads, 63 sectors/track, 17849 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000081 Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 548 4194304 82 Linux swap / Solaris Partition 2 does not end on cylinder boundary. /dev/sda3 548 1070 4194304 83 Linux /dev/sda4 1070 17850 134780308 5 Extended /dev/sda5 1071 17850 134778880 83 LinuxTry to partition via fdisk command
fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x6001e0a2. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: The size of this disk is 4.0 TB (4000787030016 bytes). DOS partition table format can not be used on drives for volumes larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID partition table format (GPT). WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u')The fdisk command cannot partition hard disks larger than 2TB
Partition through parted command
Change partition table type
parted -s /dev/sdb mklabel gpt parted -s /dev/sdc mklabel gpt parted -s /dev/sdd mklabel gptdisk partition
parted /dev/sdb 'mkpart primary 0 -1' parted /dev/sdc 'mkpart primary 0 -1' parted /dev/sdd 'mkpart primary 0 -1'Format Partition
mkfs.ext4 -q /dev/sdb1 mkfs.ext4 -q /dev/sdc1 mkfs.ext4 -q /dev/sdd1Mount directory
mkdir /MFS_DATA1; mount /dev/sdb1 /MFS_DATA1;echo "mount /dev/sdb1 /MFS_DATA1" >> /etc/rc.local mkdir /MFS_DATA2; mount /dev/sdc1 /MFS_DATA2;echo "mount /dev/sdc1 /MFS_DATA2" >> /etc/rc.local mkdir /MFS_DATA3; mount /dev/sdd1 /MFS_DATA3;echo "mount /dev/sdd1 /MFS_DATA3" >> /etc/rc.localView disk mount
df-h Filesystem Size Used Avail Use% Mounted on /dev/sda5 127G 1.1G 120G 1% / tmpfs 7.8G 12K 7.8G 1% /dev/shm /dev/sda1 194M 29M 155M 16% /boot /dev/sda3 4.0G 254M 3.5G 7% /var /dev/sdb1 3.6T 196M 3.4T 1% /MFS_DATA1 /dev/sdc1 3.6T 196M 3.4T 1% /MFS_DATA2 /dev/sdd1 3.6T 196M 3.4T 1% /MFS_DATA3
Recommended site searches: domain name history, IP address query, domain name registration, cn domain name registration, Hong Kong vps host rental, domain name system, domain name error correction system, telecommunications server rental, asp host network IP address query,
发表评论