通常我们用的比较多的一般都是fdisk工具来进行分区,但是现在由于磁盘越来越廉价,而且磁盘空间越来越大;而fdisk工具他对分区是有大小限制的,它只能划分小于2T的磁盘。但是现在的磁盘空间很多都已经是远远大于2T了,甚至达到2.5T和3T,那要怎么办能,有两个方法,其一是通过卷管理来实现,其二就是通过我们今天谈到的Parted工具来实现对GPT磁盘进行分区操作。

GPT格式的磁盘相当于原来MBR磁盘中原来保留4个partition table的4*16个字节,只留第一个16个字节,类似于扩展分区,真正的partitiontable在512字节之后,GPT磁盘没有四个主分区的限制。

1、            Parted工具详解:

1.1    进入Parted的方法(在命令行输入Parted命令即可)

[root@jetsen ~]# partet

Warning: Unable to open/dev/hdc read-write (Read-only file system). /dev/hdc has been

opened read-only.

GNU Parted 1.8.1

Using /dev/hdc

Welcome to GNU Parted! Type'help' to view a list of commands.

(parted)

1.2    获取parted工具帮助的方法:(只需输入help即可)

(parted) help

check NUMBER                             do a simple checkon the file system

cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition

help [COMMAND]                           prints general help,or help on COMMAND

mklabel,mktable LABEL-TYPE               create a new disklabel(partition table)

mkfs NUMBER FS-TYPE                      make a FS-TYPE filesystem on partititon

NUMBER

mkpart PART-TYPE [FS-TYPE] START END     make a partition

mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system

move NUMBER START END                    move partition NUMBER

name NUMBER NAME                         name partition NUMBERas NAME

print [free|NUMBER|all]                  display the partition table,a partition, or

all devices

quit                                     exit program

rescue START END                         rescue a lostpartition near START and END

resize NUMBER START END                  resize partition NUMBER andits file system

rm NUMBER                                deletepartition NUMBER

select DEVICE                            choose the deviceto edit

set NUMBER FLAG STATE                    change the FLAG onpartition NUMBER

toggle [NUMBER [FLAG]]                   toggle the state of FLAG onpartition NUMBER

unit UNIT                                set the defaultunit to UNIT

version                                  displays thecurrent version of GNU Parted

and copyright information

(parted)

[root@jetsen ~]# parted--help

Usage: parted [OPTION]...[DEVICE [COMMAND [PARAMETERS]...]...]

Apply COMMANDs withPARAMETERS to DEVICE.  If no COMMAND(s)are given, run in

interactive mode.

OPTIONs:

-h, --help                    displays this help message

-i, --interactive             where necessary, prompts for userintervention

-l, --list                    lists partition tables ofall detected devices

-s, --script                  never prompts for userintervention

-v, --version                 displays the version

COMMANDs:

check NUMBER                             do a simple checkon the file system

cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition

help [COMMAND]                           prints general help,or help on COMMAND

mklabel,mktable LABEL-TYPE               create a new disklabel(partition table)

mkfs NUMBER FS-TYPE                      make a FS-TYPE filesystem on partititon NUMBER

mkpart PART-TYPE [FS-TYPE] START END     make a partition

mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system

move NUMBER START END                    move partition NUMBER

name NUMBER NAME                         name partition NUMBERas NAME

print [free|NUMBER|all]                  display the partition table, apartition, or all devices

quit                                     exitprogram

rescue START END                         rescue a lostpartition near START and END

resize NUMBER START END                  resize partition NUMBER andits file system

rm NUMBER                                deletepartition NUMBER

select DEVICE                            choose the deviceto edit

set NUMBER FLAG STATE                    change the FLAG onpartition NUMBER

toggle [NUMBER [FLAG]]                   toggle the state of FLAG onpartition NUMBER

unit UNIT                                set the defaultunit to UNIT

version                                  displays thecurrent version of GNU Parted and copyright information

[root@jetsen ~]#

