Help us understand the problem. What is going on with this article?

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

経緯

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のサイズが拡張されました。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away