私は私が特定のファイルがフラッシュメモリ(内部ストレージ)で移動し、書き込み/更新の間に移動するかどうかを知りたいです。
フラッシュメモリ上のファイルの場所を取得できる方法はありますか?
(クラスタ番号、セクタ番号など)
私はAndroid V8を使用しています、
そしてそれのためにアプリを使用するのを使ってインストールすることができます、
または、該当するコマンドが存在する場合は、Androidが存在する場合はコマンドラインを使用してください。
私は私が特定のファイルがフラッシュメモリ(内部ストレージ)で移動し、書き込み/更新の間に移動するかどうかを知りたいです。
フラッシュメモリ上のファイルの場所を取得できる方法はありますか?
(クラスタ番号、セクタ番号など)
私はAndroid V8を使用しています、
そしてそれのためにアプリを使用するのを使ってインストールすることができます、
または、該当するコマンドが存在する場合は、Androidが存在する場合はコマンドラインを使用してください。
I would like to know If I certain file moves on the Flash memory (internal storage), between writes/updates to it.
Is there some way I can get the file's location on the Flash memory?
(Cluster Number, Sector Number, etc)
I am using Android v8,
and can either install use an App for that,
or use the Command Line, If a relevant command exists in the Linux command-prompt that Android has.
cluster を言うことによって仮定しますWindows ' ALLOCATION UNIT Linuxの世界では、一般に block と呼ばれています。ファイルシステムが使用するデータストレージの単位です。クラスタ/ブロックは、基礎となる記憶媒体(HDDまたはフラッシュストレージ)上の複数の とからなるかまたは対応することができる。セクタは、OSが読み書きできるストレージの最小アトミック単位です。ブロックサイズは、ファイルシステム作成時に決定されます。すなわち、パーティションをフォーマットするとき(<コード> 9988776666544330 )。パーティションとファイルシステムは、物理ストレージデバイス上のデータを分類して整理することを容易にします。
ハードディスクドライブ
「セクタ」は、 物理セクタ または 論理セクタ を指すことがある。 HDDの初期頃には、回転ディスク上のクラスタ/トラックを小さな部分に分割することによって作成された物理的なセクターだけがありました。 c イリンダ/ h EAD / s Ector(CHS)は、 L Ogicalの前にアドレス指定する方法です。 b ロック a ddressing(LBA)を考案しました。物理セクタを直接扱う代わりに、OSはLBA番号を参照してディスクコントローラファームウェア(SATA / SCSIコマンドを介して)と話すようになりました。リターンのファームウェアは、
フラッシュストレージ
フラッシュメディア(SSDS、EMMC、UFS、SDカードなど)回転ディスクはなく、シリンダーはありません。 NANDフラッシュはシリコンセルでできています。各セルは1つ( s ingle l evel - c ell)、2( M ulti- lc )、3( t rip- lc )または4( q UAD - lc )ビット。細胞はページ(例えば4kb)とページに分類され、消去ブロック(例えば128kb)。 LBAS~ p ヒリアシカル b ロック ddressesマッピングは、 f ラッシュ t 繰り返し l Ayer。フラッシュコントローラのファームウェアの一部。 OSはそれについて何も知っていない、それはそれを下に起こっているものではなく、最大LBAで見ることができます。 ECC の故障メモリセルのECC mmc-utils または<コード> 9988776544333 (ドライバがサポートしている場合)。
HDDとは異なり、メモリのページが上書きされないので、 > プログラム (書面)。副作用は、小さなファイルが編集されていても、ページ数が消去/書き直され、物理マッピングが変わることです。この不要な読み取り修正書き込み(http://codecapsule.com/2014/02/12/2014/02/12/2014/02/12/2014/02/12/2014/02/12/2014/02/12/2014/02/12-pages-blocks-and-the-lash-translation-layer / "REL =" NOFOLLOW NOREFERRER "> RMW )は、 w riite a 集合と呼ばれます。 HDDでは、短縮または伸びのない限り、ファイルは物理的に置き換えられません。 OSはHDDのこれらの物理的な変更を認識していますが、フラッシュメモリではありません。
それで、私たちが関心のあるものすべてが論理セクターです。 ストレージメディアは、論理セクターサイズのOSに通知しますが、デフォルト 512のハードウェア" をカバーしているため、HDDは 4kn形式もHDDの場合も。<コード> 512B は、実際には少し大きいサイズです。ヘッダー、ECCなどの部屋を作ります。 /#post5936065 "rel =" nofollow noreferrer "> USE 。
あなたのクエリ:
特定のファイルがフラッシュメモリ(内部ストレージ)で移動したかどうかを知りたいのですが、書き込み/更新の間に。
「Move」の定義に依存します。フラッシュストレージでは、ファイルに書き込まれていなくても、背景のために真の物理的な場所を変更し続けることができます g arges c OLELECTION; を達成するために、 を除去し、を削除することで高い書き込みスループット(<>プログラム演算)を実現するために、FTLによって制御される現象が内部的に制御されます。 バックグラウンドで が無効です( Erase 操作)。
フラッシュメモリ(クラスタ番号、セクタ番号など)にファイルの場所を取得できる方法はありますか?
YES基礎となるブロックデバイス(パーティション)のLBASとのリニアマッピングを持つファイルのファイルシステムブロックアドレスを取得できます。しかし、これらのアドレスは、フラッシュメモリ上の実際の/物理の場所ではありません。ただし、通常の法医学やデータ回復が関係していない限り、通常は真の物理的な場所に関係しません。
例
<コード> /sys/class/mmc_host/*/*/life_time6
だからここでのセクタサイズは512bですが、ファイルシステムブロックサイズは4kibです。テストファイルを作成しましょう:
<事前> <コード> ~# echo foobar >/cache/test_file ~# cat /cache/test_file foobar ~# filefrag -sv -b512 /cache/test_file Filesystem type is: ef53 File size of /cache/test_file is 7 (8 block of 512 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 7: 307200.. 307207: 8: last,eof /cache/test_file: 1 extent found* <コード> debugfs -R 'stat test_file' /dev/block/by-name/cache <コード>
の代わりに使用することもできます。作成されたファイル(7バイトサイズ)を占めます.1 fileSystemブロックを占めます。 99887766544433310
ブロックサイズ(4096b)をセクタサイズ(512b)に変換します。ファイルシステム全体の占有率:
パーティションから直接ファイルを読みましょう:
<事前> <コード> /sys/class/mmc_host/*/*/life_time12そこにいます。これで、EMMCの開始からファイルを見つけます。
<コード> /sys/class/mmc_host/*/*/life_time13
だからファイルシステムとパーティションが削除されても、ファイルを読むことができます(上書きされないように)。
もう少し掘ることをしましょう:
<コード> low-level formatting4
ファイルはファイルシステムから削除されますが、物理的にはまだそこにあります。 FTLに永久に削除するように依頼しましょう。
<コード> low-level formatting5
そしてそれは消えています。しかし、最も o ver- p rovisioning spaceのどこかでまだそこにあります。次のGCで消去された 、それがどこにあるのかわからないだけです。
注:
EXT_CSD0
はBusyBoxアプレットです。関連:
I assume by saying cluster you mean Windows' allocation unit, commonly called block in Linux world. It's a unit of data storage a filesystem uses. A cluster/block may consist of or correspond to multiple sectors on underlying storage media (HDD or flash storage). Sector is the minimum atomic unit of storage an OS can read or write. Block size is decided at the time of filesystem creation i.e. when we format a partition (high-level formatting
). Partitions and filesystems make it easy to categorize and organize our data on the physical storage device.
HARD DISK DRIVES
"Sector" may refer to a physical sector or logical sector. In early days of HDDs there were only physical sectors created by dividing clusters/tracks on rotating disks into small parts. Cylinder/Head/Sector (CHS) has been a popular method of addressing before the Logical Block Addressing (LBA) was devised. Instead of directly dealing with physical sectors, OS now talks to disk controller firmware (through SATA/SCSI commands) referring an LBA number. Firmware in return maintains an LBA to CHS mapping itself, which includes ECC, G-list (disk's defect table) etc. This mapping (1:1 / sequenced / linear) (ref) is created during low-level formatting
of disk drive when manufacturing, which never changes except if some sector is marked bad and remapped to some spare sector. So the OS / filesystem is aware of the physical geometry of the disk, which is propotional to the geometry of LBAs.
FLASH STORAGE
On flash media (SSDs, eMMC, UFS, SD cards etc.) there are no rotating disks and hence no cylinders. NAND flash is made of silicon cells, each cell consists of one (Single-Level-Cell), two (Multi-LC), three (Triple-LC) or four (Quad-LC) bits. Cells are grouped into pages (e.g. of 4KB) and pages into erase blocks (e.g. of 128 KB). LBAs to Physical Block Addresses mapping is fully controlled by Flash Translation Layer; a part of flash controller firmware. OS knows nothing about it, it can see at maximum the LBAs, not what's happening below it. Not even the ECC of failed memory cells, and that's why we don't realize the bad health of eMMC unless it fails, except by reading EXT_CSD
(requires root) using mmc-utils or from /sys/class/mmc_host/*/*/life_time
(if driver supports).
Since a page of memory can't be just overwritten unlike HDDs, a whole EraseBlock has to be Erased first before being Programmed (written). A side effect is that a number of pages are erased/re-written and the physical mapping changes even if a small file is edited. This unnecessary read-modify-write (RMW) is called Write Amplification. On HDDs, files aren't physically replaced unless shortened or elongated. OS is aware of these physical changes on HDD, but not on flash memory.
WHAT IS SECTOR?
So after all what we are concerned with is logical sector. Storage media informs the OS of its logical sector size but xe2x80x9cthe default of 512 covers most hardwarexe2x80x9d because HDDs have been using 512B
from early days, though things have changed with 4Kn format for HDDs too. 512B
is the size what OS sees, in actual it's a bit larger to make some room for header, ECC etc. Physical sector size on flash storage is of no use to us.
Your queries:
I would like to know if a certain file moves on the Flash memory (internal storage), between writes/updates to it.
It depends on the definition of xe2x80x9cmovexe2x80x9d. On flash storage, even if you don't write to a file, it may keep on changing its true physical location due to background Garbage Collection; a phenomenon controlled by FTL internally to reduce WA, to achieve Wear Leveling and to provide high write throughput (Program operations) by deleting invalid pages in background (Erase operations).
Is there some way I can get the file's location on the Flash memory (Cluster Number, Sector Number etc.)?
Yes you can get the filesystem block addresses of a file which have a linear mapping with LBAs of underlying block device (partition). But these addresses aren't the actual/physical file's location on the Flash memory. However usually one isn't concerned with true physical location unless some forensics or data recovery is involved.
EXAMPLE
~# cat /sys/block/mmcblk0/queue/logical_block_size 512 ~# blockdev --getss /dev/block/by-name/cache 512 ~# tune2fs -l /dev/block/by-name/cache | grep 'Block size' Block size: 4096
So the sector size here is 512B while filesystem block size is 4KiB. Let's create a test file:
~# echo foobar >/cache/test_file ~# cat /cache/test_file foobar ~# filefrag -sv -b512 /cache/test_file Filesystem type is: ef53 File size of /cache/test_file is 7 (8 block of 512 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 7: 307200.. 307207: 8: last,eof /cache/test_file: 1 extent found
* debugfs -R 'stat test_file' /dev/block/by-name/cache
can also be used in place of filefrag
Created file (of 7 bytes size) occupies 1 filesystem block. -b 512
converts block size (4096B) to sector size (512B). "test_file" should be at 307200th sector, same for partition and filesystem because filesystem occupies whole partition:
~# blockdev --getsize64 /dev/block/by-name/cache | awk '$1 /= 4096' 65536 ~# tune2fs -l /dev/block/by-name/cache | grep 'Block count' Block count: 65536
Let's read the file directly from partition:
~# dd if=/dev/block/by-name/cache skip=307200 count=1 | head -c7 foobar
It's there. Now locate the file from the start of eMMC:
~# readlink /dev/block/by-name/cache /dev/block/mmcblk0p25 ~# cat /sys/block/mmcblk0/mmcblk0p25/start 7471104 ~# dd if=/dev/block/mmcblk0 skip=$(( 7471104 + 307200 )) count=1 | head -c7 foobar
So even if filesystem and partition are deleted, you can read the file (provided that it's not overwritten).
Let's do some more digging:
~# rm /cache/test_file; sync; echo -n 1 >/proc/sys/vm/drop_caches ~# dd if=/dev/block/mmcblk0 skip=$(( 7471104 + 307200 )) count=1 | head -c7 foobar
File is deleted from filesystem, but physically still there. Let's ask FTL to delete it permanently:
~# fstrim /cache; sync; echo -n 1 >/proc/sys/vm/drop_caches ~# dd if=/dev/block/mmcblk0 skip=$(( 7471104 + 307200 )) count=1 | head -c7
And it's gone. But most probably it's still there somewhere in Over-Provisioning Space, scheduled to be Erased in next GC, just we don't know where it is.
Note:
dd
on naked partitions is a killer. Be cautious!tune2fs
and filefrag
are part of e2fsprogs. filefrag
isn't shipped with Android, build from source or try this one. fstrim
is a busybox applet.RELATED:
© 2022 cndgn.com All Rights Reserved. Q&Aハウス 全著作権所有