APFS 확장 디스크

8884 단어 apfstech

왜?

  • 240GB SSD의 내용을 dd로 500GB SSD에 원형 복사
  • 하지만 500GB의 SSD로 시동을 걸면 용량이 240GB 상태로 유지돼 곤란하다.
  • 먼저

  • 실제 디스크 용량 변경 명령을 실행하면 응답이 중지됩니다.
  • 디스크 액세스가 모두 차단될 수 있습니다.
  • 어쩌면 좋아


    현황 확인

    sudo diskutil list
    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         239.8 GB   disk0s2
    
    /dev/disk1 (synthesized):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      APFS Container Scheme -                      +239.8 GB   disk1
                                     Physical Store disk0s2
       1:                APFS Volume MacOS                   52.8 GB    disk1s1
       2:                APFS Volume Preboot                 268.8 MB   disk1s2
       3:                APFS Volume Recovery                1.1 GB     disk1s3
       (略)
    
    disk0의 2호, Container disk1의 용량은 디스크의 용량과 일치하지 않습니다.

    확장성

    sudo diskutil apfs resizeContainer disk1 0 disk1는 APFS Contaainer입니다.위에 표시된 synthesized 디스크의 번호를 지정합니다dev/disk1이 아닙니다.
    다음0은 치수 변경 +100g을 지정할 수 있습니다.0을 지정하면 최대 용량으로 확장됩니다.
    Started APFS operation
    Aligning grow delta to 260,050,452,480 bytes and targeting a new physical store size of 499,898,105,856 bytes
    Determined the maximum size for the targeted physical store of this APFS Container to be 499,897,077,760 bytes
    Resizing APFS Container designated by APFS Container Reference disk1
    The specific APFS Physical Store being resized is disk0s2
    Verifying storage system
    Using live mode
    Performing fsck_apfs -n -x -l /dev/disk0s2
    Checking the container superblock
    Checking the EFI jumpstart record
    Checking the space manager
    Checking the space manager free queue trees
    Checking the object map
    Checking the encryption key structures
    Checking volume /dev/rdisk1s1
    Checking the APFS volume superblock
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the document ID tree
    Checking the fsroot tree
    Checking the extent ref tree
    Verifying volume object map space
    The volume /dev/rdisk1s1 appears to be OK
    Checking volume /dev/rdisk1s2
    Checking the APFS volume superblock
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the fsroot tree
    Checking the extent ref tree
    Verifying volume object map space
    The volume /dev/rdisk1s2 appears to be OK
    Checking volume /dev/rdisk1s3
    Checking the APFS volume superblock
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the fsroot tree
    Checking the extent ref tree
    Verifying volume object map space
    The volume /dev/rdisk1s3 appears to be OK
    Checking volume /dev/rdisk1s4
    Checking the APFS volume superblock
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the fsroot tree
    Checking the extent ref tree
    Verifying volume object map space
    The volume /dev/rdisk1s4 appears to be OK
    Checking volume /dev/rdisk1s5
    Checking the APFS volume superblock
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking snapshot 1 of 1 (com.apple.os.update-018EB80C949FBD899...)
    Checking the fsroot tree
    Checking the file extent tree
    Checking the extent ref tree
    Verifying volume object map space
    The volume /dev/rdisk1s5 appears to be OK
    Checking volume /dev/rdisk1s6
    Checking the APFS volume superblock
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the fsroot tree
    Checking the extent ref tree
    Verifying volume object map space
    The volume /dev/rdisk1s6 appears to be OK
    Verifying allocated space
    The container /dev/disk0s2 appears to be OK
    Storage system check exit code is 0
    Growing APFS Physical Store disk0s2 from 239,847,653,376 to 499,898,105,856 bytes
    Modifying partition map
    Growing APFS data structures
    Finished APFS operation
    

    재확인


    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         239.8 GB   disk0s2
                                                             ~~~~~~~~
    
    /dev/disk1 (synthesized):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      APFS Container Scheme -                      +239.8 GB   disk1
                                     Physical Store disk0s2
       1:                APFS Volume MacOS                   52.8 GB    disk1s1
       2:                APFS Volume Preboot                 268.8 MB   disk1s2
       3:                APFS Volume Recovery                1.1 GB     disk1s3
       4:                APFS Volume VM                      1.1 MB     disk1s4
       5:                APFS Volume macSSD                  15.2 GB    disk1s5
       6:              APFS Snapshot com.apple.os.update-... 15.2 GB    disk1s5s1
    
    또 disk 0s2는 239.8GB였다.이 사이즈는 disk1s0 사이즈로 여기를 확장하지 않으면 실제 사용할 수 있는 용량이 증가하지 않습니다.

    확장


    repairdisk 실행


    이 작업을 수행하지 않으면 다음 확장은 알 수 없는 오류로 인해 실패합니다. (용량 부족 등 오류)sudo diskutil repairdisk disk0첫 번째 문제는 무섭지만, 사실은 데이터가 나쁘지 않을 것 같아..
    그리고 이렇게 하면 예전의 디스크가 남아있을 테니 최악의 방법은 있겠지.
    (역으로 무능하다면 백업부터 하자)
    Repairing the partition map might erase disk0s1, proceed? (y/N) y
    Started partition map repair on disk0
    Checking prerequisites
    Checking the partition list
    Adjusting partition map to fit whole disk as required
    Checking for an EFI system partition
    Checking the EFI system partition's size
    Checking the EFI system partition's file system
    Repairing the EFI system partition's file system
    Checking file system and repairing if necessary and if possible
    Volume is already unmounted
    Performing fsck_msdos -y /dev/rdisk0s1
    ** /dev/rdisk0s1
    ** Phase 1 - Preparing FAT
    ** Phase 2 - Checking Directories
    ** Phase 3 - Checking for Orphan Clusters
    Found orphan cluster(s)
    Fix? yes
    Marked 116 clusters as free
    Free space in FSInfo block (363872) not correct (363988)
    Fix? yes
    813 files, 181994 KiB free (363988 clusters)
    
    ***** FILE SYSTEM WAS MODIFIED *****
    File system check exit code is 0
    Restoring the original state found as unmounted
    Checking the EFI system partition's folder content
    Checking all HFS data partition loader spaces
    Checking booter partitions
    Reviewing boot support loaders
    Checking Core Storage Physical Volume partitions
    The partition map has been repaired
    Finished partition map repair on disk0
    

    진짜 확장.

    sudo diskutil apfs resizeContainer disk0s2 0
    Started APFS operation
    Aligning grow delta to 260,050,452,480 bytes and targeting a new physical store size of 499,898,105,856 bytes
    Determined the maximum size for the targeted physical store of this APFS Container to be 499,897,077,760 bytes
    長いので略
    Finished APFS operation
    

    최종 확인

    diskutil list
    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         499.9 GB   disk0s2
    
    /dev/disk1 (synthesized):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      APFS Container Scheme -                      +499.9 GB   disk1
                                     Physical Store disk0s2
    
    용량 변경수고하셨습니다.

    사족


    사용되지 않은 명령

    sudo diskutil apfs resizeContainer disk0s2 limits
    Resize limits for APFS Physical Store partition disk0s2:
      Current Physical Store partition size on map:   239.8 GB (239847653376 Bytes)
      Minimum (constrained by file/snapshot usage):   75.9 GB (75942068224 Bytes)
      Recommended minimum (if used with macOS):       86.7 GB (86679486464 Bytes)
      Maximum (constrained by partition map space):   499.9 GB (499897077760 Bytes)
    

    리페어디스를 안 하면...

    sudo diskutil apfs resizeContainer disk0s2 0 sudo diskutil apfs resizeContainer disk0s2 499.9g
    The size (499.9g) must not be greater than the partition map allocatable size
    
    안 돼요.그나저나 용량을 더 줄여도 똑같은 오류가 발생할 수 있다.

    좋은 웹페이지 즐겨찾기