Parted的用途及说明
parted用于对磁盘(或RAID磁盘)进行分区及管理,与fdisk分区工具相比,支持2TB以上的磁盘分区,并且允许调整分区的大小。
parted是一个用于硬盘分区或调整分区大小的工具。可以创建、清除、调整、移动和复制ext2、ext3、linux-swap、FAT、FAT32和reiserfs分区;也能创建、调整和移动苹果系统的HFS分区;还能检测jfs、ntfs、ufs和xfs分区。该工具常用于为新安装的操作系统创建空间,重新分配硬盘使用情况,在将数据拷贝到新硬盘的时候也常常使用。
使用实例
[deployer@localhost ~]$ sudo parted /dev/sdb # 交互式命令方式
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt # 定义分区表格式(常用的有msdos和gpt分区表格式,msdos不支持2TB以上容量的磁盘,大于2TB的磁盘选gpt分区表格式)
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) mkpart primary 0% 100%
(parted) quit
Information: You may need to update /etc/fstab.
[deployer@localhost ~]$ sudo fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c2c92
Device Boot Start End Blocks Id System
/dev/sda1 2048 6143 2048 83 Linux
/dev/sda2 * 6144 4200447 2097152 83 Linux
/dev/sda3 4200448 104857599 50328576 8e Linux LVM
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdb: 8796.1 GB, 8796093022208 bytes, 17179869184 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: F7A0B069-DBF3-44BA-8B18-D875798D29A8
# Start End Size Type Name
1 2048 17179867135 8T Microsoft basic primary
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdc: 5497.6 GB, 5497558138880 bytes, 10737418240 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: CA3959A8-B896-4284-9390-8BA638CA4981
# Start End Size Type Name
1 2048 10737416191 5T Microsoft basic primary
Disk /dev/mapper/centos-root: 47.2 GB, 47240445952 bytes, 92266496 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 4294 MB, 4294967296 bytes, 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[deployer@localhost ~]$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
268435456 inodes, 2147483136 blocks
107374156 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
65536 block groups
32768 blocks per group, 32768 fragments per group
4096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544, 1934917632
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[deployer@localhost ~]$ sudo mount /dev/sdb1 /Storage_8TB/
[deployer@localhost ~]$ sudo df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 12M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 44G 1.8G 43G 4% /
/dev/sda2 2.0G 150M 1.9G 8% /boot
tmpfs 378M 0 378M 0% /run/user/1000
/dev/sdb1 8.0T 93M 7.6T 1% /Storage_8TB