1 概述
1.1 说明
parted用于对磁盘(或RAID磁盘)进行分区及管理,与fdisk分区工具相比,支持2TB以上的磁盘分区,并且允许调整分区的大小
2 分区
交互式进行分区
[root@localhost ~]# parted /dev/sda //进入parted分区工具
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt //把sda改成gpt大分区格式 ;定义分区表格式(常用的有msdos和gpt分区表格式,msdos不支持2TB以上的容量的磁盘,所以大于2TB的磁盘选gpt分区表格式) Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) print //进行查看 ,可以看到已经打上了gpt的标签
Model: DELL PERC H710P (scsi)
Disk /dev/sda: 4000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
(parted) mkpart primary 0 4000GB //创建一个主分区,容量从0GB开始到4000GB的全部空间
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
(parted) print //查看分区的信息
Model: DELL PERC H710P (scsi)
Disk /dev/sda: 4000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 4000GB 4000GB primary
(parted) quit
Information: You may need to update /etc/fstab.
3 确认分区表的改变
partprobe /dev/sdb
使用partprobe则可以使kernel重新读取分区 信息,从而避免重启系统
3.1 partprobe 选项说明
-d 不更新内核
-s 显示磁盘分区汇总信息
-h 显示帮助信息
-v 显示版本信息
4 格式化(此格式化过程需要5分钟左右)
[root@localhost ~]# mkfs.ext4 -F /dev/sda1
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
244154368 inodes, 976617463 blocks
48830873 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
29804 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, 214990848, 512000000, 550731776, 644972544
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5 查看此磁盘的uuid,进行挂载
#blkid /dev/sdb1
/dev/sdb1: UUID="120927fd-c132-4149-b78b-2148291c9287" TYPE="ext4" PARTLABEL="primary" PARTUUID="07220a37-50fb-47fa-803c-9ce648d6aa92"
然后使用uuid进行挂载