1.3    退出parted工具(只需输入quit即可)

(parted) quit

Information: Don't forget toupdate /etc/fstab, if necessary.

并且同时会提示及时更新/etc/fstab文件

 

2、            开始通过parted工具来对磁盘进行操作

  2.1 查看单个磁盘状态

[root@jetsen ~]#parted /dev/sdb

GNU Parted 1.8.1

Using /dev/sdb

Welcome to GNUParted! Type 'help' to view a list of commands.

(parted) p

Model: VMware,VMware Virtual S (scsi)

Disk /dev/sdb:16.1GB

Sector size(logical/physical): 512B/512B

Partition Table:msdos

Number  Start  End     Size    Type    File system  Flags

1     32.3kB  16.1GB  16.1GB primary  ext3

(parted)                                                                  

 

2.2 查看所有磁盘状态

[root@jetsen ~]#parted -l

Warning: Unable toopen /dev/hdc read-write (Read-only file system).  /dev/hdc has been

opened read-only.

Error: Unable toopen /dev/hdc - unrecognised disk label.

Model: VMware,VMware Virtual S (scsi)

Disk /dev/sda:21.5GB

Sector size(logical/physical): 512B/512B

Partition Table:msdos

Number  Start  End     Size    Type    File system  Flags

1     32.3kB  107MB   107MB  primary  ext3         boot

2     107MB   21.5GB  21.4GB primary               lvm

Model: VMware,VMware Virtual S (scsi)

Disk /dev/sdb:16.1GB

Sector size(logical/physical): 512B/512B

Partition Table:msdos

Number  Start  End     Size    Type    File system  Flags

1     32.3kB  16.1GB  16.1GB primary  ext3

Model: VMware,VMware Virtual S (scsi)

Disk /dev/sdc:16.1GB

Sector size(logical/physical): 512B/512B

Partition Table:loop

Number  Start  End     Size    File system Flags

1     0.00kB  16.1GB  16.1GB ext3

Error: Unable toopen /dev/sdd - unrecognised disk label.

Error: Unable toopen /dev/sde - unrecognised disk label.

Error: Unable toopen /dev/md0 - unrecognised disk label.

  2.2 通过parted工具来创建大于2T的分区

[root@jetsen ~]#parted /dev/sde

GNU Parted 1.8.1     ---Parted的软件版本号

Using /dev/sde       ---将执行下面操作盘

Welcome to GNUParted! Type 'help' to view a list of commands.    –欢迎信息

(parted) mklabel                                           ----创建创建磁盘标签

New disk labeltype? gpt

(parted) p                                                ----查看分区状态

Model: VMware,VMware Virtual S (scsi)

Disk /dev/sde:2190GB

Sector size(logical/physical): 512B/512B

Partition Table:gpt

Number  Start End  Size  File system Name  Flags

(parted) mkpart

Partition name?  []? gpt2t      ---指定分区名称

File system type? [ext2]ext3    ----指定分区类型

Start? 1                      ---指定开始位置

End? 2190GB                 ---指定结束位置

(parted) P                    ----显示分区信息

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sde: 2190GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number  Start   End    Size    File system  Name  Flags

1      17.4kB 2190GB  2190GB               gpt2t

(parted) Q                              ---退出

Information: Don't forget to update /etc/fstab, if necessary.    -----提示不要忘记更新/etc/fstab文件

2.3 通过parted工具来实现单磁盘多分区

[root@jetsen ~]#parted /dev/sdd

GNU Parted 1.8.1

Using /dev/sdd

Welcome to GNUParted! Type 'help' to view a list of commands.

(parted) p                                        ---列出分区信息

Error:Unable to open /dev/sdd - unrecognised disk label.  ----由于没有打上磁盘标签,所以表现信息无法列出

(parted)mklabel                                   ----创建磁盘标签

New disk labeltype? gpt                             ---输入磁盘表情名

(parted) p                                        ----再次列出磁盘分区

