Linux環境下增加磁盤

在Linux環境下增加磁盤(包括物理機器上增加磁盤,或者在雲環境增加磁盤),都需要將磁盤格式化,並掛載到指定目錄下。
以阿里雲環境下,增加一塊高效雲盤爲例。

使用fdisk增加分區

增加一塊1T的高效雲盤以後,使用fdisk查看,會發現新增了一塊磁盤/dev/vdb

root@iZt4n2xe04owrybltp05j6Z:~# fdisk -l
Disk /dev/vda: 40 GiB, 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
Disklabel type: dos
Disk identifier: 0xb2ac676a

Device     Boot Start      End  Sectors Size Id Type
/dev/vda1  *     2048 83886046 83883999  40G 83 Linux


Disk /dev/vdb: 1 TiB, 1099511627776 bytes, 2147483648 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
root@iZt4n2xe04owrybltp05j6Z:~# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.31.1).
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.
Created a new DOS disklabel with disk identifier 0xaf33802a.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2147483647, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-2147483647, default 2147483647):

Created a new partition 1 of type 'Linux' and of size 1024 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

查看新分區的情況,可以看到已經有了一個分區信息/dev/vdb1

root@iZt4n2xe04owrybltp05j6Z:~# fdisk -l
Disk /dev/vda: 40 GiB, 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
Disklabel type: dos
Disk identifier: 0xb2ac676a

Device     Boot Start      End  Sectors Size Id Type
/dev/vda1  *     2048 83886046 83883999  40G 83 Linux


Disk /dev/vdb: 1 TiB, 1099511627776 bytes, 2147483648 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
Disklabel type: dos
Disk identifier: 0xaf33802a

Device     Boot Start        End    Sectors  Size Id Type
/dev/vdb1        2048 2147483647 2147481600 1024G 83 Linux

格式化磁盤

有了新的分區,需要在對分區格式化

mkfs.ext4 /dev/vdb1

掛載到指定目錄

mkdir /data
mount /dev/vdb1 /data

這樣,就可以使用新的磁盤空間了。

對於磁盤空間大於2TB的情況,阿里雲環境下,需要額外處理,可以參考:
https://help.aliyun.com/document_detail/34377.html?spm=a2c4g.11186623.2.26.29d37d56A660p1#concept-i15-qpc-ydb

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章