1、msdos分区
支持小于2T的硬盘,不支持大于2T的硬盘
有主分区,扩展分区,逻辑分区
如果使用fdisk命令给一个大于2T的msdos类型硬盘分区,只能给2T的部分分区,超过2T的部分不能使用,也就浪费了。
2、gpt分区
支持大小容量的硬盘
不区分主分区,扩展分区,逻辑分区,也没有4个分区数量的限制
一、通过parted创建分区
[root@kvm ~]#parted /dev/sdc
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)mklabel gpt //一般选择gpt、msdos
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? y
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) mkpart
Partition name? []? //回车
File system type? [ext2]? //回车
Start? 1049kB
End? 5G
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 5000MB 4999MB
(parted) resizepart 1 6G //增大分区为6G,resizepart 分区number 分区大小
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 6000MB 5999MB
(parted) resizepart 1 5G //调减小为5G,尽量不要减小分区,可能会丢失数据,如果要调整也要先备份数据
Warning: Shrinking a partition can cause data loss, are you sure you want to continue?
Yes/No?y
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 5000MB 4999MB
(parted) quit
Information: You may need to update /etc/fstab.
二、通过mkfs.ext4格式化分区文件系统,再mount挂载
[root@kvm ~]# mkfs.ext4 /dev/sdc1 //格式化分区文件系统为ext4
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
305216 inodes, 1220352 blocks
61017 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1249902592
38 block groups
32768 blocks per group, 32768 fragments per group
8032 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@kvm ~]# mount /dev/sdc1 /home //挂载到/home
[root@kvm ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 919724 0 919724 0% /dev
tmpfs 931520 0 931520 0% /dev/shm
tmpfs 931520 9724 921796 2% /run
tmpfs 931520 0 931520 0% /sys/fs/cgroup
/dev/mapper/centos-root 9349120 2135036 7214084 23% /
/dev/sda1 1038336 191268 847068 19% /boot
tmpfs 186304 0 186304 0% /run/user/0
/dev/sdc1 4673664 19064 4394148 1% /home
三、删除创建好文件系统的分区,通过rescue命令恢复
[root@kvm ~]#parted /dev/sdc
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 5000MB 4999MB ext4
(parted)rm 1
(parted)rescue 1049kB 5000M
searching for file systems... 1% (time left 01:23)Information: A ext4 primary partition was found at 1049kB -> 5000MB. Do you want to add it to the partition table?
Yes/No/Cancel?y
(parted)print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 5000MB 4999MB ext4
(parted)quit