Model: VMware,VMware Virtual S (scsi)               ---显示磁盘类型为SCSI磁盘

Disk /dev/sdd:1100GB                             ---磁盘大小为1100GB

Sector size(logical/physical): 512B/512B              ---扇区大小为512B

Partition Table:gpt                                ----显示标签名为我刚才输入的标签名称

Number  Start End  Size  File system Name  Flags  ----现在是一新硬盘还没有创建分区

(parted)mkpart                                   ---创建分区

Partitionname?  []? part1                           ---指定分区名称

File systemtype?  [ext2]? ext2                       ---定义分区类型

Start? 1G                                         ---指定起始位置

End? 10G                                         ----指定终止位置

(parted)mkpart                                   ---创建分区

Partitionname?  []? part2                           ---指定分区名称

File systemtype?  [ext2]? ext2                       ---定义分区类型

Start? 11G                                        ---指定起始位置

End? 100G                                       ---指定终止位置

(parted)mkpart

Partitionname?  []? part3

File systemtype?  [ext2]?

Start? 101G                                    ----指定分区其实位置

End? -1                                        ----指定到分区最后

(parted) p                                     ----显示分区信息

Model: VMware,VMware Virtual S (scsi)

Disk /dev/sdd:1100GB

Sector size (logical/physical):512B/512B

Partition Table:gpt

Number  Start  End     Size     File system  Name  Flags      ---查看到下面共有三个分区

1     17.4kB  10.0GB  10000MB               part1

2     10.0GB  100GB   90.0GB                part2

3     100GB   1100GB  1000GB                part3

(parted) rm 3                                     ------删除分区3

(parted) p                                        ------再次查看分区状态

Model: VMware,VMware Virtual S (scsi)

Disk /dev/sdd:1100GB

Sector size(logical/physical): 512B/512B

Partition Table:gpt

Number  Start  End     Size     File system  Name  Flags      ----显示分区删除成功,只剩下两个分区

1     17.4kB  10.0GB  10000MB               part1

2     10.0GB  100GB   90.0GB                part2

(parted) quit

Information: Don'tforget to update /etc/fstab, if necessary.

[root@jetsen ~]#ls -l /dev/sdd*

brw-r----- 1 rootdisk 8, 48 May 10 16:48 /dev/sdd

brw-r----- 1 rootdisk 8, 49 May 10 16:48 /dev/sdd1

brw-r----- 1 rootdisk 8, 50 May 10 16:48 /dev/sdd2

[root@jetsen ~]#

  2.3 通过parted工具来删除分区

[root@jetsen ~]# parted /dev/sde

GNU Parted 1.8.1

Using /dev/sde

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) p

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sde: 2190GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number  Start   End    Size    File system  Name  Flags

1      17.4kB 2190GB  2190GB               gpt2t

(parted) rm 1            ----删除分1号分区

(parted) p              ----显示分区信息,看如下是没有分区的

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sde: 2190GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Number  Start  End Size  File system  Name Flags

(parted) q

Information: Don't forget to update /etc/fstab, if necessary.

[root@jetsen ~]#

  2.4 通过parted工具来创建文件系统

[root@jetsen ~]#parted /dev/sdd                         -----选择要格式化的磁盘

GNU Parted 1.8.1

Using /dev/sdd

Welcome to GNUParted! Type 'help' to view a list of commands.

(parted) mkfs 2ext3                                   ----格式化的类型为ext3分区号为2-

Warning: Theexisting file system will be destroyed and all data on the partition will

be lost. Do youwant to continue?

parted: invalidtoken: 2

Yes/No? yes                                          ----再次确认是否格式化

Partition number?2                                   -----再次输入磁盘分区号

File system?  [ext2]?                                  ----格式化的类型

(parted)

查看格式化是否成功:

(parted) p                                           -----查看文件系统是否被格式化

Model: VMware,VMware Virtual S (scsi)

Disk /dev/sdd:1100GB

