阿里云磁盤擴展操作筆記

磁盤擴展

查看磁盤

現(xiàn)有一個300GB的磁盤設(shè)備/dev/vda,有一個主分區(qū)并掛載于/dev/vda1下。

[root@kubernetes ~]# fdisk -l /dev/vda

Disk /dev/vda: 322.1 GB, 322122547200 bytes, 629145600 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: 0x0008d73a

Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   209713151   104855552   83  Linux

查看分區(qū)所占存儲大小

可以看到主分區(qū)分配了100G的磁盤空間

[root@kubernetes ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        99G   60G   34G  64% /

還有200GB的存儲空間實際上是新增的存儲,還沒有分配使用。

查看文件系統(tǒng)類型

查看一下該分區(qū)所使用的文件系統(tǒng)類型,這里實際是使用的ext4。

[root@kubernetes rpms]# blkid /dev/vda1
/dev/vda1: UUID="eb448abb-3012-4d8d-bcde-94434d586a31" TYPE="ext4" 

創(chuàng)建新分區(qū)及分配存儲空間

[root@kubernetes ~]# fdisk -u /dev/vda
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.


Command (m for help): p

Disk /dev/vda: 322.1 GB, 322122547200 bytes, 629145600 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: 0x0008d73a

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   209713151   104855552   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (209713152-629145599, default 209713152): 
Using default value 209713152
Last sector, +sectors or +size{K,M,G} (209713152-629145599, default 629145599): 
Using default value 629145599
Partition 2 of type Linux and of size 200 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

其中有一段WARNING

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

可以使用partprobe指令處理,具體詳情可以考慮該文檔

https://blog.csdn.net/yusiguyuan/article/details/25396123

查看新分區(qū)情況

lsblk /dev/vda

通過該指令將看到新的分區(qū)/dev/vda2.

格式化新的分區(qū)

使用mkfs.ext4指令創(chuàng)建ext4文件系統(tǒng):

[root@kubernetes ~]# mkfs.ext4 /dev/vda2
mke2fs 1.42.9 (28-Dec-2013)
warning: 256 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13132800 inodes, 52428800 blocks
2621439 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2199912448
1600 block groups
32768 blocks per group, 32768 fragments per group
8208 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done     

查看新分區(qū)的詳情

[root@kubernetes ~]# blkid /dev/vda2
/dev/vda2: UUID="f7f6ca5e-7271-yyyy-xxxx-c746164ad124" TYPE="ext4" 

將新分區(qū)掛載到文件系統(tǒng)指定路徑

運行mount /dev/vda2 /mnt掛載文件系統(tǒng)。

[root@kubernetes ~]# mount /dev/vda2 /mnt

查看磁盤使用情況

[root@kubernetes ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        99G   83G   11G  89% /
/dev/vda1        99G   83G   11G  89% /
/dev/vda2       197G   61M  187G   1% /mnt

//TODO

系統(tǒng)啟動自動掛載新分區(qū)

5.設(shè)置開機自動掛載,打開自動掛載文件:vi /etc/fstab,加入如下圖所示內(nèi)容行:

image

保存退出,重啟主機看下是否自動掛載:df -lh

image

PV配置優(yōu)化

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 目錄磁盤結(jié)構(gòu)磁盤分區(qū)磁盤分區(qū)管理文件系統(tǒng)管理掛載 一、磁盤結(jié)構(gòu) (一)設(shè)備文件 設(shè)備文件:linux系統(tǒng)下一切皆文...
    哈嘍別樣閱讀 1,211評論 0 0
  • 1 概述 本文通過對講解了磁盤的基本概念,分區(qū),創(chuàng)建文件系統(tǒng),掛載,卸載等步驟進行講解。使得用戶能夠創(chuàng)建基本的磁盤...
    ghbsunny閱讀 1,729評論 0 0
  • 一.分區(qū)工具fdisk (1)分區(qū)工具fdisk工具的使用:fdisk -l -u :查看分區(qū)表,該命令是在磁盤上...
    楠人幫閱讀 819評論 0 1
  • 目錄(持續(xù)更新) 基礎(chǔ)-第0章-安裝基礎(chǔ)-第1章-基本操作基礎(chǔ)-第2章-磁盤及文件系統(tǒng)管理基礎(chǔ)-第3章-獲得幫助基...
    sky92archangel閱讀 768評論 0 0
  • 以前,總是認為,既然已經(jīng)接受完了系統(tǒng)性的學(xué)校教育,那么,是否就意味著成長完畢,就像產(chǎn)品已經(jīng)走完了流水線,只需按照計...
    秋葉瑟瑟閱讀 357評論 1 0

友情鏈接更多精彩內(nèi)容