0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【2025年01月版】macOSで、偽装された容量のデバイスかどうかのチェック【容量偽装、SDカード、USBメモリ、SSD】

Posted at

はじめに

最近、USBメモリや、SDカード、SSDの容量偽装多すぎ。。。

f3write / f3read でチェクしても時間かかるし。。。

そうだ、dd で、指定位置に書き込みできるかどうかでチェックしよう

f3write / f3read によるチェックの方法は以下の記事を参照

【2023年8月版】macOS で f3 によるSDカードの容量偽装チェック【f3write/f3read】

確認方法

前提条件

  • デバイスは、64Gだと公証されているとします。
  • デバイスは、/dev/disk4 にマウントされているものとします。
  • デバイスがどこにマウントされているかは、以下のコマンドで確認します。
    % diskutil list
    

概要

  • 指定の位置に文字列を書き込み
  • デバイスを抜く
  • デバイスを指す
  • 指定の位置の文字列を読み込んで書き込み内容をチェック

指定の位置に文字列を書き込み

  • ポジションは、seek=$((63*1024*1024*1024)) で指定しますが、適当に1-2Gぐらい抜いておくと良いでしょう
% diskutil umountDisk /dev/disk4
% echo -n "hello" | sudo dd of=/dev/disk4 bs=1 seek=$(((63-1)*1024*1024*1024)) count=5
5+0 records in
5+0 records out
5 bytes transferred in 0.075170 secs (67 bytes/sec)
  • 一旦書き込み内容を確認
% sudo dd if=/dev/disk4 skip=$(((63-1)*1024*1024*1024)) bs=1 count=5 | hexdump -C
5+0 records in
5+0 records out
5 bytes transferred in 0.002430 secs (2058 bytes/sec)
00000000  68 65 6c 6c 6f                                    |hello|
00000005

デバイスを抜く

  • 以下のコマンドを実行した後にデバイスを抜きましょう
$ diskutil umountDisk /dev/disk4

デバイスを指す

  • ふたたびデバイスを差し込んでください。

指定の位置の文字列を読み込んで書き込み内容をチェック

  • 再び書き込み内容を確認
$ sudo dd if=/dev/disk4 skip=$((63*1024*1024*1024)) bs=1 count=5 | hexdump -C

容量が偽装されていない場合

  • 書き込み内容が確認できます。
% sudo dd if=/dev/disk4 skip=$(((63-1)*1024*1024*1024)) bs=1 count=5 | hexdump -C
5+0 records in
5+0 records out
5 bytes transferred in 0.002430 secs (2058 bytes/sec)
00000000  68 65 6c 6c 6f                                    |hello|
00000005

容量が偽装されている場合

  • 書き込み内容が確認できず、0 になります。
% sudo dd if=/dev/disk4 skip=$(((63-1)*1024*1024*1024)) bs=1 count=5 | hexdump -C
5+0 records in
5+0 records out
5 bytes transferred in 0.062127 secs (80 bytes/sec)
00000000  00 00 00 00 00                                    |.....|
00000005

さいごに

かんたんでしたね

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?