LVM이 아닌 ext4 파티션의 크기를 조정/확대/확대하는 방법

LVM이 아닌 ext4 파티션의 크기를 조정/확대/확대하는 방법

이미 포럼을 검색했지만 적합한 답변을 찾을 수 없습니다.

KVM 호스트로 Ubuntu Server 10.04가 있고 10.04도 실행되는 게스트 시스템이 있습니다. 호스트 시스템은 LVM을 사용하며 게스트에게 가상 블록 장치로 제공되는 세 개의 논리 볼륨(/용 하나, /home용 하나, 스왑용 하나)이 있습니다. 게스트는 LVM 없이 분할되었습니다.

호스트 시스템에서 논리 볼륨을 이미 확장했습니다. 게스트는 더 큰 가상 디스크를 성공적으로 확인합니다. 그러나 이 가상 디스크에는 여전히 예전의 작은 크기를 갖고 있는 하나의 "좋은 오래된" 파티션이 포함되어 있습니다.

fdisk -l의 출력은 다음과 같습니다.

me@produktion:/$ LC_ALL=en_US sudo fdisk -l

Disk /dev/vda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x000c8ce7

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        3917    31455232   83  Linux

Disk /dev/vdb: 2147 MB, 2147483648 bytes
244 heads, 47 sectors/track, 365 cylinders
Units = cylinders of 11468 * 512 = 5871616 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f2bf7

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1         366     2095104   82  Linux swap / Solaris
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(0, 32, 33) logical=(0, 43, 28)
Partition 1 has different physical/logical endings:
     phys=(260, 243, 47) logical=(365, 136, 44)

Disk /dev/vdc: 225.5 GB, 225485783040 bytes
255 heads, 63 sectors/track, 27413 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: 0x00027f25

   Device Boot      Start         End      Blocks   Id  System
/dev/vdc1               1        9138    73398272   83  Linux

분할 인쇄의 출력은 모두 다음과 같습니다.

Model: Virtio Block Device (virtblk)
Disk /dev/vda: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  32.2GB  32.2GB  primary  ext4         boot


Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  2146MB  2145MB  primary  linux-swap(v1)


Model: Virtio Block Device (virtblk)
Disk /dev/vdc: 225GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  75.2GB  75.2GB  primary  ext4

내가 달성하고 싶은 것은 가상 블록 장치 /dev/vdc가 제공하는 전체 공간을 사용하도록 /dev/vdc1 파티션을 늘리거나 크기를 조정하는 것입니다. 문제는 parted로 그렇게 하려고 하면 다음과 같이 불평한다는 것입니다.

(parted) select /dev/vdc                                                  
Using /dev/vdc
(parted) print                                                            
Model: Virtio Block Device (virtblk)
Disk /dev/vdc: 225GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  75.2GB  75.2GB  primary  ext4

(parted) resize 1                                                         
WARNING: you are attempting to use parted to operate on (resize) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs.  We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Start?  [1049kB]?                                                         
End?  [75.2GB]? 224GB                                                     
Error: File system has an incompatible feature enabled.  Compatible features are has_journal, dir_index, filetype, sparse_super and large_file.  Use tune2fs
or debugfs to remove features.

그래서 내가 무엇을 할 수 있니? 이것은 헤드리스 생산 시스템입니다. 이 파티션을 확장하는 안전한 방법은 무엇입니까? 하지만 마운트 해제할 수 있으므로 이는 문제가 되지 않습니다.

편집: Cfdisk는 분할되지 않은 작은 여유 공간을 표시한 다음 파티션("부팅" 및 Linux/ext3로 플래그 지정), 분할되지 않은 나머지 공간을 표시했습니다. 파티션을 삭제하고 cfdisk를 사용하여 다시 생성한 후 - cfdisk는 하나의 큰 파티션 영역(나에게는 괜찮을 것임)을 표시하고 파일 시스템 유형으로 "Linux"만 표시합니다.

