VPS(LVM) 9GB에서 40GB로 저장공간을 확장하는 방법

VPS(LVM) 9GB에서 40GB로 저장공간을 확장하는 방법

내 VM은 9GB 설정과 함께 제공되었지만 드라이브는 60GB였습니다. 전체 크기로 확장하려고합니다. 여러 서버에서 이 작업을 수행해야 합니다. 다른 곳의 가이드를 따르려고 했지만 새 파티션을 만들 때 이 메시지를 받았습니다.

4개 이상의 파티션을 생성하려면 먼저 기본 파티션을 확장 파티션으로 교체해야 합니다.

다음은 도움이 될 만한 몇 가지 정보입니다.

root@ubuntu:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G  4.0K  2.0G   1% /dev
tmpfs           396M  584K  395M   1% /run
/dev/dm-0        57G  3.0G   52G   6% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            2.0G     0  2.0G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/sda1       134M   68M   57M  55% /boot

root@ubuntu:~# fdisk -l

Disk /dev/sda: 62.9 GB, 62914560000 bytes
64 heads, 32 sectors/track, 60000 cylinders, total 122880000 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 identifier: 0x00096132

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      292863      145408   83  Linux
/dev/sda2          292864     2246655      976896   82  Linux swap / Solaris
/dev/sda3         2246656    20969471     9361408   8e  Linux LVM
/dev/sda4        20969472   122879999    50955264   8e  Linux LVM

Disk /dev/mapper/CAC_VG-CAC_LV: 61.8 GB, 61761126400 bytes
255 heads, 63 sectors/track, 7508 cylinders, total 120627200 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 identifier: 0x00000000

Disk /dev/mapper/CAC_VG-CAC_LV doesn't contain a valid partition table`

어떤 도움이라도 대단히 감사하겠습니다. 추가 정보가 필요하면 언제든지 문의하세요. 아침 내내 지켜볼 거예요.

감사해요

편집-실제로 이전에 실행한 스크립트가 작동하여 드라이브를 확장했다고 생각하고 있지만 한 서버에는 해당 파티션 오류가 있고 다른 서버에는 그렇지 않습니다.

편집 - Fstab 출력

root@ubuntu:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/CAC_VG-CAC_LV /               ext4    errors=remount-ro 0      1  
# /boot was on /dev/sda1 during installation
UUID=1d92b194-7885-4b25-a4ba-a7b8683229e1 /boot           ext4  defaults 0 2
# swap was on /dev/sda2 during installation
UUID=be7625e5-2e2c-41f2-8d5f-331f90980b9e none            swap    sw  0 0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

pvdisplay 및 vgdisplay

root@ubuntu:~# vgdisplay
  --- Volume group ---
  VG Name               CAC_VG
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               57.52 GiB
  PE Size               4.00 MiB
  Total PE              14725
  Alloc PE / Size       14725 / 57.52 GiB
  Free  PE / Size       0 / 0
  VG UUID               A4SRwW-Vqpz-qRLf-iXIm-yKny-tcyI-wYTMdg

root@ubuntu:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               CAC_VG
  PV Size               8.93 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2285
  Free PE               0
  Allocated PE          2285
  PV UUID               al3A0j-NEpg-yjRd-2yzF-pMUm-fa42-XdcZmc

  --- Physical volume ---
  PV Name               /dev/sda4
  VG Name               CAC_VG
  PV Size               48.59 GiB / not usable 1.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              12440
  Free PE               0
  Allocated PE          12440
  PV UUID               phIhtw-wze3-IOTU-oiik-586P-ecJP-5KY913

편집 - 실행되었다고 알려진 스크립트 클라우드 호스트의 출력

root@ubuntu:~# sh zang.sh
Error: Can't create any more partitions.
Error: Partition doesn't exist.
partition: none, disk: /dev/sda, lower: 0, upper: 0
/dev/sda: partition table type 'dos' detected
partx: /dev/sda: adding partition #1 failed: Device or resource busy
partx: /dev/sda: adding partition #2 failed: Device or resource busy
partx: /dev/sda: adding partition #3 failed: Device or resource busy
partx: /dev/sda: adding partition #4 failed: Device or resource busy
partx: /dev/sda: error adding partitions 1-4
  Device /dev/sda5 not found (or ignored by filtering).
  Device /dev/sda5 not found (or ignored by filtering).
  Unable to add physical volume '/dev/sda5' to volume group 'CAC_VG'.
  New size (9725 extents) matches existing size (9725 extents)
  Run `lvextend --help' for more information.
resize2fs 1.42.9 (4-Feb-2014)
The filesystem is already 9958400 blocks long.  Nothing to do!

보시다시피 작동하지 않는 것 같지만 로그인할 때 다음에서 이동합니다.

Usage of /:  13.1% of 8.66GB   to    Usage of /:   3.1% of 37.27GB 

도움을 주셔서 다시 한 번 감사드립니다.

답변1

절차는 다소 쉬우며 실행 중인 시스템에서도 작동합니다. "해야 한다"는 말을 명심하세요. 일반적으로 절차는 다음과 같습니다.

  • 크기를 조정해야 하는 LVM의 크기 조정부터 시작하세요. sudo lvresize -l 100%FREE /dev/vg00/myvolume 이는 LVM이 볼륨을 확대하기 위해 모든 여유 공간을 사용하도록 지시합니다./dev/vg00/myvolume
  • 이제 포함된 파일 시스템의 크기를 조정해야 합니다. sudo resize2fs /dev/vg00/myvolume 디스크가 마운트되어 있음을 감지한 다음 온라인 크기 조정 모드를 사용해야 합니다.

그게 다야... 넌 끝났어.

그 모든 작업을 하기 전에 데이터를 백업하라고 제가 말했습니까? 여기 있습니다: 이 작업을 수행하기 전에 데이터를 백업하세요.

출력 결과에 볼륨이 약 61.8GB라는 내용이 나와 있습니다. 의 출력 과 의 내용 lvdisplay모두 시스템에 관한 추가 정보를 제공할 수 있습니다. 또한 왜 두 개의 LVM 표시 파티션이 있는지 잘 모르겠습니다. 당신이 그걸 만들었나요?vgdisplay/etc/fstab

관련 정보