🧑🏻💻 ディスクユーティリティ はよくスタックする?
SDカードを再フォーマットしようとしたら、
これがなぜか処理が終わらない。
👉 Mac STUCK on disk utility process - “wait… - Apple Community
👉 Stuck at disk utility , cannot reinstall mac or erase the disks? What to do ? : r/MacOS
不安定なのか。
どうしようもないので、
ディスクユーティリティ を強制終了したり、
無理やりカードを引き抜いたりしてました。
🧑🏻💻 純正 diskutil を使う
GUI ではなかなか症状が分かりづらいので、
diskutil
で進みます。
洗練された自在なツールに見えます。
❯ diskutil
Disk Utility Tool
Utility to manage local disks and volumes
Most commands require an administrator or root user
WARNING: Most destructive operations are not prompted
Usage: diskutil [quiet] <verb> <options>, where <verb> is as follows:
list (List the partitions of a disk)
info[rmation] (Get information on a specific disk or partition)
listFilesystems (List file systems available for formatting)
listClients (List all current disk management clients)
activity (Continuous log of system-wide disk arbitration)
u[n]mount (Unmount a single volume)
unmountDisk (Unmount an entire disk (all volumes))
eject (Eject a disk)
mount (Mount a single volume)
mountDisk (Mount an entire disk (all mountable volumes))
enableJournal (Enable HFS+ journaling on a mounted HFS+ volume)
disableJournal (Disable HFS+ journaling on a mounted HFS+ volume)
moveJournal (Move the HFS+ journal onto another volume)
enableOwnership (Exact on-disk User/Group IDs on a mounted volume)
disableOwnership (Ignore on-disk User/Group IDs on a mounted volume)
rename[Volume] (Rename a volume)
verifyVolume (Verify the file system data structures of a volume)
repairVolume (Repair the file system data structures of a volume)
verifyDisk (Verify the components of a partition map of a disk)
repairDisk (Repair the components of a partition map of a disk)
resetFusion (Reset the components of a machine's Fusion Drive)
eraseDisk (Erase an existing disk, removing all volumes)
eraseVolume (Erase an existing volume)
reformat (Erase an existing volume with same name and type)
eraseOptical (Erase optical media (CD/RW, DVD/RW, etc.))
zeroDisk (Erase a disk, writing zeros to the media)
randomDisk (Erase a disk, writing random data to the media)
secureErase (Securely erase a disk or freespace on a volume)
partitionDisk ((re)Partition a disk, removing all volumes)
addPartition (Create a new partition to occupy free space)
splitPartition (Split an existing partition into two or more)
mergePartitions (Combine two or more existing partitions into one)
resizeVolume (Resize a volume, increasing or decreasing its size)
appleRAID <verb> (Perform additional verbs related to AppleRAID)
coreStorage <verb> (Perform additional verbs related to CoreStorage)
apfs <verb> (Perform additional verbs related to APFS)
image <verb> (Perform additional verbs related to DiskImage)
diskutil <verb> with no options will provide help on that verb
SDカードをチェックしてみます。
私の環境では、SDカードは /dev/disk18
です。
❯ diskutil verifyDisk /dev/disk18
Nonexistent, unknown, or damaged partition map scheme
If you are sure this disk contains a (damaged) APM, MBR, or GPT partition
scheme, you might be able to repair it with "diskutil repairDisk /dev/disk18"
❯ diskutil repairDisk /dev/disk18
Nonexistent, unknown, or damaged partition map scheme
If you are sure this disk contains a (damaged) APM, MBR, or GPT partition map,
you can hereby try to repair it enough to be recognized as a map; another
"diskutil repairDisk /dev/disk18" might then be necessary for further repairs
Proceed? (y/N) y
Error repairing map: MediaKit reports bad partition or no map found (-5324)
げ、死んでますか?
🧑🏻💻 dd で復活!
イメージなどをディスクに書き込んだりする dd
コマンドを使います。
DD(1) General Commands Manual DD(1)
NAME
dd – convert and copy a file
SYNOPSIS
dd [operands ...]
DESCRIPTION
The dd utility copies the standard input to the standard output. Input
data is read and written in 512-byte blocks. If input reads are short,
input from multiple reads are aggregated to form the output block. When
finished, dd displays the number of complete and partial input and output
blocks and truncated input records to the standard error output.
以下のようにやると復活したっぽい。
❯ diskutil unmountDisk force /dev/disk18
Forced unmount of all volumes on disk18 was successful
❯ sudo dd if=/dev/zero of=/dev/disk18 bs=1024 count=1024
1024+0 records in
1024+0 records out
1048576 bytes transferred in 4.508285 secs (232589 bytes/sec)
❯ diskutil partitionDisk /dev/disk18 GPT JHFS+ "My External HD" 0g
Started partitioning on disk18
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk18s2 as Mac OS Extended (Journaled) with name My External HD
Initialized /dev/rdisk18s2 as a 30 GB case-insensitive HFS Plus volume with a 8192k journal
Mounting disk
Finished partitioning on disk18
/dev/disk18 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *32.0 GB disk18
1: EFI EFI 209.7 MB disk18s1
2: Apple_HFS My External HD 31.7 GB disk18s2
👉 Disk Utility fails to erase/format an external HDD (El Capitan). "Mediakit reports not enough space on device for requested operation." : r/applehelp
👉 mac - How can I resolve the error "MediaKit reports partition (map) too small"? - Super User
/dev/zeroは、制限をかけてあげないとファイルシステムが埋まるまで
ゼロで埋めてしまうみたいです。
👉 /dev/nullと/dev/zeroの違いまとめ #Linux - Qiita
🧑🏻💻 復活を確認して、再フォーマットをする
以下のように復活の確認をして、
やりたかった再フォーマットまでできました!
❯ diskutil verifyDisk /dev/disk18
Started partition map verification on disk18
Checking prerequisites
Checking the partition list
Checking the partition map size
Checking for an EFI system partition
Checking the EFI system partition's size
Checking the EFI system partition's file system
Checking the EFI system partition's folder content
Checking all HFS data partition loader spaces
Checking booter partitions
Checking Core Storage Physical Volume partitions
The partition map appears to be OK
Finished partition map verification on disk18
❯ diskutil eraseDisk FAT32 SDCARD-32GB MBR /dev/disk18
Started erase on disk18
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk18s1 as MS-DOS (FAT32) with name SDCARD-32GB
512 bytes per physical sector
/dev/rdisk18s1: 62513312 sectors in 1953541 FAT32 clusters (16384 bytes/cluster)
bps=512 spc=32 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=8192 drv=0x80 bsec=62543872 bspf=15263 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk18
❯ diskutil list /dev/disk18
/dev/disk18 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *32.0 GB disk18
1: DOS_FAT_32 SDCARD-32GB 32.0 GB disk18s1
❯ diskutil info /dev/disk18
Device Identifier: disk18
Device Node: /dev/disk18
Whole: Yes
Part of Whole: disk18
Device / Media Name: Built In SDXC Reader
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None
Content (IOContent): FDisk_partition_scheme
OS Can Be Installed: No
Media Type: Generic
Protocol: Secure Digital
SMART Status: Not Supported
Disk Size: 32.0 GB (32026656768 Bytes) (exactly 62552064 512-Byte-Units)
Device Block Size: 512 Bytes
Media OS Use Only: No
Media Read-Only: No
Volume Read-Only: Not applicable (no file system)
Device Location: Internal
Removable Media: Removable
Media Removal: Software-Activated
Solid State: Info not available
Virtual: No
🧑🏻💻 まとめ
GUI ディスクユーティリティ はあやしいので diskutil
コマンド。
Windows / Mac 互換なら、FAT32 の MBR が今は普通で互換性があるか。
diskutil eraseDisk FAT32 SDCARD MBR /dev/disk18
# 容量・ファイルサイズが大きい場合
diskutil eraseDisk ExFAT SDCARD GPT /dev/disk18
先人先生、今回もありがとうございます。
あと、フォーマットに関しては以下が見やすかったです。
👉 ファイルシステム(FAT32、FAT16、NTFS、exFAT、HFS、HFS+、APFS)の違いについて | バッファロー
👉 【Mac】セブンイレブンのマルチコピー機と micro SDカード
KIOXIA(キオクシア) 旧東芝メモリ microSD 128GB UHS-I Class10 (最大読出速度100MB/s) Nintendo Switch動作確認済 国内サポート正規品 メーカー保証5年 KLMEA128G