linux大硬盘分区工具parted

由于单块硬盘的容量不断增大,价格也很便宜,现在2TB的硬盘已经很常见,而传统的MBR方式存储使很多分区工具不能正常读取大于2TB的磁盘而无法分区大于2TB的磁盘,linux提供parted工具可以很好的支持大磁盘分区。
Parted和fdisk很相似,也是命令行工具,但是parted分区是实时的,只要开始执行分区,就实实在在的分区啦,而不像fdisk工具需要执行w后才开始分区,所以使用parted分区的时候一定要注意,看清楚在下手。
下面是parted的欢迎界面
[root@dbserver1 dev]# parted
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
选择使用/dev/sdd设备
(parted) select /dev/sdd                                                 
Using /dev/sdd
创建分区表
(parted) mklabel                                                         
New disk label type? gpt                                                 
(parted) p                                                               
Model: DGC RAID 5 (scsi)
Disk /dev/sdd: 25.6TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
有可能在在创建分区表的时候出现以下警告,警告用户磁盘数据将会丢失,是否继续,输入yes是继续,需慎重。
Warning: The existing disk label on /dev/hdd will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No?
创建分区
(parted) mkpart                                                          
Partition name?  []?            --可以指定分区名字                                         
File system type?  [ext2]?      --文件系统类型                                         
Start? 2048G                    --开始位置                                         
End? 4096G                      --结束位置                                         
在创建几个分区
(parted) mkpart                                                          
Partition name?  []?                                                     
File system type?  [ext2]?                                               
Start? 4096G                                                             
End? 6144G                                                               
(parted) mkpart                                                          
Partition name?  []?                                                     
File system type?  [ext2]?                                               
Start? 6144G                                                             
End? 8192G                                                               
(parted) mkpart                                                          
Partition name?  []?                                                     
File system type?  [ext2]?                                               
Start? 8192G                                                             
End? 10240G                                                              
(parted) mkpart                                                          
Partition name?  []?                                                     
File system type?  [ext2]?                                               
Start? 10240G                                                            
End? -1                       --使用所有剩余空间                                           
输入print可以查看以创建的分区,可缩写p
(parted) p                                                               
Model: DGC RAID 5 (scsi)
Disk /dev/sdd: 25.6TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name  Flags
1      1049kB  2048GB  2048GB
2      2048GB  4096GB  2048GB
3      4096GB  6144GB  2048GB
4      6144GB  8192GB  2048GB
5      8192GB  10.2TB  2048GB
6      10.2TB  25.6TB  15.4TB
如果对分区不满意,可以用rm删除分区,比如要删除第6个分区(Number为6的分区)。
(parted) rm 6
Print查看分区。
(parted) p                                                               
Model: DGC RAID 5 (scsi)
Disk /dev/sdd: 25.6TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name  Flags
1      1049kB  2048GB  2048GB
2      2048GB  4096GB  2048GB
3      4096GB  6144GB  2048GB
4      6144GB  8192GB  2048GB
5      8192GB  10.2TB  2048GB
操作完毕,输入quit退出,parted会提示我们修改/etc/fstab文件,将分区设置为自动挂载。
(parted) quit
Information: You may need to update /etc/fstab.
到操作系统查看分区
[root@dbserver1 dev]# ls -l /dev/sdd*
brw-rw---- 1 root disk 8, 48 Aug  4 15:12 /dev/sdd
brw-rw---- 1 root disk 8, 49 Aug  4 15:12 /dev/sdd1
brw-rw---- 1 root disk 8, 50 Aug  4 15:12 /dev/sdd2
brw-rw---- 1 root disk 8, 51 Aug  4 15:12 /dev/sdd3
brw-rw---- 1 root disk 8, 52 Aug  4 15:12 /dev/sdd4
brw-rw---- 1 root disk 8, 53 Aug  4 15:12 /dev/sdd5
Parted内带的格式化工具还不是很完善,建好分区后,需要使用操作系统带的mkfs工具对分区进行格式化,(此文为搭建ASM磁盘组,所以并没有格式化分区)
[root@dbserver1 dev]# mkfs /dev/sdd1
[root@dbserver1 dev]# mkfs /dev/sdd2
[root@dbserver1 dev]# mkfs /dev/sdd3
[root@dbserver1 dev]# mkfs /dev/sdd4
[root@dbserver1 dev]# mkfs /dev/sdd5

你可能感兴趣的:(linux)