1. Linux系统分区表
分区表 | 介绍 |
---|---|
MBP分区表 | 支持最大分区2TB;最多支持4个分区,或三个主分区一个扩展分区 |
GPT分区表 | 支持18EB;做多支持128个分区,其中1个系统保留分区,127个用户自定义分区| |
而fdisk命令进行分区,只能建立MBP分区表
而parted命令可以使用GPT分区表,但是不支持ext3、ext4等文件系统
2. 使用parted命令进行分区
[root@localhost disk1]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
#
mkpart PART-TYPE [FS-TYPE] START END make a partition
#创建一个分区
name NUMBER NAME name partition NUMBER as NAME
#
print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all
found partitions, or a particular partition
#显示分区表、活动设备、空闲空间、所有分区
quit exit program
#退出
rescue START END rescue a lost partition near START and END
#修饰丢失分区
resizepart NUMBER END resize partition NUMBER
#修改分区大小
rm NUMBER delete partition NUMBER
#删除分区
select DEVICE choose the device to edit
#选择要编辑的设备
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
#改变分区标记
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
#切换分区表状态
unit UNIT set the default unit to UNIT
#设置默认单位
version display the version number and copyright information of GNU Parted
#显示版本
(parted) print
#打印分区状态
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
1 1049kB 2149MB 2147MB primary ext4
2 2149MB 21.5GB 19.3GB extended
5 2150MB 4297MB 2147MB logical ext4
(parted) mklabel gpt
#建立GPT分区表
警告: 正在使用 /dev/sdb 上的分区。
忽略/Ignore/放弃/Cancel? Ignore
警告: 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
错误: Partition(s) 1, 5 on /dev/sdb have been written, but we have been unable to inform the kernel of the
change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should
reboot now before making further changes.
忽略/Ignore/放弃/Cancel? Ignore
(parted) print
#打印分区状态
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
(parted) quit
#退出
重启电脑让分区生效
[root@localhost ~]# reboot
开始建立分区
[root@localhost ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
(parted) mkpart
分区名称? []? disk1
文件系统类型? [ext2]?
起始点? 1MB
结束点? 2GB
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 1049kB 2000MB 1999MB ext4 disk1
(parted) quit
进行文件系统的格式化
[root@localhost ~]# mkfs -t ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122160 inodes, 487936 blocks
24396 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=501219328
15 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
进行挂载
[root@localhost ~]# mount /dev/sdb1 /mnt/disk1/
查看挂载
[root@localhost ~]# mount
/dev/sdb1 on /mnt/disk1 type ext4 (rw,relatime,data=ordered)