resize2fs : 열려고하는 동안 수퍼 블록의 잘못된 매직 번호


150

CentOS7에서 논리 볼륨의 크기를 조정하려고하는데 다음 오류가 발생합니다.

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.

fdisk를 사용하여 새 파티션을 추가하고 vgextend를 사용하여 볼륨 그룹을 확장 한 다음 크기를 조정하려고했습니다. lvextend를 사용하여 논리 볼륨에 대해 크기 조정이 정상적으로 작동했지만 resize2fs에서 실패했습니다.

또한 fdisk를 사용하여 기존 파티션을 삭제하고 더 큰 엔드 블록으로 파티션을 다시 만든 다음 lvm pvresize를 사용하여 물리 볼륨의 크기를 조정 한 다음 lvm lvresize를 사용하여 논리 볼륨의 크기를 조정했습니다. 이 시점까지 모든 것이 잘 작동했습니다.

위의 두 가지 방법을 모두 사용하여 resize2fs를 사용하려고 시도하면 정확히 동일한 오류가 발생했습니다.

다음 중 일부는 약간의 빛을 발산하기를 바랍니다.

fdisk -l

[root@server~]# fdisk -l

Disk /dev/xvda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x0009323a

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048     1026047      512000   83  Linux
/dev/xvda2         1026048    41943039    20458496   8e  Linux LVM
/dev/xvda3        41943040    62914559    10485760   8e  Linux LVM

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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 /dev/mapper/centos-root: 29.5 GB, 29532094464 bytes, 57679872 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

pvdisplay

[root@server ~]# pvdisplay
--- Physical volume ---
PV Name               /dev/xvda2
VG Name               centos
PV Size               19.51 GiB / not usable 2.00 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              4994
Free PE               0
Allocated PE          4994
PV UUID               7bJOPh-OUK0-dGAs-2yqL-CAsV-TZeL-HfYzCt

--- Physical volume ---
PV Name               /dev/xvda3
VG Name               centos
PV Size               10.00 GiB / not usable 4.00 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              2559
Free PE               0
Allocated PE          2559
PV UUID               p0IClg-5mrh-5WlL-eJ1v-t6Tm-flVJ-gsJOK6

vgdisplay

[root@server ~]# vgdisplay
--- Volume group ---
VG Name               centos
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  6
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                2
Act PV                2
VG Size               29.50 GiB
PE Size               4.00 MiB
Total PE              7553
Alloc PE / Size       7553 / 29.50 GiB
Free  PE / Size       0 / 0
VG UUID               FD7k1M-koJt-2veW-sizL-Srsq-Y6zt-GcCfz6

lvdisplay

[root@server ~]# lvdisplay
--- Logical volume ---
LV Path                /dev/centos/swap
LV Name                swap
VG Name                centos
LV UUID                KyokrR-NGsp-6jVA-P92S-QE3X-hvdp-WAeACd
LV Write Access        read/write
LV Creation host, time localhost, 2014-10-09 08:28:42 +0100
LV Status              available
# open                 2
LV Size                2.00 GiB
Current LE             512
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     8192
Block device           253:0

--- Logical volume ---
LV Path                /dev/centos/root
LV Name                root
VG Name                centos
LV UUID                ugCOcT-sTDK-M8EV-3InM-hjIg-2nwS-KeAOnq
LV Write Access        read/write
LV Creation host, time localhost, 2014-10-09 08:28:42 +0100
LV Status              available
# open                 1
LV Size                27.50 GiB
Current LE             7041
Segments               2
Allocation             inherit
Read ahead sectors     auto
- currently set to     8192
Block device           253:1

어리석은 짓을 했으므로 도움을 주시면 감사하겠습니다!


답변:


293

가능한 답변에서 언급 한 바와 같이 약간의 시행 착오 후에 ...이 xfs_growfs아니라 요구되었습니다 resize2fs.

CentOS 7,

fdisk /dev/xvda

새 기본 파티션을 작성하고 유형을로 설정하십시오 linux lvm.

n
p
3
t
8e
w

새로운 1 차 볼륨을 작성하고 볼륨 그룹을 새로운 볼륨으로 확장하십시오.

partprobe
pvcreate /dev/xvda3
vgextend /dev/centos /dev/xvda3

사용 가능한 공간에 대한 물리적 볼륨을 확인하고 사용 가능한 공간으로 논리 볼륨을 확장하십시오.

vgdisplay -v
lvextend -l+288 /dev/centos/root

마지막으로 온라인 크기 조정을 수행하여 논리 볼륨의 크기를 조정 한 다음 사용 가능한 공간을 확인하십시오.

xfs_growfs /dev/centos/root
df -h

2
RHEL 7에서도 작동합니다. 감사!
— Richard Corfield

1
한 파티션을 축소하고 축소 된 공간을 다른 파티션에 추가하는 방법은 무엇입니까? xfs_growfs이 작동하지 않는 것 같습니다.
— GoingMyWay

당신은 전설입니다,이 가이드를 위해 너무 많이, 우분투 /
— 센토 스는

