parted创建GPT分区(支持2T以上硬盘)

介绍2种分区表:

MBR分区表:(MBR含义:主引导记录)
所支持的最大卷:2T (T; terabytes,1TB=1024GB)
对分区的设限:最多4个主分区或3个主分区加一个扩展分区。

GPT分区表:(GPT含义:GUID分区表)
支持最大卷:18EB,(E:exabytes,1EB=1024TB)
每个磁盘最多支持128个分区

 

所以如果要大于2TB的卷或分区就必须得用GPT分区表。

 

Linux下fdisk工具不支持GPT,得使用另一个GNU发布的强大分区工具parted。

fdisk工具用的话,会有下面的警告信息:

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

下面是用parted工具对/dev/sda做GPT分区的过程:

root@node01:/mnt# parted /dev/sda
GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.

 

(parted) mklabel 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                                                            
Model: DELL PERC 6/i Adapter (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B      
#遇到Sector size (logical/physical): 512B/4096B,第一个分区从1049KB起,否则可能4K对不齐
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

 

(parted)mkpart primary 0KB 3000GB
Warning: You requested a partition from 0.00B to 3000GB.                   
The closest location we can manage is 17.4kB to 3000GB.
Is this still acceptable to you?
Yes/No? yes                                                               
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore                          

 

(parted) print                                                            
Model: DELL PERC 6/i Adapter (scsi)
Disk /dev/sda: 3000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size   File system  Name     Flags
 1      17.4kB  3000GB  3000GB               primary

 

(parted)quit                                                             
Information: You may need to update /etc/fstab.                           

root@node01:/#fdisk -l

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sda: 3001 GB, 499558383616 bytes
255 heads, 63 sectors/track, 60734 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       60735   487849983+  ee  GPT

root@node01:/#mkfs.ext4 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
30490624 inodes, 121962487 blocks
6098124 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
3722 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

正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

root@node01:/#mount /dev/sda1 /export/glusterfs01/


root@node01:/# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/node01-root
                      6.8G  987M  5.5G  16% /
none                  7.9G  208K  7.9G   1% /dev
none                  7.9G     0  7.9G   0% /dev/shm
none                  7.9G   32K  7.9G   1% /var/run
none                  7.9G     0  7.9G   0% /var/lock
/dev/sdb1             228M   21M  196M  10% /boot
/dev/sda1             2.7t  198M  2.6t   1% /export/glusterfs01

 

root@node01:/#vi /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/mapper/node01-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sdb1 during installation
UUID=c21707ff-ba0f-43ee-819a-8e72fa0f8500 /boot           ext2    defaults        0       2
/dev/mapper/node01-swap_1 none            swap    sw              0       0
/dev/sda1       /export/glusterfs01     ext4    defaults        0       2

 

重启就可以自动挂载了!至此完成



创建多个GPT分区方法:

 parted /dev/sdb # 使用parted来对GPT磁盘操作,进入交互式模式
GNU Parted 1.8.1 Using /dev/sdb Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) mklabel gpt           # 将MBR磁盘格式化为GPT
(parted) print                       #打印当前分区
(parted) mkpart primary 0 4.5TB                # 分一个4.5T的主分区
(parted) mkpart primary 4.5TB 12TB      # 分一个7.5T的主分区
(parted) print                         #打印当前分区
(parted) quit 退出
Information: Don’t forget to update /etc/fstab, if necessary.
2.然后格式化成ext4,需要安装包e4fsprogs.x86_64(yum install e4fsprogs.x86_64)即可。

[root@localhost ~]# mkfs.ext4 /dev/sdb1
[root@localhost ~]# mkfs.ext4 /dev/sdb2

3.接着用mount挂载分区

[root@localhost]# mount -t ext4 /dev/sdb1 /bk
[root@localhost]# mount -t ext4 /dev/sdb2 /mail
[root@localhost ~]# df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda6     ext3     39G  9.4G   28G  26% /
/dev/sda1     ext3    122M   13M  103M  12% /boot
none         tmpfs   1004M     0 1004M   0% /dev/shm
/dev/sdb1     ext4    4.1T   194M  3.9T  1% /bk
/dev/sdb2     ext4    6.8T   179M  6.4T  1% /mail

4.最后修改/etc/fstab,添加如下两行,让其开机自动挂载.

/dev/sdb1       /bk          ext4            defaults,noatime       1 2
/dev/sdb2      /mail       ext4           defaults,noatime         1 2 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值