CentOS分区&格式化&挂载磁盘

磁盘分区挂载分为2T以下和2T以上,由于MBR格式的限制,msdoc类型最大分区为2T,那么2T以上就需要采用GPT等其他方式进行分区了。

MBR(主引导记录)就是我们常用的分区方式,最大支持2.19TB(2的32次方*512byte),可以划分4个主分区或3个主分区+1个扩展分区。

一般使用BIOS的x86架构PC,3T硬盘做系统盘(主盘)就必须使用MBR分区方式。从Vista、win7时代开始,为了解决硬盘容量限制问题,增加了GPT(GUID分区表)。GPT最大支持9.4ZB(1ZB=1024PB,1PB=1024EB,1EB=1024TB,即9.4ZEB=94亿TB)容量,支持128个主分区(window限制,有资料介绍实际无限),但使用GPT分区方式的硬盘只能作为数据盘(从盘)使用,并且注意xp 32位是无法识别GPT分区形式的数据盘的。

检查是否有未挂载的分区

  1. 使用df -h查看挂载的分区与所收集的信息是否能匹配上,如果没有匹配上则需要查看是否有未挂载的磁盘了

  2. 使用fdisk -l查看磁盘,如果出现/dev/vdb没有的情况则就是未挂载;

[root@iZ2vc8dc24dkpleiwpx4n2Z /]# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: dos
Disk identifier: 0x000bb9c1

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux

Disk /dev/vdb: 1099.5 GB, 1099511627776 bytes, 2147483648 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

小于2T的分区

  1. 进入/dev/vdb进行分区
[root@iZ2vc8dc24dkpleiwpx4n2Z ~]# fdisk /dev/vdb 
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x37681faf.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2147483647, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2147483647, default 2147483647): 
Using default value 2147483647
Partition 1 of type Linux and of size 1024 GiB is set

Command (m for help): p

Disk /dev/vdb: 1099.5 GB, 1099511627776 bytes, 2147483648 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: dos
Disk identifier: 0x37681faf

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048  2147483647  1073740800   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
  1. Command (m for help): n新建分区

  2. Select (default p): p新建主分区

  3. Partition number (1-4, default 1): 1输入编号按照fdisk -l查出结果的顺序来

  4. First sector (2048-2147483647, default 2048):直接回车,开始的大小

  5. Last sector, +sectors or +size{K,M,G} (2048-2147483647, default 2147483647):直接回车,结束的大小

  6. Command (m for help): p打印一下结果,此部可以跳过

  7. Command (m for help): w保存并退出

  8. 如下/dev/vdb1显示就是已经挂载完成了;

[root@iZ2vc8dc24dkpleiwpx4n2Z /]# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: dos
Disk identifier: 0x000bb9c1

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux

Disk /dev/vdb: 1099.5 GB, 1099511627776 bytes, 2147483648 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: dos
Disk identifier: 0x37681faf

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048  2147483647  1073740800   83  Linux

大于2T的分区

  1. 进入/dev/vdb进行分区,大于2T需要使用gpt的分区模式所以需要输入g进入;
[root@iZ2vc8dc24dkpleiwpx4n2Z ~]# fdisk /dev/vdb 
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x37681faf.

Command (m for help): g
Building a new GPT disklabel (GUID: 26965E7C-1CD5-4EB3-B1F4-DE7E5B896224)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-128, default 1): 1
First sector (2048-2147483647, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-2147483647, default 2147483647): 
Created partition 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
  1. Command (m for help): g使用gpt模式进行分区

  2. Command (m for help): n新建分区

  3. Partition number (1-128, default 1): 1输入编号按照fdisk -l查出结果的顺序来

  4. First sector (2048-2147483647, default 2048):直接回车,开始的大小

  5. Last sector, +sectors or +size{K,M,G,T,P} (2048-2147483647, default 2147483647):直接回车,结束的大小

  6. Command (m for help): w保存并退出

挂载

  1. 挂载刚分区好的磁盘
mount /dev/vdb1 /data/
  • 如果提示以下下错误,则需要重新格式化磁盘;
[root@iZ2vc8dc24dkpleiwpx4n2Z /]# mount /dev/vdb1 /data
mount: /dev/vdb1 is write-protected, mounting read-only
mount: unknown filesystem type '(null)'
[root@iZ2vc8dc24dkpleiwpx4n2Z /]# 
格式化磁盘
mkfs.ext4 /dev/vdb1
- `mkfd.ext4`设置磁盘文件格式为ext4的格式

- `/dev/vdb1`是磁盘的名称
  1. 挂载后需要设置开机自动挂载
vim /etc/fstab
UUID=9f2d3e15-a78a-4f3d-8385-0165b4b67864 /                       ext4    defaults        1 1
/dev/vdb1 /data ext4 defaults 0 0
  • /dev/vdb1为我们新挂载的盘

卸载

# umount -v /dev/vdb1          通过设备名卸载  
/dev/sda1 umounted  
# umount -v /data      通过挂载点卸载  
/tmp/diskboot.img umounted 

开机启动挂载的盘,别忘记删除掉

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值