Linux如何将未分配的硬盘挂载出来

情景说明

客户给了几台服务器,说500G硬盘,但到手操作的时候,使用命令查看,发现只有不到200的硬盘

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 6.8G 44G 14% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 88K 63G 1% /dev/shm
tmpfs 63G 272M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/mapper/centos-home 48G 6.7G 41G 15% /home
/dev/sda1 497M 158M 340M 32% /boot
tmpfs 13G 24K 13G 1% /run/user/0

再使用fdisk查看,发现的确是500G硬盘,但挂载的只有100多

[root@localhost ~]# fdisk -l

Disk /dev/sda: 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: 0x000a3e10

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 209715199 104344576 8e Linux LVM

Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 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: 2147 MB, 2147483648 bytes, 4194304 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-home: 50.9 GB, 50944016384 bytes, 99500032 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)使用fdisk进入待分区的磁盘中(fdisk -l可以查看只有一块硬盘):

fdisk /dev/sda

(2)新增一个主分区:p --> n --> 三次enter默认 --> p --> w

(3)刷新sda分区表:partprobe

(4)对刚分好分区的磁盘格式化:mkfs.ext3 /dev/sda3

(5)创建挂载点:mkdir /test

(6)查看UUID:blkid

(7)更改/etc/fstab文件,如:echo "/dev/sda3 /test ext3 defaults 1 1 " >> /etc/fstab

(8)挂载文件系统:mount -a

再次使用fdisk能看到多了一个分区

[root@localhost ~]# fdisk -l

Disk /dev/sda: 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: 0x000a3e10

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 209715199 104344576 8e Linux LVM
/dev/sda3 209715200 1048575999 419430400 83 Linux

posted @ 2019-09-04 11:42  wswang  阅读(3875)  评论(3)    收藏  举报