[TOC]
查看未分配硬盘
查看磁盘信息 fdisk -l
Disk /dev/vdc
Disk /dev/vdd
未被使用
[root@test-bgd-cdh-04 ~]# fdisk -l
Disk /dev/vda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x000a6672
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 4196351 2097152 83 Linux
/dev/vda2 4196352 20973567 8388608 82 Linux swap / Solaris
/dev/vda3 20973568 1048575999 513801216 83 Linux
Disk /dev/vdb: 2147.5 GB, 2147483648000 bytes, 4194304000 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: 0xc5a20a73
Device Boot Start End Blocks Id System
/dev/vdb1 2048 4194303999 2097150976 8e Linux LVM
Disk /dev/vdc: 2147.5 GB, 2147483648000 bytes, 4194304000 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/vdd: 1073.7 GB, 1073741824000 bytes, 2097152000 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
查看磁盘格式
df -T
[root@test-bgd-cdh-04 ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/vda3 xfs 513550340 452181092 61369248 89% /
devtmpfs devtmpfs 65920560 0 65920560 0% /dev
tmpfs tmpfs 65931228 0 65931228 0% /dev/shm
tmpfs tmpfs 65931228 222528 65708700 1% /run
tmpfs tmpfs 65931228 0 65931228 0% /sys/fs/cgroup
/dev/vda1 xfs 2086912 172532 1914380 9% /boot
tmpfs tmpfs 13186248 0 13186248 0% /run/user/0
tmpfs tmpfs 13186248 0 13186248 0% /run/user/1000
overlay overlay 513550340 452181092 61369248 89% /var/lib/docker/overlay2/60af3bc5d8c5593180da1c908b32c097f551b699f7e57c1f89f9752a66482590/merged
shm tmpfs 65536 0 65536 0% /var/lib/docker/containers/eb218c6e8a60b8a386d909f6e72f868549faec6afe5ce190a6f885b935681c92/mounts/shm
overlay overlay 513550340 452181092 61369248 89% /var/lib/docker/overlay2/fb836a5a91560edf98c7eefc66035c33dcd510f020926aad2c8a3ae194704a18/merged
shm tmpfs 65536 0 65536 0% /var/lib/docker/containers/cec8cbe20ca00a66f8e1101c9967e84f523f013a0acb0cf7c9518b462927b058/mounts/shm
overlay overlay 513550340 452181092 61369248 89% /var/lib/docker/overlay2/a2801d984bf74c4b5f92d3d20c79443e951d26862b4dcd893ba057dc06267c83/merged
shm tmpfs 65536 0 65536 0% /var/lib/docker/containers/f7b7d214f76345850e20e603535d7388016db3091f81e6a30f19a9374be97fbe/mounts/shm
cm_processes tmpfs 65931228 24824 65906404 1% /run/cloudera-scm-agent/process
overlay overlay 513550340 452181092 61369248 89% /var/lib/docker/overlay2/811dbdc2661b7ff69b6710ec078a748eaf5c309c8c5f28cf04d8410ff935e961/merged
shm tmpfs 65536 4 65532 1% /var/lib/docker/containers/53b7f6afcb8f55f8e000818fe53da4e9bdbfcdd3b1e04e0c7e8688f01a5560fc/mounts/shm
overlay overlay 513550340 452181092 61369248 89% /var/lib/docker/overlay2/e0274eb8bf17823d5d34cb8caf25908a3552c05ae740add59a4ba0b2283908cf/merged
shm tmpfs 65536 0 65536 0% /var/lib/docker/containers/64aa133b28d715115aa2f7c9f943fe2dece6415b31f8ebf1eeff2b6937810d76/mounts/shm
overlay overlay 513550340 452181092 61369248 89% /var/lib/docker/overlay2/391110b883f4fe3a4cef8c2a4e6b264861a8f9a91d6c01e65f44161ba53b0557/merged
shm tmpfs 65536 3080 62456 5% /var/lib/docker/containers/51e7c7184a6d0a91dfc7ad55921dd2bcd732f116af403f44ce47bd4d26bfe54f/mounts/shm
overlay overlay 513550340 452181092 61369248 89% /var/lib/docker/overlay2/2cecb1d47f935971de87041c8d5ed8c340696fc622780c93c840d1ee9fd33aaa/merged
shm tmpfs 65536 0 65536 0% /var/lib/docker/containers/38466a377befe251a9091cb14808c81d5e31cb41d295079ce804ab9b634cbdba/mounts/shm
/dev/vdb1 xfs 2096126980 32992 2096093988 1% /work/disk1
新建分区
fdisk /dev/vdc //这里的vdb是要挂载的新硬盘
n //添加新分区
p //创建主分区
1 // 分区号1
回车 // 起始扇区选择默认
回车 // 中止扇区选择默认
p // 查看创建出来的分区
w // 保存
[root@test-bgd-cdh-04 ~]# fdisk /dev/vdc
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 0x6f6f0be5.
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-4194303999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303999, default 4194303999):
Using default value 4194303999
Partition 1 of type Linux and of size 2 TiB is set
Command (m for help): p
Disk /dev/vdc: 2147.5 GB, 2147483648000 bytes, 4194304000 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: 0x6f6f0be5
Device Boot Start End Blocks Id System
/dev/vdc1 2048 4194303999 2097150976 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
格式化分区
可格式为ext4或xfs
注:若选择xfs,需要匹配docker默认overlay2存储驱动,建议使用命令:
mkfs.xfs -f -n ftype=1 /dev/vdc1
新添加硬盘分区挂载到指定文件目录
mkdir -p /work/disk2
mount /dev/vdc1 /work/disk2
实现开机自动挂载
vi /etc/fstab
/dev/vdc1 /work/disk2 xfs defaults 1 2
[第一列]可以是实际分区名,也可以是实际分区的卷标;
如果磁盘是SATA接口,且有多个磁盘,则每个磁盘被标记为 /dev/hda,/dev/hdb,/dev/hdc 等以此类推
而每个磁盘的分区被标记为 /dev/hda1,/dev/hda2等
如果磁盘是SCSI类型,则多个磁盘会被分别标记为 /dev/sda,/dev/sdb等等。分区同理。
如果使用标签来表示,则格式如:
LABLE=/
[第二列]是挂载点。
挂载点必须为当前已经存在的目录,为了兼容起见,最好在创建需要挂载的目标目录后,将其权限设置为777,以开放所有权限。
[第三列]为此分区的文件系统类型。
Linux可以使用ext2、ext3等类型,此字段须与分区格式化时使用的类型相同。也可以使用 auto 这一特殊的语法,使系统自动侦测目标分区的分区类型。auto通常用于可移动设备的挂载。
[第四列]是挂载的选项,用于设置挂载的参数。
auto: 系统自动挂载,fstab默认就是这个选项
defaults: rw, suid, dev, exec, auto, nouser, and async.
noauto 开机不自动挂载
nouser 只有超级用户可以挂载
ro 按只读权限挂载
rw 按可读可写权限挂载
user 任何用户都可以挂载
请注意光驱和软驱只有在装有介质时才可以进行挂载,因此它是noauto
[第五列]是dump备份设置。
当其值设置为1时,将允许dump备份程序备份;设置为0时,忽略备份操作;
[第六列]fsck磁盘检查设置。
其值是一个顺序。当其值为0时,永远不检查;而 / 根目录分区永远都为1。其它分区从2开始,数字越小越先检查,如果两个分区的数字相同,则同时检查。
重启验证是否成功
reboot