Resize2fs는 이 오류를 반환합니다. resize2fs 1.41.11 (14-Mar-2010) resize2fs: Bad magic number in super-block while trying to open /dev/vdc1 Couldn't find valid filesystem superblock

답변1

이것페이지에는 마운트 해제, 삭제, 원하는 크기로 파티션을 다시 생성하고 resize2fs를 사용하여 파티션을 확장하는 방법이 나와 있습니다. resize2fs 매뉴얼 페이지는 이에 동의합니다.

'파티션 삭제'가 무섭게 들리겠지만 데이터가 전혀 변경되지는 않습니다. 단지 컨테이너를 참조하는 것을 변경하는 것뿐입니다. 그러지 않는 한 mkfs.ext4괜찮을 것입니다.

파티션 시작 지점은 이전과 동일해야 합니다. 그렇지 않으면 OS가 그 뒤에 있는 내용을 해석하는 방법을 알 수 없습니다. 그런 다음 끝점을 더 따라가면 더 큰 파티션을 만들 수 있습니다.

댓글의 오류는 시작점 이동과 관련이 있는 것 같습니다. 시작한 시점과 정확히 동일한 지점에서 시작해야 합니다. 끝점은 이동할 수 있습니다.

신용슈시cfdisk 대신 fdisk를 제안하고 시작점 문제를 확인했습니다.

답변2

예:

/dev/sdb2는 /boot 파티션입니다. 용량은 100MB로 다소 작습니다. 실행 중인 시스템에서 이 ext4 파티션을 늘리려면 루트 또는 sudo로 다음을 수행하십시오.

마운트 해제/부팅

/dev/sdb로 분리됨

(분할) 인쇄

모델: ATA Patriot Torqx 2(scsi)
디스크 /dev/sdb: 32.0GB
섹터 크기(논리적/물리적): 512B/512B
파티션 테이블: msdos

번호 시작 끝 크기 유형 파일 시스템 플래그
1 1049kB 12.9GB 12.9GB 기본 유형=83
2 12.9GB 13.0GB 107MB 기본 ext4 유형=83

(헤어짐) rm 2

(분할) mkpart

파티션 유형? 기본/확장? 기본
파일 시스템 유형은 무엇입니까? [ext2]?
시작? 12.9GB
끝? 13.4GB

(헤어졌다) 그만둬

resize2fs /dev/sdb2

resize2fs 1.42.6 (2012년 9월 21일)
/dev/sdb2의 파일 시스템이 /boot에 마운트됩니다. 온라인 크기 조정 필요
old_desc_blocks = 1, new_desc_blocks = 2
/dev/sdb2의 파일 시스템 길이는 이제 498688 블록입니다.

완료!

모든 데이터는 그대로 유지됩니다. /boot는 사용할 준비가 되어 있으며 크기는 472MB입니다(parted는 크기에 비해 안전하지 않습니다. 이유를 알아보려면 설명서를 읽어보세요).

모든 데이터는 이전에 백업되었지만 예방 조치로만 백업되었습니다. 나는 똑같이하는 것이 좋습니다.

실패할 경우 /boot 마운트 해제를 중지하는 프로세스를 찾으려면 다음 명령을 사용하십시오.

lsof /부팅

행운을 빌어요!

답변3

파티션을 삭제하고 다시 생성하려고 하면 파티션이 2048 미만으로 시작되었을 때 제가 겪었던 것과 같은 문제가 발생할 수 있습니다 resize2fs.

Couldn't find valid filesystem superblock.

에서fdisk 버전 2.17.2, fdisk IIUC는 하드 드라이브가 "올바르게 정렬"되었는지 확인하기 위해 2048부터 시작하도록 강제합니다. 따라서 원래 파티션이 2048년 이전에 시작된 경우 파티션을 다시 생성하는 데 어려움을 겪게 됩니다.

가장 좋은 접근 방식은디스크 복제 시 rsync.

관련 정보