虚拟机也好,物理机也罢,在CentOS的使用过程中都有可能会出现需要增加磁盘的情况,这篇文章就是介绍如何为新磁盘进行分区以及挂载操作。
所有操作都在root用户下进行。
查看当前磁盘使用状况
# df -hFilesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 18G 15G 3.3G 82% /
devtmpfs 902M 0 902M 0% /dev
tmpfs 912M 0 912M 0% /dev/shm
tmpfs 912M 8.6M 904M 1% /run
tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 197M 119M 79M 61% /boot
tmpfs 183M 0 183M 0% /run/user/0
列出现有的磁盘及分区信息
# fdisk -l# /dev/sda 是原有的磁盘,可以看到这块磁盘下面的分区信息
Disk /dev/sda: 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: 0x000b4958
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 41943039 20765696 8e Linux LVM
/dev/sda3 41943040 83886079 20971520 83 Linux
# /dev/sdb 就是我们刚添加的磁盘(如果原来只有一块磁盘的话),可以看到这块磁盘下面没有任何分区
Disk /dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sect