Sector size(logical/physical): 512B/512B

Partition Table:gpt

Number  Start  End     Size     File system  Name  Flags

1     17.4kB  10.0GB  10000MB               part1

 2     10.0GB  100GB   90.0GB  ext2         part2       -------可以看到文件系统类型为ext2,可确定文件系统已经被格式化了。

(parted)

挂载刚才格式化后的文件系统

[root@jetsen ~]#cd /                                         -----退到根目录

[root@jetsen /]#mkdir part2                                  -----创建part目录

[root@jetsen /]#mount /dev/sdd2 /part2                        -----将/dev/sdd2挂载到/part2

[root@jetsen /]#df –h                                         -----查看分区信息

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

18G  5.8G  11G  35% /

/dev/sda1              99M   12M  82M  13% /boot

tmpfs                 506M  4.0K 506M   1% /dev/shm

/dev/sdd2             83G  52K   79G   1% /part2       ------可以看到已经被挂载上来              

[root@jetsen /]#cd /part2

[root@jetsenpart2]# mkdir 1111                              ------并且可以访问

[root@jetsenpart2]# ls

1111  lost+found

[root@jetsen part2]#

删除和恢复分区

[root@jetsen /]#umount /dev/sdd2                     ----卸载分区

[root@jetsen /]#parted /dev/sdd                       ---通过parted选择/dev/sdd磁盘进入操作

GNU Parted 1.8.1

Using /dev/sdd

Welcome to GNUParted! Type 'help' to view a list of commands.

(parted) rm 2                                      ------删除磁盘分区

(parted) rescue                        -------对磁盘分区进行恢复

Start? 10G                                                               

End? 100G                                                                

Information: A ext2 primary partitionwas found at 10.0GB -> 100GB. Do youwant to add

it to the partition table?

Yes/No/Cancel? Yes                    ----告诉

(parted) print                                                           

 

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdd: 1100GB

Sector size (logical/physical):512B/512B

Partition Table: gpt

 

Number Start   End     Size    File system  Name   Flags

 1     17.4kB  10.0GB  10000MB               part1      

 2     10.0GB  100GB   90.0GB  ext2                    

 

(parted)

[root@jetsen/]# cd /part2                           ----神奇吧,数据也被恢复回来了

[root@jetsenpart2]# ls

1111  lost+found                                                          

 

  2.6 通过parted工具来验证和维护文件系统及分区。

验证文件系统的完整性:

(parted)check 1

Error:File system was not cleanly unmounted! You should run e2fsck.  Modifyingan

uncleanfile system could cause severe corruption.

Ignore/Cancel?ignore

Information:The ext2 file system passed a basic check. For a more comprehensive check,

use thee2fsck program.

(parted)

