Alibaba Cloud ECS イメージ機能のディスクサイズの拡張方法
作成日:2020/01/07この記事は最終更新日から2年以上が経過しています。
Alibaba Cloud ECS イメージ機能のディスクサイズの拡張方法
今回は、Alibaba Cloud ECS イメージ機能のディスクサイズの拡張方法を紹介します。
拡張する前のディスク状況はこんな感じです。
# fdisk -lデバイス ブート 始点 終点 ブロック Id システム/dev/vda1 * 2048 2099199 1048576 83 Linux/dev/vda2 2099200 16777215 7339008 8e Linux LVM
今回は新たに /dev/vda3 を作成し、使っていないディスクサイズを割り当てました。
# fdisk -lデバイス ブート 始点 終点 ブロック Id システム/dev/vda1 * 2048 2099199 1048576 83 Linux/dev/vda2 2099200 16777215 7339008 8e Linux LVM/dev/vda3 16777216 209715199 96468992 8e Linux LVM
拡張方法はこちらです。
# fdisk /dev/vdanp3[enter][enter]t38epw# reboot ※ここでrebootしないと/dev/vda3が認識されません。# pvcreate /dev/vda3# pvdisplay# vgextend rhel /dev/vda3# vgdisplay# lvextend -l +100%FREE /dev/rhel/root# xfs_growfs /dev/rhel/root# df -h
実行 log はこちらです。
[root@Redhat ~]# fdisk /dev/vdaWelcome 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.コマンド (m でヘルプ): nPartition type:p primary (2 primary, 0 extended, 2 free)e extendedSelect (default p): pパーティション番号 (3,4, default 3): 3最初 sector (16777216-209715199, 初期値 16777216):初期値 16777216 を使いますLast sector, +sectors or +size{K,M,G} (16777216-209715199, 初期値 209715199):初期値 209715199 を使いますPartition 3 of type Linux and of size 92 GiB is setコマンド (m でヘルプ): tパーティション番号 (1-3, default 3): 3Hex code (type L to list all codes): 8eChanged type of partition 'Linux' to 'Linux LVM'コマンド (m でヘルプ): pDisk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O サイズ (最小 / 推奨): 512 バイト / 512 バイトDisk label type: dosディスク識別子: 0x000b4c65デバイス ブート 始点 終点 ブロック Id システム/dev/vda1 * 2048 2099199 1048576 83 Linux/dev/vda2 2099200 16777215 7339008 8e Linux LVM/dev/vda3 16777216 209715199 96468992 8e Linux LVMコマンド (m でヘルプ): wパーティションテーブルは無事変更されました。ioctl() を呼び出してパーティションテーブルを再読込みします。WARNING: Re-reading the partition table failed with error 16: デバイスもしくはリソースがビジー状態です.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)ディスクを同期しています。[root@Redhat ~]# pvcreate /dev/vda3Device /dev/vda3 not found.[root@Redhat ~]# reboot[root@Redhat ~]# pvcreate /dev/vda3Physical volume "/dev/vda3" successfully created.[root@Redhat ~]#[root@Redhat ~]#[root@Redhat ~]# pvdisplay--- Physical volume ---PV Name /dev/vda2VG Name rhelPV Size <7.00 GiB / not usable 3.00 MiBAllocatable yes (but full)PE Size 4.00 MiBTotal PE 1791Free PE 0Allocated PE 1791PV UUID UZVses-HbtL-iC7Z-fYVE-bE1D-8eCQ-idvSTJ"/dev/vda3" is a new physical volume of "92.00 GiB"--- NEW Physical volume ---PV Name /dev/vda3VG NamePV Size 92.00 GiBAllocatable NOPE Size 0Total PE 0Free PE 0Allocated PE 0PV UUID baejtP-mYYS-7J6K-hmTr-tLKZ-XlWJ-pZS3Pl[root@Redhat ~]# vgextend rhel /dev/vda3Volume group "rhel" successfully extended[root@Redhat ~]# vgdisplay--- Volume group ---VG Name rhelSystem IDFormat lvm2Metadata Areas 2Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 2Open LV 2Max PV 0Cur PV 2Act PV 2VG Size 98.99 GiBPE Size 4.00 MiBTotal PE 25342Alloc PE / Size 1791 / <7.00 GiBFree PE / Size 23551 / <92.00 GiBVG UUID 2Q1PbX-fe2g-ebBn-Dxd6-0g9o-WhFj-rpfn1I[root@Redhat ~]# lvextend -l +100%FREE /dev/rhel/rootSize of logical volume rhel/root changed from <6.20 GiB (1586 extents) to 98.19 GiB (25137 extents).Logical volume rhel/root successfully resized.[root@Redhat ~]#[root@Redhat ~]# xfs_growfs /dev/rhel/rootmeta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=406016 blks= sectsz=512 attr=2, projid32bit=1= crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=1624064, imaxpct=25= sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal bsize=4096 blocks=2560, version=2= sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0data blocks changed from 1624064 to 25740288[root@Redhat ~]#[root@Redhat ~]# df -hファイルシス サイズ 使用 残り 使用% マウント位置/dev/mapper/rhel-root 99G 1.7G 97G 2% /devtmpfs 3.9G 0 3.9G 0% /devtmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 3.9G 8.6M 3.9G 1% /runtmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/vda1 1014M 148M 867M 15% /boottmpfs 783M 0 783M 0% /run/user/0[root@Redhat ~]#[root@Redhat ~]#[root@Redhat ~]# fdisk -lDisk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O サイズ (最小 / 推奨): 512 バイト / 512 バイトDisk label type: dosディスク識別子: 0x000b4c65デバイス ブート 始点 終点 ブロック Id システム/dev/vda1 * 2048 2099199 1048576 83 Linux/dev/vda2 2099200 16777215 7339008 8e Linux LVM/dev/vda3 16777216 209715199 96468992 8e Linux LVMDisk /dev/mapper/rhel-root: 105.4 GB, 105432219648 bytes, 205922304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O サイズ (最小 / 推奨): 512 バイト / 512 バイトDisk /dev/mapper/rhel-swap: 859 MB, 859832320 bytes, 1679360 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
以上となります。最後まで読んでいただき、ありがとうございました。
Alibaba Cloudを始めてみましょう
ソフトバンクは、Alibaba Cloudのアカウント開設から、サービス展開までをお手伝いします。
このページは参考になりましたか?