VirtualBox_linux_디스크 증설

Ja L·2023년 3월 20일
0

[OS] Linux

목록 보기
2/7

1. 가상머신 전원 off

2. Windows 명령 프롬프트에서 virtualBox가 설치된 폴더로 이동

# 디폴트 설치 경로
C:\Program Files\Oracle\VirtualBox 

3. 가상 디스크 파일의 크기를 조절하는 명령어를 입력

VBoxManage modifyhd "D:\Disk\VM\centos2\centos2.vdi" --resize 40960

4. VirtualBox 실행 후 용량 확인

$ fdisk -l

5. 파티션 설정

$ 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): p

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000aab80
   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        2611    20458496   8e  Linux LVM

Command (m for help): n

Command action
   e   extended
   p   primary partition (1-4)
p

Partition number (1-4): 3

First cylinder (2611-5221, default 2611): 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-5221, default 5221): 5221

Command (m for help): t
Partition number (1-4): 3

Hex code (type L to list codes): 0x8e
Type 0 means free space to many systems
(but not to Linux). Having partitions of
type 0 is probably unwise. You can delete
a partition using the `d' command.
Changed system type of partition 3 to 0 (Empty)

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.

6. 가상머신 재부팅

$ roboot

7. 새로운 물리 볼륨 생성(볼륨을 sda3으로 생성)

$ pvcreate /dev/sda3
	Physical volume "/dev/sda3" successfully created
$ vgextend centos /dev/sda3

vgextend [group][경로] 에서 group을 확인할 수 있는 명령어 $pvscan
참고 - https://fmyson.tistory.com/152

8. 새 파티션을 볼륨 그룹에 추가

$ vgextend centos /dev/sda3

[Error] Couldn't create temporary archive name
남아 있는 용량이 너무 부족하거나, /etc/lvm/archive 가 읽기전용이기 때문이다.
나의 경우 몇 개의 파일을 지우고나니 자연스럽게 해결되었다.
결국 용량문제였다.


[해결]
참고 - https://unix.stackexchange.com/questions/389539/lvm-couldnt-create-temporary-archive-name/389542#389542

9. 파티션 확장

$ lvextend --size +20g /dev/centos/root

[Error] 에러코드 실종
[해결]
$ lvextend --size +19.99g /dev/centos/root

10. 파티션 크기 조정

$ resize2fs /dev/centos/root

[Error] resize2fs: Bad magic in super-block while trying to open /dev/centos/root
Couldn't find valid filesystem superblock.


[해결]
$ xfs_growfs /dev/centos/root

11. 확인

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G  8.7M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   37G   17G   21G  46% /
/dev/sda1               1014M  195M  820M  20% /boot
tmpfs                    379M     0  379M   0% /run/user/0
profile
DB Engineer

0개의 댓글