여기 자세한 정보를 찾을 수 있습니다 : tecmint.com/extend-and-reduce-lvms-in-linux
— Lihai

1
xfs_growfs는 XFS 파일 시스템 용입니다. 누군가 다른 파일 시스템 (ext4)과 함께 CentOS를 설치하면 xfs_growfs가 실패합니다. fsadmxfs, ext4 및 일부 파일 시스템을 처리하는 사용하십시오 .
— karatedog

58

Centos 7에서 기본 파일 시스템은 xfs 입니다.

xfs 파일 시스템 지원은 축소되지 않습니다. 따라서 파일 시스템의 크기를 조정하려면 resize2fs 대신 xfs_growfs를 사용하십시오.

xfs_growfs /dev/root_vg/root 

참고 : ext4 파일 시스템 사용

resize2fs /dev/root_vg/root

1
mount | column -t다른 많은 방법으로 파일 시스템 유형을 찾을 수 있습니다 .
— harperville 2016 년

장치를 차단하지 말고 마운트 지점을 지정해야합니다. xfs_growfs version 5.1.0, Fedora 31Usage: xfs_growfs [options] mountpoint
— Alois Mahdal

43

나는 정오 오늘 똑같은 문제에 달려 드디어 해결책을 발견 -> resize2fs에 노력 EB 볼륨 실패

파티션이 이미 마운트되었으므로 마운트를 건너 뛰었습니다.

분명히 CentOS 7은 기본 파일 시스템으로 XFS를 사용하므로 결과적으로 resize2fs실패합니다.

나는 /etc/fstabXFS가 나를 쳐다보고있는 것을 추측했다. 이것이 도움이 되길 바란다.


2
나는 lvextend --resize를 실행하여 centos 7에서 크기가 조정되었습니다.이 문제를 해결하는 것처럼 보였습니다.
— technocrat

21
lvextend의 ​​맨 페이지는 fsadm파일 시스템의 크기를 조정 하는 데 사용한다고 말합니다 . 그래서 시도 fsadm resize /dev/centos/root하고 작동했습니다.
— Fatih

기술적으로 이것은 실제로 답변이 아니며 해당 URL의 정보가 저에게 효과적이지 않았습니다. 여기서 논의 할 수있는 질문에 답하고 도움이된다고 생각되면 지원 문서에 대한 링크를 추가하는 것이 가장 좋습니다.
— PJ Brunet

22

resize2fs 명령이 모든 파일 시스템에서 작동하지는 않습니다.

아래 명령을 사용하여 인스턴스의 파일 시스템을 확인하십시오. 여기에 이미지 설명을 입력하십시오

다른 파일 시스템에 대한 Amazon 공식 문서에 언급 된 단계에 따라 볼륨을 확장하려면 절차를 따르십시오.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html

Centos의 기본 파일 시스템은 xfs입니다. xfs 파일 시스템에 대해 다음 명령을 사용하여 파티션 크기를 늘리십시오.

sudo xfs_growfs -d /

그런 다음 "df -h"를 확인하십시오.


2
이런 식으로 사람들의 직업을 구할 수 있습니다. 잘 하셨어요!
— 벤 파워

17

Centos 7에서 resize2fs가 "bad magic number"로 실패하는 원래 질문에 대한 답으로 다음과 같이 fsadm을 사용해보십시오.

fsadm resize /dev/the-device-name-returned-by-df

그때:

df 

... 크기 변경이 확인되었습니다.


LVM 파티션의 크기가 조정 된 CentOS VM에서도 저와 함께 일했습니다.
— 알렉상드르 제르맹

16

CentOS7 + VM

나는 그것을 만들었다 :

  1. Gparted-live 볼륨을 확장
  2. pvresize -v /dev/sda2
  3. lvresize -r -l+100%FREE centos/root

6
How to resize root partition online :  

1)  [root@oel7 ~]# df -h  
Filesystem                         Size  Used Avail Use% Mounted on  
/dev/mapper/root_vg-root           5.0G  4.5G  548M  90% /

2)   

PV /dev/sda2   VG root_vg     lvm2 [6.00 GiB / 0    free]

as here it shows that there is no space left on root_vg volume group, so first i need to extend VG 

3)  
[root@oel7 ~]# vgextend root_vg /dev/sdb5  

  Volume group "root_vg" successfully extended

4)  

[root@oel7 ~]# pvscan  
    PV /dev/sda2   VG root_vg     lvm2 [6.00 GiB / 0    free]  
    PV /dev/sdb5   VG root_vg     lvm2 [2.00 GiB / 2.00 GiB free]

5)  Now extend the logical volume   

[root@oel7 ~]# lvextend -L +1G /dev/root_vg/root  

  Size of logical volume root_vg/root changed from 5.00 GiB (1280 extents) to 6.00 GiB (1536 extents).
  Logical volume root successfully resized  

3)  [root@oel7 ~]# resize2fs /dev/root_vg/root  

