AWS 인스턴스에서 디스크 크기를 조정할 수 없습니다.

AWS 인스턴스에서 디스크 크기를 조정할 수 없습니다.

나는 다음 지침을 따르려고 노력했습니다. resize2fs를 사용하여 파티션 크기를 조정할 수 없습니다

그러나 아무것도 작동하지 않는 것 같았습니다.

출력은 다음과 lsblk같습니다.

[AWS root@archive ~]$ lsblk
NAME                          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
xvda                          202:0    0   300G  0 disk
├─xvda1                       202:1    0   500M  0 part /boot
├─xvda2                       202:2    0  29.5G  0 part
│ ├─vg_archive-lv_root (dm-0) 253:0    0 147.6G  0 lvm  /
│ └─vg_archive-lv_swap (dm-1) 253:1    0     2G  0 lvm  [SWAP]
├─xvda3                       202:3    0    10G  0 part
│ └─vg_archive-lv_root (dm-0) 253:0    0 147.6G  0 lvm  /
└─xvda4                       202:4    0   110G  0 part
  └─vg_archive-lv_root (dm-0) 253:0    0 147.6G  0 lvm  /

300Gb를 사용할 수 있는 것을 볼 수 있지만 루트 볼륨을 150Gb에서 확장할 수는 없었습니다. 도움을 주시면 감사하겠습니다.

업데이트: Linux 배포판을 추가하려고 했는데, 오래되어서 문제의 일부일 수 있습니다...

Linux version 2.6.32-358.18.1.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Wed Aug 28 17:19:38 UTC 2013

의견에서 요청한 대로 위 링크에서 제안된 명령의 출력은 다음과 같습니다.

[AWS root@archive ~]$ sudo pvs
  PV         VG         Fmt  Attr PSize   PFree
  /dev/xvda2 vg_archive lvm2 a--   29.51g    0
  /dev/xvda3 vg_archive lvm2 a--    9.99g    0
  /dev/xvda4 vg_archive lvm2 a--  110.00g    0
[AWS root@archive ~]$ sudo pvresize /dev/xvda2
  Physical volume "/dev/xvda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[AWS root@archive ~]$ sudo pvresize /dev/xvda3
  Physical volume "/dev/xvda3" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[AWS root@archive ~]$ sudo pvresize /dev/xvda4
  Physical volume "/dev/xvda4" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[AWS root@archive ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_archive-lv_root
                      146G  131G  8.0G  95% /
tmpfs                 938M     0  938M   0% /dev/shm
/dev/xvda1            485M   80M  380M  18% /boot
[AWS root@archive ~]$ sudo lvextend -r -l +100%FREE /dev/mapper/vg_archive-lv_root
  Extending logical volume lv_root to 147.56 GiB
  Logical volume lv_root successfully resized
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 38682624 blocks long.  Nothing to do!

[AWS root@archive ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_archive-lv_root
                      146G  131G  8.0G  95% /
tmpfs                 938M     0  938M   0% /dev/shm
/dev/xvda1            485M   80M  380M  18% /boot

업데이트: 아래 출력에서 ​​fs 유형은 ext4인 것으로 나타납니다.

[AWS root@archive ~]$ df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/mapper/vg_archive-lv_root
              ext4    146G  131G  8.0G  95% /
tmpfs        tmpfs    938M     0  938M   0% /dev/shm
/dev/xvda1    ext4    485M   80M  380M  18% /boot

업데이트: cfdisk /dev/xvda요청에 따른 출력:

                                                         cfdisk (util-linux-ng 2.17.2)

                                                             Disk Drive: /dev/xvda
                                                      Size: 322122547200 bytes, 322.1 GB
                                             Heads: 255   Sectors per Track: 63   Cylinders: 39162

       Name                 Flags                Part Type         FS Type                       [Label]                   Size (MB)
 ---------------------------------------------------------------------------------------------------------------------------------------------
                                                                   Unusable                                                     1.05          *
       xvda1                Boot                  Primary          Linux ext3                                                 524.29          *
       xvda2                                      Primary          Linux LVM                                                31686.92          *
       xvda3                                      Primary          Linux LVM                                                10731.94          *
       xvda4                                      Primary          Linux LVM                                               118115.03
                                                                   Unusable                                                161063.34          *

답변1

다음을 수행하여 디스크 크기를 성공적으로 조정했습니다.

AWS 콘솔의 이미지 크기를 150Gb에서 300Gb로 늘린 후 다음 명령을 실행했습니다.

[AWS root@archive ~]$ pvresize /dev/xvda4
  Physical volume "/dev/xvda4" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

재부팅

[AWS root@archive ~]$ growpart /dev/xvda 4
CHANGED: partition=4 start=83875365 old: size=230693400 end=314568765 new: size=545262165,end=629137530
[AWS root@archive ~]$ pvresize /dev/xvda4
  Physical volume "/dev/xvda4" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[AWS root@archive ~]$ lvextend /dev/vg_archive/lv_root -l+100%FREE
  New size (37776 extents) matches existing size (37776 extents)
  Run `lvextend --help' for more information.
[AWS root@archive ~]$ resize2fs /dev/vg_archive/lv_root
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 38682624 blocks long.  Nothing to do!

작동하지 않아서 다시 재부팅하세요.

[AWS root@archive ~]$ lvextend /dev/vg_archive/lv_root -l+100%FREE
  New size (37776 extents) matches existing size (37776 extents)
  Run `lvextend --help' for more information.
[AWS root@archive ~]$ resize2fs /dev/vg_archive/lv_root
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 38682624 blocks long.  Nothing to do!

[AWS root@archive ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_archive-lv_root
                      146G  131G  8.0G  95% /
tmpfs                 938M     0  938M   0% /dev/shm
/dev/xvda1            485M   80M  380M  18% /boot
[AWS root@archive ~]$ pvresize /dev/xvda4
  Physical volume "/dev/xvda4" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[AWS root@archive ~]$ lvextend /dev/vg_archive/lv_root -l+100%FREE
  Extending logical volume lv_root to 297.56 GiB
  Logical volume lv_root successfully resized
[AWS root@archive ~]$ resize2fs /dev/vg_archive/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_archive/lv_root is mounted on /; on-line resizing required
old desc_blocks = 10, new_desc_blocks = 19
Performing an on-line resize of /dev/vg_archive/lv_root to 78004224 (4k) blocks.
The filesystem on /dev/vg_archive/lv_root is now 78004224 blocks long.

[AWS root@archive ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_archive-lv_root
                      293G  131G  149G  47% /
tmpfs                 938M     0  938M   0% /dev/shm
/dev/xvda1            485M   80M  380M  18% /boot

그래서 재부팅이 필요한 명령이 무엇인지는 잘 모르겠지만 크기 조정이 성공하려면 재부팅해야했습니다.

이것이 다른 사람에게 도움이 되기를 바랍니다

관련 정보