parted分区详解 查看UUID两种方式 blkid 和 ls -l /dev/disk/by-uuid的更多相关文章

  1. 详解Redis中两种持久化机制RDB和AOF(面试常问,工作常用)

    redis是一个内存数据库,数据保存在内存中,但是我们都知道内存的数据变化是很快的,也容易发生丢失.幸好Redis还为我们提供了持久化的机制,分别是RDB(Redis DataBase)和AOF(Ap ...

  2. 详解Redis中两种持久化机制RDB和AOF

    redis是一个内存数据库,数据保存在内存中,但是我们都知道内存的数据变化是很快的,也容易发生丢失.幸好Redis还为我们提供了持久化的机制,分别是RDB(Redis DataBase)和AOF(Ap ...

  3. Solr系列二:solr-部署详解(solr两种部署模式介绍、独立服务器模式详解、SolrCloud分布式集群模式详解)

    一.solr两种部署模式介绍 Standalone Server 独立服务器模式:适用于数据规模不大的场景 SolrCloud  分布式集群模式:适用于数据规模大,高可靠.高可用.高并发的场景 二.独 ...

  4. MySQL的表分区详解 - 查看分区数据量,查看全库数据量----转http://blog.csdn.net/xj626852095/article/details/51245844

    查看分区数据量,查看全库数据量 USE information_schema; SELECT PARTITION_NAME,TABLE_ROWS FROM INFORMATION_SCHEMA.PAR ...

  5. linux磁盘及分区详解

    1.Linux 分区简介 1.1 主分区 vs 扩展分区 硬盘分区表中最多能存储四个分区,但我们实际使用时一般只分为两个分区,一个是主分区(Primary Partion)一个是扩展分区(extend ...

  6. 分区工具parted的详解及常用分区使用方法【转】

    来源:http://blog.51cto.com/zhangmingqian/1068779 分区工具parted的详解及常用分区使用方法 一.         parted的用途及说明 概括使用说明 ...

  7. CKEditor配置,最适合新手两种方式详解。

    CKEditor.js的配置,大概有两种方式,这里有基础版和全面的版本可以试验 https://cdn.ckeditor.com/4.8.0/full-all/ckeditor.js http://c ...

  8. java中调用本地动态链接库(*.DLL)的两种方式详解和not found library、打包成jar,war包dll无法加载等等问题解决办法

    我们经常会遇到需要java调用c++的案例,这里就java调用DLL本地动态链接库两种方式,和加载过程中遇到的问题进行详细介绍 1.通过System.loadLibrary("dll名称,不 ...

  9. python模块的导入的两种方式区别详解

    Python 有两种导入模块的方法.两种都有用,你应该知道什么时候使用哪一种方法.一种方法,import module,另一种是from module import,下面是 from module i ...

随机推荐

  1. HDU2612---(两次BFS)

    Description Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Nin ...

  2. MyEclipse2014搭建JSF项目实例

    开发环境:  Windows2008 R2 64位 + MyEclipse Professional 2014 +JDK1.7+Tomcat7.0 搭建步骤: 1.打开MyEclipse2014后新建 ...

  3. Java-IO之总框架

    在Java IO中我们会经常提到输入流和输出流,流是一种抽象的数据总称,本质是能够进行数据的传输.按照流的方向分为:输入流和输出流.按照流中处理数据的单位,可以将其区分为:字节流和字符流.在Java中 ...

  4. MyBatis主键生成器SelectKeyGenerator(三)

    前面两篇博客我们介绍了MyBatis主键生成器KeyGenerator(一)和MyBatis主键生成器Jdbc3KeyGenerator(二),接下来我们介绍SelectKeyGenerator, 如 ...

  5. Spark MLlib数据类型

        MLlib支持几种数据类型:本地向量(local vectors),和存储在一个简单机器中的矩阵(matrices),以及由一个或多个RDDs组成的分布式矩阵. 1,本地向量(Local Ve ...

  6. LTP语法分析

    http://blog.csdn.net/pipisorry/article/details/50306931 POS词性标注解释 词性标注(Part-of-speech Tagging, POS)是 ...

  7. 检查一个二叉树是否平衡的算法分析与C++实现

    今天面试一个实习生,就想既然是未出校园,那就出一个比较基础的题吧,没想到答的并不如人意,对于树的操作完全不熟悉,因此此题算是未作答.原来我想看一下他分析问题的思路,优化代码的能力.接下来会把最近半年我 ...

  8. WdatePicker()时间控制方式(转载+原创)

     控制时间在制定范围内: <input class="wzsrk" name="startDateStr" id="startDateStr ...

  9. 《java入门第一季》集合框架引入与面试题

    注:在开始的几篇集合介绍里,不包含泛型的概念.泛型在讲述所有集合后再加入进去. 集合的由来:    我们学习的是面向对象语言,而面向对象语言对事物的描述是通过对象体现的,为了方便对多个对象进行操作,我 ...

  10. python异常处理和断言

    http://blog.csdn.net/pipisorry/article/details/21841883 关于异常处理有必要么的讨论 最重要的问题是你在开发过程中隐藏了bug,如果当时你没加这个 ...