resize2fs 1.42.9 (28-Dec-2013)  
resize2fs: Bad magic number in super-block while trying to open /dev/root_vg  /root  
Couldn't find valid filesystem superblock.  

as root partition is not a ext* partiton so , you resize2fs will not work for you.  

4)  to check the filesystem type of a partition 
[root@oel7 ~]# df -Th  
Filesystem                        Type      Size  Used Avail Use% Mounted on  
/dev/mapper/root_vg-root          xfs       6.0G  4.5G  1.6G  75% /  
devtmpfs                          devtmpfs  481M     0  481M   0% /dev  
tmpfs                             tmpfs     491M   80K  491M   1% /dev/shm  
tmpfs                             tmpfs     491M  7.1M  484M   2% /run  
tmpfs                             tmpfs     491M     0  491M   0% /sys/fs  /cgroup
/dev/mapper/data_vg-home          xfs       3.5G  2.9G  620M  83% /home  
/dev/sda1                         xfs       497M  132M  365M  27% /boot  
/dev/mapper/data_vg01-data_lv001  ext3      4.0G  2.4G  1.5G  62% /sybase  
/dev/mapper/data_vg02-backup_lv01 ext3      4.0G  806M  3.0G  22% /backup  

above command shows that root is an xfs filesystem , so we are sure that we need to use xfs_growfs command to resize the partition.

6)  [root@oel7 ~]# xfs_growfs /dev/root_vg/root  
meta-data=/dev/mapper/root_vg-root isize=256    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1310720 to 1572864  

[root@oel7 ~]# df -Th  

Filesystem                        Type      Size  Used Avail Use% Mounted on
/dev/mapper/root_vg-root          xfs       6.0G  4.5G  1.6G  75% /  

6

LVM에 대해 읽고 PV-> VG-> LV에 익숙해지면 나에게 효과적입니다.

0) #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  824K  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/fedora-root   15G  2.1G   13G  14% /
tmpfs                    1.9G     0  1.9G   0% /tmp
/dev/md126p1             976M  119M  790M  14% /boot
tmpfs                    388M     0  388M   0% /run/user/0

1) #vg

  VG     #PV #LV #SN Attr   VSize   VFree   
  fedora   1   2   0 wz--n- 231.88g 212.96g

2) # vgdisplay

  --- Volume group ---
  VG Name               fedora
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               231.88 GiB
  PE Size               4.00 MiB
  Total PE              59361
  Alloc PE / Size       4844 / 18.92 GiB
  Free  PE / Size       54517 / 212.96 GiB
  VG UUID               9htamV-DveQ-Jiht-Yfth-OZp7-XUDC-tWh5Lv

3) # lvextend -l + 100 % FREE / dev / mapper / fedora-root

  Size of logical volume fedora/root changed from 15.00 GiB (3840 extents) to 227.96 GiB (58357 extents).
  Logical volume fedora/root successfully resized.

4) #lvdisplay

5) #fd -h

6) # xfs_growfs / dev / mapper / fedora-root

meta-data=/dev/mapper/fedora-root isize=512    agcount=4, agsize=983040 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1 spinodes=0 rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=3932160, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 3932160 to 59757568

7) #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  828K  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/fedora-root  228G  2.3G  226G   2% /
tmpfs                    1.9G     0  1.9G   0% /tmp
/dev/md126p1             976M  119M  790M  14% /boot
tmpfs                    388M     0  388M   0% /run/user/0

친애하는,


6

os : rhel7

후 gparted, # xfs_growfs /dev/mapper/rhel-root살아있는 시스템에 트릭을했다.

$ df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   47G   47G   20M 100% /
devtmpfs               1.9G     0  1.9G   0% /dev
tmpfs                  1.9G     0  1.9G   0% /dev/shm
tmpfs                  1.9G  9.3M  1.9G   1% /run
tmpfs                  1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1             1014M  205M  810M  21% /boot
tmpfs                  379M  8.0K  379M   1% /run/user/42
tmpfs                  379M     0  379M   0% /run/user/1000


# lvresize -l +100%FREE /dev/mapper/rhel-root
  Size of logical volume rhel/root changed from <47.00 GiB (12031 extents) to <77.00 GiB (19711 extents).
  Logical volume rhel/root successfully resized.


# xfs_growfs /dev/mapper/rhel-root
meta-data=/dev/mapper/rhel-root  isize=512    agcount=7, agsize=1900032 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=12319744, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=3711, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 12319744 to 20184064


# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   77G   47G   31G  62% /
devtmpfs               1.9G     0  1.9G   0% /dev
tmpfs                  1.9G     0  1.9G   0% /dev/shm
tmpfs                  1.9G  9.3M  1.9G   1% /run
tmpfs                  1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1             1014M  205M  810M  21% /boot
tmpfs                  379M  8.0K  379M   1% /run/user/42
tmpfs                  379M     0  379M   0% /run/user/1000

6

CentOS 및 페도라에서 fsadm 작업

fsadm resize /dev/vg_name/root
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.