MBR分区表有一定的局限性,最大支持2.1tb硬盘,单块硬盘最多4个主分区。

  这里就要引入GPT分区表,可以支持最大18EB的卷,最多支持128个主分区,所以如果使用大于2tb的卷,就必须使用GTP分区。

  对/dev/sdb进行分区

parted /dev/sdb

  进入交互模式:

(parted)

  交互模式下常用命令:

print  [free|all | NUMBER]

查看分区状态信息

mkpart PART-TYPE START END

创建新分区,

PART-TYPE: primary  extended   logical

START, END  开始,结束为止

set NUMBER  FLAG  STATE

对编号为NUMBER的进行标记。

FLAG: boot  引导, hidden 隐藏, raid  软raid, lvm  逻辑卷,

STATE:  on| off

mkfs NUMBER FS-TYPE

对NUMBER指定文件系统。FS-Type有:ext2、fat16、fat32、linuxswap、NTFS、reiserfs、ufs 等

cp  [FROM-DEV] FROM-NUMBER  TO-NUMBER

将分区 FROM-NUMBER 上的文件系统完整地复制到分区TO-NUMBER 中,作为可选项还可以指定一个来源硬盘的设备名称FROM-DEVICE,若省略则在当前设备上进行复制。

move NUMBER START END

将指定编号 NUMBER 的分区移动到从 START 开始 END 结束的位置上。注意:(1)只能将分区移动到空闲空间中。(2)虽然分区被移动了,但它的分区编号是不会改变的

resize NUMBER START END  

对指定编号 NUMBER 的分区调整大小。分区的开始位置和结束位置由 START 和 END 决定

check NUMBER

检查指定编号 NUMBER 分区中的文件系统是否有什么错误

rescue START END

rescue START END

mklabel,mktable LABELTYPE

创建一个新的 LABEL-TYPE 类型的空磁盘分区表,对于PC而言 msdos 是常用的 LABELTYPE。 若是用 GUID 分区表,LABEL-TYPE 应该为 gpt. 还有其他的aix, amiga, bsd, dvh, gpt, mac, msdos, pc98, sun, loop

实例:

[root@linux-node2 ~]# parted /dev/sdb    #对sdb分区
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p    #print 打印
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: Number Start End Size Type File system Flags
(parted) mklabel    #定义分区表类型,msdos是MBR分区表,可以用这个方法将硬盘转换成MBR
New disk label type? gpt #分区表定义为gpt,之前是mbr分区,所以会有下面的提醒
Warning: 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    #警告sdb之前的内容将会丢失
(parted) mkpart    #创建分区
Partition name? []? sdb1  #分区表名称
File system type? [ext2]? ext4    #文件系统类型
Start? 0    #起始扇区
End? 1g    #结束扇区
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i    #警告内容将删除,选择忽略
(parted) p   #print打印分区信息
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number Start End Size File system Name Flags
.4kB 1000MB 1000MB ext4 sdb1 (parted) rm 1    #删除分区1
(parted) mkpart primary 1g  #创建主分区1gb
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i    #警告内容会被删除,选择忽略
(parted) mkpart primary 1g 3g     #创建主分区2gb
(parted) p     #打印
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number Start End Size File system Name Flags
.4kB 1000MB 1000MB ext4 primary
1000MB 3220MB 2220MB ext4 primary (parted) q    #退出
Information: You may need to update /etc/fstab.

[root@linux-node2 ~]# fdisk -l /dev/sdb    #查看/dev/sdb分区
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.


Disk /dev/sdb: 3221 MB, 3221225472 bytes, 6291456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


# Start End Size Type Name
1 34 1953125 953.7M Microsoft basic primary
2 1953792 6289407 2.1G Microsoft basic primary

[root@linux-node2 ~]# mkfs.ext4 /dev/sdb1    #格式化sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
61056 inodes, 244136 blocks
12206 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=251658240
8 block groups
32768 blocks per group, 32768 fragments per group
7632 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

[root@linux-node2 ~]# blkid /dev/sdb1    #查看sdb1的UUID
/dev/sdb1: UUID="612067e2-12ca-4410-9ab8-682b22c0da87" TYPE="ext4" PARTLABEL="primary" PARTUUID="ae6af195-c535-4380-8a8f-e96c73730d96"
[root@linux-node2 ~]# echo 'UUID=612067e2-12ca-4410-9ab8-682b22c0da87 /data ext4 defaults 0 0' >> /etc/fstab    #实现开机自动挂载

学习参考来自:http://www.cnblogs.com/onlybobby/p/7018788.html

最新文章

  1. 编译可在Nexus5上运行的CyanogenMod13.0 ROM(基于Android6.0)
  2. //build->//learn->//publish
  3. flex上下固定中间滚动布局
  4. Open Cascade DataExchange DXF
  5. mysql create db utf8 character
  6. GLUT教程 - 安装
  7. Confluence 5.4实现与JIRA前所未有的集成
  8. bzoj 3053 HDU 4347 : The Closest M Points kd树
  9. DateTime字段控件值显示短格式的做法
  10. 关于MATLAB处理大数据坐标文件2017620
  11. JVM核心之JVM运行和类加载全过程
  12. D 洛谷 P3602 Koishi Loves Segments [贪心 树状数组+堆]
  13. windows命令中的cd
  14. c++ Qt向PHP接口POST文件流
  15. Could not find artifact cn.e3mall:e3mall-parent:pom:0.0.1-SNAPSHOT
  16. 隐藏Nginx或Apache以及PHP的版本号的方法
  17. 2、evaluate-reverse-polish-notation
  18. Android 写一个Activity之间来回跳转的全局工具类(主要是想实现代码的复用)
  19. linux通过sendmail发送邮件
  20. JSP9大内置对象

热门文章

  1. 【JS】垃圾回收和块级作用域
  2. [React] Forward a DOM reference to another Component using forwardRef in React 16.3
  3. python使用pytest+pytest报告
  4. python实现高速排序算法(两种不同实现方式)
  5. nexus启动报错----->错误 1067: 进程意外终止。
  6. JavaScript:目录
  7. Node.js:事件循环
  8. [luogu P5349] 幂 解题报告 (分治FFT)
  9. Java 实时论坛 - Sym 1.3.0 发布
  10. Activity创建时布局文件的实现原理