[Linux] 리눅스 VMware Workstation에서 용량 증설

 정보

  • 업무명     : 리눅스 VMware Workstation에서 용량 증설

  • 작성자     : 이상호

  • 작성일     : 2021-01-19

  • 설   명      :

  • 수정이력 :

 

 내용

[개요]

  • 안녕하세요? 기상 연구 및 웹 개발을 담당하고 있는 해솔입니다.

  • 오늘 포스팅에서는 VMware Workstation에서 용량 증설을 소개합니다.

 

 

[특징]

  • 리눅스에서 용량 증설을 위해서 파일 시스템 기술이 요구되며 이 프로그램은 이러한 목적을 달성하기 위한 기술서

 

[기능]

  • VMware Workstation 설정

  • Linux 설정

 

[활용 자료]

  • 없음

 

[자료 처리 방안 및 활용 분석 기법]

  • 없음

 

[명세]

  • 없음

 

[사용법]

  • 없음

 

[사용 OS]

  • Windows 10

 

[사용 언어]

  • Linux (CentOS v7.3)

  • VMware Workstation Pro v15.5

 

 용량 증설

[VMware Workstation 설정]

  • VMware Workstation에서 Edit virtual machine settings 선택

 

  • Virtual Machine Settings에서 Expand 선택

 

  • Expand Disk Capacity에서 500 GB 선택

 

 

[Linux 설정]

  • df 명령어를 증설 대상에 대한 현재 용량 (150 GB)작업 경로 (/dev/mapper/centos-root) 확인

[root linux@~]# df -h
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  893M     0  893M   0% /dev
tmpfs                   tmpfs     910M     0  910M   0% /dev/shm
tmpfs                   tmpfs     910M   11M  900M   2% /run
tmpfs                   tmpfs     910M     0  910M   0% /sys/fs/cgroup
/dev/mapper/centos-root xfs       150G  117G   34G  78% /
/dev/sda1               xfs      1014M  280M  735M  28% /boot
/dev/mapper/centos-home xfs        46G  8.3G   37G  19% /home
tmpfs                   tmpfs     182M   28K  182M   1% /run/user/0
/dev/sr0                iso9660   4.4G  4.4G     0 100% /run/media/root/CentOS 7 x86_64

 

 

  • fdisk 명령어를 통해 디스크 접속

[root linux@~]# fdisk /dev/sda
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): p

Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00036812

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   419430399   208665600   8e  Linux LVM

 

 

  • 물리적 볼륨 (physical volume) 및 Linux LVM 확인

Command (m for help): pvscan

Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00036812

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   419430399   208665600   8e  Linux LVM

 

 

  • fdisk에서 순차적으로 n, p, t, 8e, w 입력하여 파티션 생성

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (419430400-1048575999, default 419430400): 
Using default value 419430400
Last sector, +sectors or +size{K,M,G} (419430400-1048575999, default 1048575999): 
Using default value 1048575999
Partition 3 of type Linux and of size 300 GiB is set

Command (m for help): t
Partition number (1-3, default 3): 
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

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.

 

 

  • reboot 명령어를 통해 시스템 재시작

[root linux@~]# reboot

 

  • pvscan를 통해 물리적 볼륨 확인

[root linux@~]# pvscan
  PV /dev/sda2   VG centos          lvm2 [<199.00 GiB / 0    free]
  Total: 1 [<199.00 GiB] / in use: 1 [<199.00 GiB] / in no VG: 0 [0   ]

 

 

  • pvcreate 명령어를 통해 물리적 볼륨 생성

[root linux@~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created.

 

 

  • pvscan 명령어를 통해 용량 확인

[root linux@~]# pvscan
  PV /dev/sda2   VG centos          lvm2 [<199.00 GiB / 0    free]
  PV /dev/sda3                      lvm2 [300.00 GiB]
  Total: 2 [<499.00 GiB] / in use: 1 [<199.00 GiB] / in no VG: 1 [300.00 GiB]

 

 

  • vgdisplay 명령어를 통해 볼륨 그룹 확인

[root linux@~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <199.00 GiB
  PE Size               4.00 MiB
  Total PE              50943
  Alloc PE / Size       50943 / <199.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               lOK7Xo-je8M-eL0j-tgjB-MAoP-oAYP-2e0ABY

 

 

  • vgextend 명령어를 볼륨 그룹 확장

[root linux@~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended

 

 

  • vgdisplay 명령어를 통해 증설된 볼륨 그룹 확인

[root linux@~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               498.99 GiB
  PE Size               4.00 MiB
  Total PE              127742
  Alloc PE / Size       50943 / <199.00 GiB
  Free  PE / Size       76799 / <300.00 GiB
  VG UUID               lOK7Xo-je8M-eL0j-tgjB-MAoP-oAYP-2e0ABY

 

 

  • lvextend 명령어를 통해 남은 용량 모두 물리적 파티션 증가

[root linux@~]# lvextend /dev/mapper/centos-root -l +100%FREE
  Size of logical volume centos/root changed from 150.00 GiB (38401 extents) to 450.00 GiB (115200 extents).
  Logical volume centos/root successfully resized.

 

 

  • resize2fs 명령어 수행할 경우 다음과 같은 에러 발생 시 파일 시스템의 구성을 확인 

[root linux@~]# resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root
Couldn't find valid filesystem superblock.

 

 

  • blkid 명령어를 통해 파일 시스템의 구성 확인

[root linux@~]# blkid /dev/mapper/centos-root
/dev/mapper/centos-root: UUID="78431d84-b39c-495a-a69c-2370dae75c26" TYPE="xfs" 

 

 

  • xfs_growfs를 통해 데이터 블록 변경

[root linux@~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512    agcount=13, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=39322624, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 39322624 to 117964800

 

 

  • df 명령어를 통해 용량 증설 확인

[root linux@~]# df -h
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  893M     0  893M   0% /dev
tmpfs                   tmpfs     910M     0  910M   0% /dev/shm
tmpfs                   tmpfs     910M   11M  900M   2% /run
tmpfs                   tmpfs     910M     0  910M   0% /sys/fs/cgroup
/dev/mapper/centos-root xfs       450G  114G  337G  26% /
/dev/sda1               xfs      1014M  280M  735M  28% /boot
/dev/mapper/centos-home xfs        46G  8.3G   37G  19% /home
tmpfs                   tmpfs     182M   12K  182M   1% /run/user/42
tmpfs                   tmpfs     182M     0  182M   0% /run/user/0

 

 

 참고 문헌

[논문]

  • 없음

[보고서]

  • 없음

[URL]

  • 없음

 

 문의사항

[기상학/프로그래밍 언어]

  • sangho.lee.1990@gmail.com

[해양학/천문학/빅데이터]

  • saimang0804@gmail.com