문서번호 : 51-537655
Document Information
•
최초 작성일 : 2022.09.23
•
최종 수정일 : 2022.09.23
•
이 문서는 아래 버전을 기준으로 작성되었습니다.
◦
OCI - Oracle Cloud
Goal
Compute instance의 boot volume 크기를 확장한다.
Solution
OCI console에서 boot volume을 resize하거나, Compute instance생성시 원하는 boot volume 크기를 지정해 storage를 배정한다. 그렇지만, root filesystem은 template image의 restore 결과물이기에 file system의 크기는 boot volume을 확장하더라도 기존과 같은 크기이다.
compute instance의 기본 partition 상태는 다음과 같이 38.4G 이다. 이미 disk는 resize되어 70G임이 확인된다.
[opc@jn-n2 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 70G 0 disk
├─sda2 8:2 0 8G 0 part [SWAP]
├─sda3 8:3 0 38.4G 0 part /
└─sda1 8:1 0 200M 0 part /boot/efi
Plain Text
복사
이하 작업은 편의상 root 계정에서 작업한다.
(옵션)이미 동작중인 instance의 boot volume을 확장했다면 다음 작업으로 size변화를 인식시킨다.
[root@jn-n2 ~]# 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.000687201 s, 745 kB/s
[root@jn-n2 ~]# echo "1" | tee /sys/class/block/sda/device/rescan
1
Plain Text
복사
boot volume의 partition과 file system의 크기를 최대로 확장하는 명령어를 OCI에 기본 제공한다.
만약 존재하지 않거나, old version이라면 ‘sudo yum update oci-utils’ 로 설치 또는 갱신한다.
[root@jn-n2 ~]# /usr/libexec/oci-growfs
Mountpoint Data
---------------
mountpoint: /
source: /dev/sda3
filesystem type: xfs
source size: 38.4G
type: part
size: 38.4G
physical devices: ['/dev/sda3']
physical volumes: ['/dev/sda']
partition number: ['3']
Partition dry run expansion "/dev/sda3" succeeded.
CHANGE: partition=3 start=17188864 old: size=80486400 end=97675264 new: size=129611742 end=146800606
Expanding partition /dev/sda3: Confirm? [y/N] y
Partition expand expansion "/dev/sda3" succeeded.
update-partition set to true
resizing 3 on /dev/sda using resize_sgdisk_gpt
disk=/dev/sda partition=3: original sgdisk info:
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data)
Partition unique GUID: DD484EE9-7227-4C1D-A713-9A61DC58B595
First sector: 17188864 (at 8.2 GiB)
Last sector: 97675263 (at 46.6 GiB)
Partition size: 80486400 sectors (38.4 GiB)
Attribute flags: 0000000000000000
Partition name: ''
Disk /dev/sda: 146800640 sectors, 70.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 761A7D13-7CFA-46A1-AECD-1A2EFB5D239A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 97677278
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB EF00 EFI System Partition
2 411648 17188863 8.0 GiB 8200
3 17188864 97675263 38.4 GiB 0700
disk=/dev/sda partition=3: pretend sgdisk info
Disk /dev/sda: 146800640 sectors, 70.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 761A7D13-7CFA-46A1-AECD-1A2EFB5D239A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 146800606
Partitions will be aligned on 2048-sector boundaries
Total free space is 49127357 sectors (23.4 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB EF00 EFI System Partition
2 411648 17188863 8.0 GiB 8200
3 17188864 97675263 38.4 GiB 0700
disk=/dev/sda partition=3: pt_start=17188864 pt_end=97675264 pt_size=80486400 pt_max=146800606 last=146800606
disk=/dev/sda partition=3: code=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 guid=DD484EE9-7227-4C1D-A713-9A61DC58B595 name=''
CHANGED: partition=3 start=17188864 old: size=80486400 end=97675264 new: size=129611742 end=146800606
Resizing filesystem at / succeeded.
File system xfs on /dev/sda3 extended successfully.
[root@jn-n2 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 16251960 0 16251960 0% /dev
tmpfs 16290116 0 16290116 0% /dev/shm
tmpfs 16290116 8936 16281180 1% /run
tmpfs 16290116 0 16290116 0% /sys/fs/cgroup
/dev/sda3 64786220 3781212 61005008 6% /
/dev/sda1 204580 7484 197096 4% /boot/efi
tmpfs 3258024 0 3258024 0% /run/user/0
tmpfs 3258024 0 3258024 0% /run/user/994
tmpfs 3258024 0 3258024 0% /run/user/1000
Plain Text
복사
oci-growfs 후 partition 상태는 다음과 같다.
[root@jn-n2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 70G 0 disk
├─sda2 8:2 0 8G 0 part [SWAP]
├─sda3 8:3 0 61.8G 0 part /
└─sda1 8:1 0 200M 0 part /boot/efi
Plain Text
복사
References
History
일자 | 작성자 | 비고 |
2022.09.23 | jnshin | 최초작성 |