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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM