오라클 클라우드 Block Volume 사이즈 온라인 변경
이번에 오라클 클라우드의 컴퓨팅 서비스에서 릴리즈된 기능은 온라인 상에서 다운타임 없이 Block Storage의 사이즈를 변경할 수 있는 기능이다
1. 준비사항
Compute Instance를 하나 생성하고 기본 boot volume에 추가로 block volume을 붙인다.
이렇게 boot volume에는 50GB, 추가로 붙인 블록 스토리지는 53.7GB가 할당되어 있고 마운트되어 있다.
[opc@instance-20200602-1131 ~]$ sudo fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 50.0 GB, 50010783744 bytes, 97677312 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: gpt
Disk identifier: 90A92FCA-07A3-4B9F-9F15-625C42866C60
# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 17188863 8G Linux swap
3 17188864 97675263 38.4G Microsoft basic
Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0xba74df0f
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104857599 52427776 83 Linux
2. Boot Volume 확장
Compute → Boot Volumes으로 진입하면 현재 생성되어 있는 Boot Volume을 확인 할 수 있다.
변경을 원하는 Boot Volume을 선택하고 Edit Size or Performance를 선택한다.
선택하면 사이즈를 변경(증가만 가능)할 수 있는데 워닝에 있는 것 처럼 블록 Volume의 사이즈는 변경이 되더라도 파티션을 늘려주는 작업은 추가로 수행해야 한다.
https://docs.cloud.oracle.com/en-us/iaas/Content/Block/Tasks/rescanningdisk.htm
Rescanning the Disk for a Block Volume or Boot Volume
Rescanning the Disk for a Block Volume or Boot Volume The Oracle Cloud Infrastructure Block Volume service lets you expand the size of block volumes and boot volumes while they are online and attached to instances, for more information, see Online Resizing
docs.cloud.oracle.com
https://docs.cloud.oracle.com/en-us/iaas/Content/Block/Tasks/extendingbootpartition.htm
Extending the Partition for a Boot Volume
Extending the Partition for a Boot Volume When you create a new virtual machine (VM) instance or bare metal instance based on an Oracle-provided image or custom image, you have the option of specifying a custom boot volume size. You can also expand the siz
docs.cloud.oracle.com
Save를 하게 되면 친절하게 Rescan 명령어를 보여주니 그것을 복사해서 해당 Instance에 들어가서 수행한다.
해당 Instance에 들어가서 확인을 해보면 아직 확장된 볼륨으로 표시가 되지 않는다.
[opc@instance-20200602-1131 ~]$ sudo fdisk -l /dev/sda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 50.0 GB, 50010783744 bytes, 97677312 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: gpt
Disk identifier: 90A92FCA-07A3-4B9F-9F15-625C42866C60
# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 17188863 8G Linux swap
3 17188864 97675263 38.4G Microsoft basic
그래서 위의 명령어를 수행해줌으로써 다시 스토리지 스캔을 한뒤 사이즈를 확인해보면 확장되어 있는 것을 알 수 있다.
[opc@instance-20200602-1131 ~]$ sudo dd iflag=direct if=/dev/sda of=/dev/null count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.00124005 s, 413 kB/s
[opc@instance-20200602-1131 ~]$ echo "1" | sudo tee /sys/class/block/sda/device/rescan
1
[opc@instance-20200602-1131 ~]$ sudo fdisk -l /dev/sda
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 97677311 48838655+ ee GPT
Partition 1 does not start on physical sector boundary.
하지만 아직 파티션은 확장되지 않아서 확장을 해줘야 한다.
[opc@instance-20200602-1131 ~]$ df -kh
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 17M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda3 39G 2.0G 37G 5% /
/dev/sda1 200M 9.7M 191M 5% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/1000
/dev/sdb1 50G 53M 47G 1% /home/opc/mnt
파티션 확장 시 parted의 resizepart는 사용할 수 없고(unmount를 해야 한다) 가이드에 있는 문서로 작업시 오류가 발생한다. 그래서 boot volume은 실시간 사이즈 증가는 가능하지만 결국 파티션 작업시 single mode로 부팅 후 작업을 해야 할 것 같다.
** Updated
Oracle Linux는 OCI Utility를 통해 파티션 조절을 할 수 있는 것 같고, 타 리눅스의 경우에는 parted로 해결하는 방법을 찾았음
https://ctech.cyou/2021/12/30/oracle-ubuntu-extend-boot-volume/
Oracle Ubuntu Extend Boot Volume – C-Tech
sudo dd iflag=direct if=/dev/oracleoci/oraclevda of=/dev/null count=1 echo “1” | sudo tee /sys/class/block/`readlink /dev/oracleoci/oraclevda | cut -d’/’ -f 2`/device/rescan [email protected]:/home/ubuntu# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTP
ctech.cyou
3. Block Volume 확장
Boot Volume 확장과 동일한 방식으로 콘솔에서 확장을 하면 된다.
sudo dd iflag=direct if=/dev/sdb of=/dev/null count=1
echo "1" | sudo tee /sys/class/block/sdb/device/rescan
50GB에서 150GB로 확장을 했다
리눅스에서 확인해보면 여전히 그대로로 남아 있어 스캔을 해줘야 한다.
[opc@instance-20200602-1131 ~]$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0xba74df0f
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104857599 52427776 83 Linux
스캔 후 확인을 하면 확장되어 있는 것을 확인 할 수 있다.
[opc@instance-20200602-1131 ~]$ sudo dd iflag=direct if=/dev/sdb of=/dev/null count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000935175 s, 547 kB/s
[opc@instance-20200602-1131 ~]$ echo "1" | sudo tee /sys/class/block/sdb/device/rescan
1
[opc@instance-20200602-1131 ~]$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0xba74df0f
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104857599 52427776 83 Linux
https://docs.cloud.oracle.com/en-us/iaas/Content/Block/Tasks/extendingblockpartition.htm
Extending the Partition for a Block Volume
Extending the Partition for a Block Volume The Oracle Cloud Infrastructure Block Volume service lets you expand the size of block volumes with offline volume resizing. For more information, see Resizing a Volume. In order to take advantage of the larger vo
docs.cloud.oracle.com
위 설명처럼 수행을 하면 남은 공간을 할당 할 수 있다. 참고로 파티션 작업을 위해서는 마운트 된 부분을 언마운트 한 뒤 수행해야 한다.
[opc@instance-20200602-1402 ~]$ sudo parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) p
Model: ORACLE BlockVolume (scsi)
Disk /dev/sdb: 314572800s
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2048s 104857599s 104855552s primary ext4
(parted) rm 1
(parted) mkpart
Partition type? primary/extended? p
File system type? [ext2]? ext4
Start? 2048s
End? 100%
(parted) p
Model: ORACLE BlockVolume (scsi)
Disk /dev/sdb: 314572800s
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2048s 314572799s 314570752s primary ext4
(parted) quit
Information: You may need to update /etc/fstab.
[opc@instance-20200602-1402 ~]$ sudo fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 50.0 GB, 50010783744 bytes, 97677312 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: gpt
Disk identifier: 90A92FCA-07A3-4B9F-9F15-625C42866C60
# Start End Size Type Name
1 2048 411647 200M EFI System EFI System Partition
2 411648 17188863 8G Linux swap
3 17188864 97675263 38.4G Microsoft basic
Disk /dev/sdb: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x0001314e
Device Boot Start End Blocks Id System
/dev/sdb1 2048 314572799 157285376 83 Linux
[opc@instance-20200602-1402 ~]$ sudo mount /dev/sdb1 ./mnt
[opc@instance-20200602-1402 ~]$ df -kh
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 17M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda3 39G 2.0G 37G 5% /
/dev/sda1 200M 9.7M 191M 5% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/1000
/dev/sdb1 50G 53M 47G 1% /home/opc/mnt
[opc@instance-20200602-1402 ~]$ sudo resize2fs /dev/sdb1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/sdb1 is mounted on /home/opc/mnt; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 19
The filesystem on /dev/sdb1 is now 39321344 blocks long.
[opc@instance-20200602-1402 ~]$ df -kh
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 17M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda3 39G 2.0G 37G 5% /
/dev/sda1 200M 9.7M 191M 5% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/1000
/dev/sdb1 148G 60M 141G 1% /home/opc/mnt
파티션을 Resize하고 난뒤에 꼭 파일시스템도 resize해줘야 한다.