버추얼 박스 5.1.26 버전에서 CentOS 서버를 운영하다 저장소가 부족해진 상황이 되었다.

8G를 셋팅했는데, 15G로 늘리고자 한다.

 

작업 순서는

1) 윈도우 커맨드 창에서 버추얼박스에 설정된 용량을 늘려주고,

2) 가상 서버에 접속해서 파티션을 새로 설정해서 늘린 용량을 적용해주는 순서로 진행된다.

 

 

우선, 윈도우 커맨트 창에서 작업을 위해, 머신의 vdi 파일이 저장된 위치를 확인해야 한다.

 

 

대상 머신의 설정을 확인하면, 저장소 탭에 위치가 나온다.

아래 이미지에서, C:\Users\arnd\VirtualBox VMs\CeontOs6.5_20180814\CeontOs6.5.vdi 가 된다.

 

 

위에서 파일 위치를 확인했으면, Windows+C 단축키를 사용하여 윈도우 커맨드창을 연다.

VBoxManage.exe 파일을 사용해야 하는데, 해당 파일이 있는 위치로 이동하거나 full 경로를 확인한다.

아래처럼 VBoxManage 명령으로 버추얼박스 머신의 용량을 늘려준다.

1G에 1024 곱하기..12288은 12G로 늘리기 위함이다.

 

C:\Users\arnd>cd "c:\Program Files\Oracle\VirtualBox"

 

c:\Program Files\Oracle\VirtualBox>VBoxManage modifyhd "C:\Users\arnd\VirtualBox VMs\CeontOs6.5_20180814\CeontOs6.5.vdi" --resize 12288
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

 

 

버추얼박스의 설정창을 다시 열면 12G로 바뀌어져 있다.

이제, 윈도우에서 할 일은 끝났고, 해당 머신을 시작하여 리눅스로 진입한다.

 

 

 

아래 작업은 CentOs 기준으로 이루어졌다.

 


[root@localhost ~]# df -h
Filesystem                                     Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root          6.5G  5.9G  277M  96% /
tmpfs                                            499M     0  499M   0% /dev/shm
/dev/sda1                                     477M   83M  369M  19% /boot

[root@localhost ~]# fdisk -l

 

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1045     7875584   8e  Linux LVM


 

8G 중에 대부분 차지하는 sda2 파티션을 삭제했다가 늘린 용량으로 다시 생성할 것이다.

 

[root@localhost ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): d        -- 파티션 지우기

Partition number (1-4): 2        -- sda2를 삭제할 것으로 선택

Command (m for help): n        -- 새로운 파티션을 생성

Command action
   e   extended
   p   primary partition (1-4)
p                                      -- Primary 파티션 선택

 

Partition number (1-4): 2        -- sda2번으로 생성

First cylinder (64-1958, default 64):
Using default value 64
Last cylinder, +cylinders or +size{K,M,G} (64-1958, default 1958):
Using default value 1958

 

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: 장치나 자원이 동작 중.
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.


[root@localhost ~]# reboot                    -- 재부팅


[root@localhost ~]# pvresize /dev/sda2    -- 물리볼륨을 리사이징 한다

  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

 

[root@localhost ~]# pvscan                -- 반영여부를 확인한다

  PV /dev/sda2   VG VolGroup        lvm2 [14.51 GiB / 7.00 GiB free]
  Total: 1 [14.51 GiB] / in use: 1 [14.51 GiB] / in no VG: 0 [0   ]

 

[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/VolGroup-lv_root
-- 증설되어 사용가능해진 저장소용량을 논리볼륨에 매핑한다 이때, 사용가능한 모든 용량을 매핑한다(100%FREE)

 

  Size of logical volume VolGroup/lv_root changed from 6.71 GiB (1718 extents) to 13.71 GiB (3510 extents).
  Logical volume lv_root successfully resized.

 

[root@localhost ~]# resize2fs /dev/mapper/VolGroup-lv_root    -- 수정내용을 반영한다

resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 3594240 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 3594240 blocks long.

 

[root@localhost ~]# df -h
Filesystem                                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root         14G  5.9G  6.9G  47% /
tmpfs                                           499M     0  499M   0% /dev/shm
/dev/sda1                                    477M   83M  369M  19% /boot 

 

 

참조 : http://egloos.zum.com/repository/v/5730315

+ Recent posts