LoginSignup
0
0

More than 3 years have passed since last update.

AzureのOracle VM イメージから作ったVirtual MachineのOSディスクのサイズを増やす

Posted at

経緯

AzureのOracle VM イメージから作ったVirtual Machineのディスク容量が足りなくなり、ディスクサイズを増やした際の方法です。

筆者の環境

  • Azure Virtual Machines
  • Oracle Linux Server release 7.4
  • Oracle Database 12c Standard Edition Release 12.2.0.1.0

Azureの設定

仮想マシンを停止後、Azure Portalの該当Virtual Machineの[ディスク]でOSディスクを選択し、[構成]で、所望のディスクサイズを設定します。

ここで設定したサイズによって、価格とパフォーマンス上限が決まります。一度設定すると、そのサイズより縮小することではできません。
https://azure.microsoft.com/ja-jp/pricing/details/managed-disks/

Linuxの設定

現在のパーティションを確認します。ここでは、/にマウントされている、/dev/sda2のパーティションを拡張します。

$ sudo lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
sda      8:0    0   60G  0 disk
├─sda1   8:1    0  500M  0 part /boot
└─sda2   8:2    0 29.5G  0 part /
sdb      8:16   0    8G  0 disk
└─sdb1   8:17   0    8G  0 part /mnt/resource

/dev/sda2のパーティションをディスクいっぱいのサイズで作成し直します。

$ sudo fdisk /dev/sda

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
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): d
Partition number (1,2, default 2): 2
Partition 2 is deleted

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 (1026048-125829119, default 1026048):
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-125829119, default 125829119):
Using default value 125829119
Partition 2 of type Linux and of size 59.5 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.

再起動します。

$ sudo shutdown -r now

ファイルシステムに反映します。

$ sudo btrfs filesystem resize max /

以上で、パーティション/dev/sda2のサイズが拡張されました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0