说明:
在 Linux 上可以采用 parted 来对磁盘进行分区
1、通过 fdisk -l 可以查看磁盘是否存在, 由于使用的是大磁盘(大于2T),fdisk 不能用来作为分区工具了,而应该使用 parted
2、使用 parted 对 /dev/sdd 进行分区。首先创建分区表, 选择 GPT 格式的分区表。 parted /dev/sdd
步骤一:分区命令
parted /dev/sdd
该命令常用的参数:
help [COMMAND] | print general help, or help on COMMAND |
创建分区表gpt | mklabel,mktable LABEL-TYPE create a new disklabel (partition table) |
创建分区 | mkpart PART-TYPE [FS-TYPE] START END make a partition |
显示当前分区信息 |
print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all |
退出 | quit、 exit program |
删除一个分区 | rm NUMBER、delete partition NUMBER |
第二步:使用parted命令进入之后,
步骤二:首先是创建分区表
[root@PandaLi ~]# parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel ####创建分区表
New disk label type? gpt ####类型是gpt
(parted) p ####显示分区信息
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt Number Start End Size File system Name Flags
步骤三:创建区并指定大小
(parted) mkpart primary 0 500G ####创建主分区并指定大小
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I ####忽略
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt Number Start End Size File system Name Flags
1 17.4kB 500GB 500GB primary (parted) mkpart extend 500G 1000G ####创建扩展分区分区并指定大小
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt Number Start End Size File system Name Flags
1 17.4kB 500GB 500GB primary
2 500GB 1000GB 500GB extend
步骤四:在命令行查看分区信息: parted /dev/sdd print <====>parted /dev/sdd p
步骤五:使用parted在命令行实现非交互式创建分区
parted /dev/sdd mkpart primary 5000G 800G
步骤六:查看分区情况
[root@PandaLi ~]# parted /dev/sdd print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 500GB 500GB rimary
2 500GB 1000GB 500GB extend
3 1000GB 1200GB 200GB logical
步骤七:在命令行删除一个分区
[root@PandaLi ~]# parted /dev/sdc rm 3
Information: You may need to update /etc/fstab.
步骤八:格式化分区(和fdisk格式化方法一样)
[root@PandaLi ~]# mkfs.ext4 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
30523392 inodes, 122070308 blocks
6103515 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
3726 block groups
32768 blocks per group, 32768 fragments per group
8192 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 Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override. 【注意一下这里】
步骤九:让系统不对我们新创建的分区进行磁盘检查
[root@PandaLi ~]# tune2fs -c 0 -i 0 /dev/sdc1
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
步骤九:挂载分区(和fdisk一样)
临时挂载:
[root@PandaLi ~]# mount /dev/sdc1 /oldboy/
永久挂载
方法一: 把挂载命令写入:/etc/rc.local 开机自启动配置文件
方法二:编辑 /etc/fstab 配置文件