码迷,mamicode.com
首页 > 其他好文 > 详细

使用parted 创建一个大于2T的分区

时间:2019-07-08 16:37:45      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:perl   sed   两种   table   number   linux   ber   end   oba   

1、查看现有分区
parted -l
fdisk   -l
 
 
2、对/dev/sdb分一个区
[root@test ~]# parted /dev/sdb
 
(parted) mkpart  【因为没有修改磁盘格式所以报错】                                                        
Error: /dev/sdb: unrecognised disk label
 
(parted) mklabel     //修改磁盘格式                                                       
New disk label type? gpt                                                 
(parted) p                                                               
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start  End  Size  File system  Name  Flags
 
(parted) mkpart 
Partition name?  []? primary       //定义一个分区名字                                            
File system type?  [ext2]? ext4                                                                
Start? 0                                                                 
End? 20G                                                                 
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I                                                         
(parted) P                                                               
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  20.0GB  20.0GB               primary
 
(parted) quit  #退出分区模式,不需要输入保存的按钮,退出来它会自动保存分区表信息。
在parted分区后,系统不需要重启也生效
 
 
3、对/dev/sdb进行分区,分多个区
(parted) p                                                               
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start  End  Size  File system  Name  Flags
 
(parted) mkpart                                                          
Partition name?  []? test1                                               
File system type?  [ext2]? ext4                                          
Start? 0                                                                 
End? 5G                                                                  
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I                                                         
(parted) mkpart
Partition name?  []? test2                                               
File system type?  [ext2]? ext4                                          
Start? 5G                                                                
End? 10G                                                                 
(parted) mkpart
Partition name?  []? test3
File system type?  [ext2]? ext4                                          
Start? 10G                                                               
End? 15G                                                                 
(parted) mkpart                                                          
Partition name?  []? test4                                               
File system type?  [ext2]? ext4                                          
Start? 15G
End? 100%                                                                 
(parted)                                                               
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start   End     Size    File system  Name   Flags
 1      17.4kB  5000MB  5000MB               test1
 2      5001MB  10.0GB  5000MB               test2
 3      10.0GB  15.0GB  5000MB               test3
 4      15.0GB  20.0GB  5000MB               test4
 
(parted) quit 
 
 
4、格式化分区并挂载
 
[root@test ~]# mkfs -t ext4 /dev/sdb1
[root@test ~]# mkdir /root/testu
[root@test ~]# mount -t ext4 /dev/sdb1 /root/testu/
[root@test ~]# df -Th
Filesystem                  Type   Size  Used Avail Use% Mounted on
/dev/mapper/vg_test-lv_root ext4    75G  3.6G   68G   6% /
tmpfs                       tmpfs  2.0G   72K  2.0G   1% /dev/shm
/dev/sda1                   ext4   485M   37M  423M   9% /boot
/dev/sdb1                   ext4   4.6G  138M  4.3G   4% /root/testu
 
 
5、打印并且删除分区
(parted) p                                                               
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  20.0GB  20.0GB               pa
 
(parted) rm   1 
 
(parted) p                                                               
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start  End  Size  File system  Name  Flags
 
 
 
6、 linux中有两种分区方式:MBR和GPT
 
MBR: (Master Boot Record)主引导记录,是传统的分区机制,应用于绝大多数使用BIOS的PC设备,使用32位表示扇区数。
  特点:
     MBR支持32位和64位系统
     MBR支持分区数量有限
     MBR只支持不超过2T的硬盘,超过2T的硬盘将只能用2T空间(有第三方解决方法)
 
 
GPT:GUID(Globals Unique Identifiers)Partition Table 全局唯一标识,是一个较新的分区机制,解决了MBR很多缺点。
   使用128位UUID 表示磁盘和分区,GPT分区表自动备份在头和尾两份,并有CRC校验位。
支持超过2T的磁盘(64位寻址空间),使用64位,支持128个分区,支持8Z(512Byte/block )64Z(4096Byte/block)。fdisk最大只能建立2TB大小的分区,创建一个大于2TB的分区使用parted,gdisk分区工具
   特点: 
       向后兼容MBR
       必须在支持UEFI的硬件上才能使用(Intel提出,用于取代BIOS)
       必须使用64位系统
       Mac、Linux系统都能支持GPT分区格式
       Windows 7/8 64bit、Windows Server 2008 64bit支持GPT

使用parted 创建一个大于2T的分区

标签:perl   sed   两种   table   number   linux   ber   end   oba   

原文地址:https://www.cnblogs.com/liuxing0007/p/11151979.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!