公司新到了两台服务器,系统都已经装好了,但有个RAID没有挂载使用,所以有了这篇文章。
首先 df -Th
先查看一下现在的目录挂载情况,已经文件系统的类型。
[root@xxx ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 1.1T 16G 1.1T 2% /
devtmpfs devtmpfs 32G 0 32G 0% /dev
tmpfs tmpfs 32G 0 32G 0% /dev/shm
tmpfs tmpfs 32G 9.1M 32G 1% /run
tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/sda1 xfs 197M 157M 41M 80% /boot
tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/0
因为使用了 LVM 所以 单独给 /boot
分配了 200MB,主目录挂载的对象显示为/dev/mapper/centos-root
。而且文件系统为 xfs 。
使用 fdisk -l
查看磁盘的使用情况。
[root@xxx~]# fdisk -l
Disk /dev/sda: 1199.2 GB, 1199168290816 bytes, 2342125568 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: 0x00044d27
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 2342125567 1170856960 8e Linux LVM
Disk /dev/sdb: 8000.5 GB, 8000450330624 bytes, 15625879552 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 /dev/mapper/centos-root: 1130.2 GB, 1130239098880 bytes, 2207498240 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 /dev/mapper/centos-swap: 68.7 GB, 68715282432 bytes, 134209536 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
可以看到 第一块磁盘大小为 1.2TB,分了两个区。 第二块磁盘为8TB,还未使用,剩下的是 虚拟磁盘的相关的信息。
最初我使用了 fdisk 命令格式化硬盘: fdisk /dev/sdb
然后一系列的交互命令。n > p > 」> 」> 」 > w
。
[root@xxx~]# fdisk /dev/sdb
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 0x867a48ad.
WARNING: The size of this disk is 8.0 TB (8000450330624 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
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):
First sector (2048-4294967295, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4294967294, default 4294967294):
Using default value 4294967294
Partition 1 of type Linux and of size 2 TiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
然后发现 这一个分区并没有使用全部磁盘空间。只有2TB。 然后才注意到fdisk 是 MBR 分区工具
他的提示里有如下信息
WARNING: The size of this disk is 8.0 TB (8000450330624 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
所以 改用 parted 重新分区。
parted /dev/sdb
, 依旧是交互模式。
mklabel gpt > mkpart > primary > xfs > 0 > -1
[root@xxx~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
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
(parted) p
Model: LSI MR9361-8i (scsi)
Disk /dev/sdb: 8000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) mkpart
Partition name? []? primary
File system type? [ext2]? xfs
Start?
Start? 0
End? -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted) p
Model: LSI MR9361-8i (scsi)
Disk /dev/sdb: 8000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 8000GB 8000GB primary
其中 创建分区表时 提示会丢失数据,需要输入 yes 确认, 以及分区时 提示未对齐, 选择 ignore 忽略。
在交互模式中 p /print 会输出硬盘的信息。
mkfs.xfs /dev/sdb1
mount /dev/sdb1 /mnt/