Skip to content

Commit c273efc

Browse files
committed
feat: add virtualbox-centos-disk.mdx
1 parent 32e87d3 commit c273efc

File tree

3 files changed

+182
-0
lines changed

3 files changed

+182
-0
lines changed
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
---
2+
title: "Virtualbox CentOS Disk 용량 늘리기"
3+
date: "2020-05-22"
4+
tags: ["Etc", "Study"]
5+
summary: "Correcting the Insufficient Capacity of CentOS Disks in Virtual Box"
6+
description: "Virtualbox에서 CentOS 용량이 부족한 경우 해결하기"
7+
---
8+
9+
:::info
10+
개인적으로 리눅스 환경에서 개발하는 것을 선호하는데, 대부분의 프로그램들이 리눅스 서버에서 동작하기도 하며,
11+
많은 오픈 소스들이 리눅스 환경에서 개발되었기 때문이다. 때론, 윈도우에서 가상 머선으로 개발환경을 구축해서 개발을 진행했었는데,
12+
Virtualbox의 용량을 20GB 로 하였지만.. Disk Full 현상을 만나게 되었고, 여유롭게 40GB로 확장하는 방법을 정리해보았다.
13+
:::
14+
15+
16+
### 용량 확인
17+
18+
---
19+
20+
```shell
21+
[root@server02 cloudera-scm-server]# df -h
22+
Filesystem Size Used Avail Use% Mounted on
23+
/dev/mapper/vg_develop-lv_root
24+
18G 15G 1.4G 92% /
25+
tmpfs 3.9G 72K 3.9G 1% /dev/shm
26+
/dev/sda1 477M 79M 373M 18% /boot
27+
cm_processes 3.9G 12M 3.9G 1% /var/run/cloudera-scm-agent/process
28+
```
29+
30+
### Step1. 가상머신 전원 Off
31+
---
32+
33+
<div style={{ textAlign: 'center' }}>
34+
<img src="/img/post/etc/virtualbox/disk.png" alt="virtualbox" style={{ display: 'inline-block' }} />
35+
</div>
36+
37+
38+
### Step2. Windows 명령 프롬프트에서 VirtualBox가 설치 된 폴더로 이동
39+
---
40+
VirtualBox를 설치할 때 default로 설치하였다면, **C:\Program Files\Oracle\VirtualBox** 의 경로에 설치 되어 있다.
41+
42+
43+
### Step3. 가상 디스크 파일의 크기를 조정하는 명령어를 입력한다.
44+
---
45+
```shell
46+
VBoxManage modifyhd "D:\Disk\VM\centos2\centos2.vdi" --resize 40960
47+
```
48+
49+
<div style={{ textAlign: 'center' }}>
50+
<img src="/img/post/etc/virtualbox/cmd.png" alt="cmd" style={{ display: 'inline-block' }} />
51+
</div>
52+
53+
54+
### Step4. VirtualBox 실행 후 용량 확인
55+
---
56+
57+
```shell
58+
root@server02 develop]# fdisk -l
59+
Disk /dev/sda: 42.9 GB, 42949672960 bytes
60+
255 heads, 63 sectors/track, 5221 cylinders
61+
Units = cylinders of 16065 * 512 = 8225280 bytes
62+
Sector size (logical/physical): 512 bytes / 512 bytes
63+
I/O size (minimum/optimal): 512 bytes / 512 bytes
64+
Disk identifier: 0x000aab80
65+
```
66+
67+
### Step5. 파티션 설정
68+
---
69+
70+
```shell
71+
[root@server02 develop]# fdisk /dev/sda
72+
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
73+
switch off the mode (command 'c') and change display units to
74+
sectors (command 'u').
75+
Command (m for help): p
76+
Disk /dev/sda: 42.9 GB, 42949672960 bytes
77+
255 heads, 63 sectors/track, 5221 cylinders
78+
Units = cylinders of 16065 * 512 = 8225280 bytes
79+
Sector size (logical/physical): 512 bytes / 512 bytes
80+
I/O size (minimum/optimal): 512 bytes / 512 bytes
81+
Disk identifier: 0x000aab80
82+
Device Boot Start End Blocks Id System
83+
/dev/sda1 * 1 64 512000 83 Linux
84+
Partition 1 does not end on cylinder boundary.
85+
/dev/sda2 64 2611 20458496 8e Linux LVM
86+
Command (m for help): n
87+
Command action
88+
e extended
89+
p primary partition (1-4)
90+
p
91+
Partition number (1-4): 3
92+
First cylinder (2611-5221, default 2611): 2611
93+
Last cylinder, +cylinders or +size{K,M,G} (2611-5221, default 5221): 5221
94+
Command (m for help): t
95+
Partition number (1-4): 3
96+
Hex code (type L to list codes): 0x8e
97+
Type 0 means free space to many systems
98+
(but not to Linux). Having partitions of
99+
type 0 is probably unwise. You can delete
100+
a partition using the `d' command.
101+
Changed system type of partition 3 to 0 (Empty)
102+
Command (m for help): w
103+
The partition table has been altered!
104+
Calling ioctl() to re-read partition table.
105+
WARNING: Re-reading the partition table failed with error 16: 장치나 자원이 동작 중.
106+
The kernel still uses the old table. The new table will be used at
107+
the next reboot or after you run partprobe(8) or kpartx(8)
108+
Syncing disks.
109+
```
110+
111+
112+
### Step6. 가상머신 OS 재부팅
113+
---
114+
115+
```shell
116+
[root@server02 develop]# reboot
117+
```
118+
119+
### Step7. 새로운 물리 볼륨 생성(볼륨을 sda3으로 생성)
120+
---
121+
122+
```shell
123+
[root@server02 develop]# pvcreate /dev/sda3
124+
Physical volume "/dev/sda3" successfully created
125+
[root@server02 develop]# vgextend vg_develop-ly_root /dev/sda3
126+
```
127+
128+
### Step8. 새 파티션을 볼륨 그룹에 추가
129+
---
130+
131+
```shell
132+
[root@server02 develop]# vgextend vg_develop /dev/sda3
133+
Found duplicate PV xwu1FT418a7uKRvasGd2z8AmJ9JDXWVI: using /dev/sda4 not /dev/sda3
134+
Using duplicate PV /dev/sda4 which is last seen, replacing /dev/sda3
135+
Found duplicate PV xwu1FT418a7uKRvasGd2z8AmJ9JDXWVI: using /dev/sda3 not /dev/sda4
136+
Using duplicate PV /dev/sda3 which is last seen, replacing /dev/sda4
137+
Found duplicate PV xwu1FT418a7uKRvasGd2z8AmJ9JDXWVI: using /dev/sda4 not /dev/sda3
138+
Using duplicate PV /dev/sda4 which is last seen, replacing /dev/sda3
139+
Found duplicate PV xwu1FT418a7uKRvasGd2z8AmJ9JDXWVI: using /dev/sda3 not /dev/sda4
140+
Using duplicate PV /dev/sda3 which is last seen, replacing /dev/sda4
141+
Found duplicate PV xwu1FT418a7uKRvasGd2z8AmJ9JDXWVI: using /dev/sda4 not /dev/sda3
142+
Using duplicate PV /dev/sda4 which is last seen, replacing /dev/sda3
143+
Physical volume "/dev/sda3" successfully created
144+
Volume group "vg_develop" successfully extended
145+
```
146+
147+
### Step9. 파티션 확장
148+
---
149+
150+
```shell
151+
[root@server02 develop]# lvextend -L +19G /dev/mapper/vg_develop-lv_root
152+
Found duplicate PV 3V6e6wnIHbuSgOODKFgVQ1eGV7miy5uC: using /dev/sda4 not /dev/sda3
153+
Using duplicate PV /dev/sda4 which is last seen, replacing /dev/sda3
154+
Size of logical volume vg_develop/lv_root changed from 17.51 GiB (4482 extents) to 36.51 GiB (9346 extents).
155+
Logical volume lv_root successfully resized.
156+
```
157+
158+
### Step10. 파티션 크기 조정
159+
---
160+
161+
```shell
162+
[root@server02 develop]# resize2fs /dev/mapper/vg_develop-lv_root
163+
resize2fs 1.41.12 (17-May-2010)
164+
Filesystem at /dev/mapper/vg_develop-lv_root is mounted on /; on-line resizing required
165+
old desc_blocks = 2, new_desc_blocks = 3
166+
Performing an on-line resize of /dev/mapper/vg_develop-lv_root to 9570304 (4k) blocks.
167+
The filesystem on /dev/mapper/vg_develop-lv_root is now 9570304 blocks long.
168+
```
169+
170+
171+
### Step11. 확인
172+
---
173+
174+
```shell
175+
[root@server02 develop]# df -h
176+
Filesystem Size Used Avail Use% Mounted on
177+
/dev/mapper/vg_develop-lv_root
178+
36G 15G 20G 44% /
179+
tmpfs 3.9G 80K 3.9G 1% /dev/shm
180+
/dev/sda1 477M 79M 373M 18% /boot
181+
cm_processes 3.9G 5.4M 3.9G 1% /var/run/cloudera-scm-agent/process
182+
```
20 KB
Loading
55.2 KB
Loading

0 commit comments

Comments
 (0)