磁盘分区挂载分为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分区形式的数据盘的。
检查是否有未挂载的分区
-
使用df -h查看挂载的分区与所收集的信息是否能匹配上,如果没有匹配上则需要查看是否有未挂载的磁盘了
-
使用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的分区
- 进入
/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.
-
Command (m for help): n
新建分区 -
Select (default p): p
新建主分区 -
Partition number (1-4, default 1): 1
输入编号按照fdisk -l
查出结果的顺序来 -
First sector (2048-2147483647, default 2048):
直接回车,开始的大小 -
Last sector, +sectors or +size{K,M,G} (2048-2147483647, default 2147483647):
直接回车,结束的大小 -
Command (m for help): p
打印一下结果,此部可以跳过 -
Command (m for help): w
保存并退出 -
如下
/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的分区
- 进入
/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.
-
Command (m for help): g
使用gpt模式进行分区 -
Command (m for help): n
新建分区 -
Partition number (1-128, default 1): 1
输入编号按照fdisk -l
查出结果的顺序来 -
First sector (2048-2147483647, default 2048):
直接回车,开始的大小 -
Last sector, +sectors or +size{K,M,G,T,P} (2048-2147483647, default 2147483647):
直接回车,结束的大小 -
Command (m for help): w
保存并退出
挂载
- 挂载刚分区好的磁盘
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`是磁盘的名称
- 挂载后需要设置开机自动挂载
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
开机启动挂载的盘,别忘记删除掉