Veternal1226
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Flash Memory File System ###### tags: `lesson` `rteslab` --- 架構: FMFS出現原因 NAND.NOR特性 FMFS架構 MTD 各FS特點(比較表) JFFS2 UBIFS YAFFS 補充 exFAT --- >待補清單 >UBIFS 找檔流程 >YASSF 垃圾收集 週期 >exFAT boundary alignment能有助於flash file system原因: >跟flash硬體有關 >若沒對齊造成跨頁,會浪費兩個區塊的壽命 >有對齊則可優化 > --- 書面報告 >https://hackmd.io/AoyMuVsoT7qWzOJmDbEiEg --- >電腦上通行的大部份檔案系統,都是針對碟盤儲存裝置設計的,應用到快閃記憶體上並不適合。一般的檔案系統,可以透過快閃記憶體轉換層(Flash Translation Layer,FTL)寫入快閃記憶體,但是它的缺點是寫入的效率較差。因此,設計快閃記憶體檔案系統仍然是有必要的。 >儘管磁碟檔案系統也能在快閃記憶體上使用,但快閃記憶體檔案系統是快閃記憶體裝置的首選,理由如下: - 擦除區塊:快閃記憶體的區塊在重新寫入前必須先進行擦除。擦除區塊會占用相當可觀的時間。因此,在裝置空閒的時候擦除未使用的區塊有助於提高速度,而寫入資料時也可以優先使用已經擦除的區塊。 - 隨機存取:由於在磁碟上尋址有很大的延遲,磁碟檔案系統有針對尋址的最佳化,以儘量避免尋址。但快閃記憶體沒有尋址延遲。 - 寫入平衡(Wear levelling):快閃記憶體中經常寫入的區塊往往容易損壞。快閃記憶體檔案系統的設計可以使資料均勻地寫到整個裝置。 >老FileSystem對flash較好原因: >寫入次數較少 [MTD](https://zh.wikipedia.org/wiki/MTD) http://mark-shih.blogspot.com/2012/10/mtd-devmtddevmtdblok.html MTD 是一個subsystem,用來簡化底層的flash device (ROM/NAND/OneNAND/NOR)的driver。在MTD下,driver只需提供read/write/erase的功能,而不需知道其上是使用FTL (Flash Translation Layer),還是FFS (Flash File System)。 為了讓既有的filesystem(fat/ext/xfs...)能用在flash device上,就需要FTL這個software layer。mtdblock就是其中一種FTL。要注意的是使用FTL時,如果改了其中一個sector,就必須讀一整個eraseblock到 memory,然後erase,最後再把整個eraseblock寫回,顯然cost很高。 具有 eraseblocks 的特微,而不是像硬碟一樣使用叢集。 eraseblocks (32KiB ~ 128KiB) 跟硬碟的 sector size(512 到 1024 bytes)比起來要大很多。 操作上主要分作三個動作: 從 eraseblock 讀取、寫入 eraseblock 、還有就是清除 eraseblock 。 壞掉的 eraseblocks 無法隱藏,需要軟體加以處理。 eraseblocks 的壽命大約會在 104 到 105 的清除動作之後結束。 像USB隨身碟、多媒體記憶卡(MMC)、SD卡、CF卡等其他流行的可移動儲存器要和MTD區分開來,雖然它們也叫「flash」,但它們不是使用MTD技術的儲存器 http://www.linux-mtd.infradead.org/faq/general.html#L_mtd_what |Block device|MTD device| |-|-| |Consists of sectors|Consists of eraseblocks| |Sectors are small (512, 1024 bytes)|Eraseblocks are larger (typically 128KiB)| |Maintains 2 main operations: read sector and write sector|Maintains 3 main operations: read from eraseblock, write to eraseblock, and erase eraseblock| |Bad sectors are re-mapped and hidden by hardware (at least in modern LBA hard drives); in case of FTL devices it is the responsibility of FTL to provide this|Bad eraseblocks are not hidden and should be dealt with in software| |Sectors are devoid of the wear-out property (in FTL devices it is the responsibility of FTL to provide this)|Eraseblocks wear-out and become bad and unusable after about 103 (for MLC NAND) - 105 (NOR, SLC NAND) erase cycles| SSD特性 https://kknews.cc/zh-tw/tech/k8xgvy8.html ### 物理特性 | | NOR | NAND | |-| -------- | -------- | || 可原地執行 | | |寫入速度| 慢 | 快 | |寫入單位| 1擦除區 | 1page | |擦除速度| 慢 | 快 | |擦除單位| 1擦除區 | 1擦除區 | |適合容量| 小 | 大 | |位元線|每個位元都有|多個位元一個| |隨機存取(位元)|有|無,只能連續存取| (1擦除區約為16~128kBytes) (1page可能為512,2048,4096,8192Bytes) NOR可原地執行 NAND容易有壞塊而使程式碼不連續 NOR每次寫入擦除都是以一擦除塊為單位 NOR常用在不需經常更新的程式 例如BIOS與韌體 快閃記憶體可分為頁(Page)、帶外區(OOB)、擦除塊(Block)。 - 頁就是快閃記憶體讀取及寫入的最小單位,依顆粒製成不同有512,2048,4096,8192位元組。 - 帶外區是每一個頁在實體的結構中實際數據位元組之外的使用空間,若以2048位元組為一頁為例,每一個頁在實體的結構中除了2048位元組的使用空間,還會有64位元組額外的容量,供硬體以及軟體儲存一些額外的資訊,通常會用來儲存糾錯碼的數據,來校正快閃記憶體使用久後會有位元不能使用的問題。 - 擦除塊為快閃記憶體擦除的最小單位, 每64或128頁即為一個擦除塊,因為頁大小會有不同,擦除塊也就不同。一顆晶片裡有多少擦除塊,是依快閃記憶體的大小而定,但通常是2的冪次方。 NAND結構: 2D SLC 1單元1bit2狀態 MLC 1單元2bit4狀態 TLC 1單元3bit8狀態 3D還沒好 |製成結構|單層單元(SLC)|多層單元(MLC)|三層單元(TLC)|四層儲存單元(QLC) |-|-|-|-|-| |每晶體儲存單位|1 位元|2 位元|3 位元|4位元 |寫入速度|200–300微秒每頁|600 - 900微秒|每頁|900–1350微秒每頁 |讀取速度|25微秒每頁|50微秒每頁|75微秒每頁 |擦除速度|1.5~2微秒每擦除塊|3微秒每擦除塊|4.5微秒每擦除塊 |使用壽命|5萬到10萬次寫入|3千到1萬次寫入|五百到1千次寫入 ## FFS2 最早 ## JFFS2 JFFS2是專為小型快閃記憶體設計的快閃記憶體檔案系統。可以使用在NOR或NAND快閃記憶體上,僅在SLC架構中使用,含有多種壓縮模式可以選用。此設計的檔案系統基本結構之儲存最小單位為一節點,每個節點都包含檔案資訊;屬於同一檔案的節點,則可以指向同一檔案的節點位置,也增加意外斷電時,可找回數據資料的可能性。在JFFS2寫入操作時,會立即寫入快閃記憶體,藉由主記憶體結構更新節點位置,加快讀取速度。因為並無目錄紀錄檔案位置,在掛載時需要掃描整個快閃記憶體,隨著儲存空間的增大,掛載時間也隨之增加。 [原始論文](https://www.kernel.org/doc/mirror/ols2001/jffs2.pdf) ISO690 WOODHOUSE, David. JFFS: The journalling flash file system. In: Ottawa linux symposium. 2001. https://baike.baidu.com/item/jffs2 ![](https://i.imgur.com/0W9401e.png) 下一代是UBIFS與LogFS ### UBIFS ![](https://i.imgur.com/SLvd5Az.png) ## YAFFS Yet Another Flash File System 屬於Log-structured file systems 有YAFFS與YAFFS2 YAFFS2可支援到2K per page, 遠高於YAFFS的512 bytes, 因此對大容量NAND Flash更具優勢 Yaffs1 is a simpler mode of operation that uses deletion markers to track state. ● Yaffs2 is a more complex mode of operating that was developed to support larger flash types that cannot used deletion markers. ● Yaffs means operations common to both. YAFFS採用Tree Node Structure, 由多個Tree Node(Tnode)所組成, Tnode又分成Internal Tnode與Lowest-Level Tnode, 其中Internal Tnode由8個Pointers所組成, Lowest-Level Tnode由16個Entries所組成, 其時間複雜度(Time Complexity)相當於O(log N), 故位址轉換時間較迅速。 官網介紹 https://archive.is/1WjyJ https://web.archive.org/web/20071006090305/http://www.yaffs.net/ 配合NAND記憶體特性開發的檔案系統 從MTD(記憶體裝置)得到的NAND頁大小而分配chunk大小,每chunk就是一頁 16~20頁 >學長的論文有JFFS2跟YAFFS2跟UBIFS的比較 Yaffs1 uses deletion markers, which breaks the sequential write rule. Yaffs2 does not use deletion markers 識別符號為YAFFS2判別檔案型別如目錄、文件等等。 父節點編號為記錄上層節點編號,通常是目錄節點;若是根目錄則為0 名字為檔案名稱可存放255位元組。 重規劃檔案大小是由於配合快閃記憶體檔案系統運作出現的,由於一份檔案的元資料只會出現在Chunk為0的節點,所以若是有檔案原來為10M的資料改變其中5M的資料只寫入3M時,會有2M的資料空洞產生。此時就需要加以記錄改變後的大小與記錄符號連接,而不使檔案資料遺失。 檔案識別符號為虛擬檔案系統辨別檔案的型別、創建時間、修改時間等等。 檔案大小則為此檔案的資料量,由於只有一個元資料,這也表示提取多少Chunk有此元資料決定。 最後是硬連接與符號連接 ### UBIFS https://zh.wikipedia.org/wiki/UBIFS UBI相當於UBIFS的FTL 作用是實現垃圾回收 ## exFAT 由FAT32演變 https://zh.wikipedia.org/wiki/ExFAT https://blog.gtwang.org/windows/ntfs-vs-fat-exfat-file-system/ https://baike.baidu.com/item/exFAT 为了解决FAT32等不支持4G及其更大的文件而推出。对于闪存,NTFS文件系统不适合使用,exFAT更为适用。对于磁盘则不太适用 與其他FS比較表 https://www.eassos.cn/jiao-cheng/ying-pan/file-system.php FAT兩大限制: 1、FAT分区中的单个文件不能大于4G;2、通常FAT分区的容量不能大于32G,否则效率会很低 https://en.wikipedia.org/wiki/ExFAT#Flash_optimizations exFAT contains a few features that, according to Microsoft, makes it flash-friendly: - Boundary alignment for filesystem structures. The offsets for the FAT and the cluster heap is adjustable at format-time, so that writes to these areas will happen in as few flash blocks as possible. - An "OEM Parameters" field can be used to record features such as block size of the underlying storage.[37] - The lack of a journal, so that less data are written http://jay-fva.blogspot.com/2011/11/exfat.html exFAT原本設計的目的是在FAT32與NTFS之 間取得一個折衷,有FAT32的輕便、不需要耗損太多的效能及記憶體來處理檔案運作,又有類似NTFS的CAL存取控制機制(很可惜在SP1下找不到 exFAT對於CAL的支援),以及類似HPFS系統可快速整理可用叢集空間的Free Space Bitmap,來將檔案破碎的情況盡量減少。 >exFAT用大cluster >大cluster浪費空間 | 1|JFFS2|YAFFS2|UBIFS |-|-|-|-| |壓縮功能|支持|不支持|支持| |快閃記憶體類別|NOR、NAND|NAND|NOR、NAND |快閃記憶體結構|2D-SLC|2D-SLC、2D-MLC|2D-SLC、2D-MLC |檔案大小|最大4 GByte|最大512GByte|最大2048GByte |最大檔名|254 Byte|255 Byte|255 Byte |寫入動作|同步|同步|同步、回寫 ||JFFS2| YAFFS2| UBIFS| |-|-|-|-| |掛載時間|每512MiB增加1.8秒|每512MiB增加0.2秒|3秒 |卸載時間|最慢不超過0.01秒|0.0003秒|0.05秒 |寫入|2.7MiB/s|2.8MiB/s|3.1MiB/s |讀取|1.8MiB/s|3.5MiB/s|2.4MiB/s |垃圾回收|空間有效利用|時間不會增加|實際不由檔案系統控制 2010年1月15日,Google宣布將他們公司使用的檔案系統,由ext2,升級為ext4。在同年12月14日,Google也宣布他們將在Android 2.3版中,使用ext4來取代之前的YAFFS。 --- 網頁list zh.wikipedia.org/wiki/闪存#快閃記憶體檔案系統 zh.wikipedia.org/wiki/快閃記憶體檔案系統 en.wikipedia.org/wiki/Flash_file_system https://zh.wikipedia.org/wiki/MTD www.linux-mtd.infradead.org/faq/general.html#L_ext2_mtd mark-shih.blogspot.com/2012/10/mtd-devmtddevmtdblok.html en.wikipedia.org/wiki/Flash_file_system zh.wikipedia.org/wiki/Ext4 en.wikipedia.org/wiki/ExFAT#Flash_optimizations zh.wikipedia.org/wiki/F2FS zh.wikipedia.org/wiki/UBIFS baike.baidu.com/item/exFAT eassos.cn/jiao-cheng/ying-pan/file-system.php zh.wikipedia.org/wiki/YAFFS#YAFFS2 archive.is/rpCEN yaffs.net/yaffs-overview yaffs.net/yaffs-2-specification https://yaffs.net/sites/yaffs.net/files/HowYaffsWorks.pdf ethesis.nitrkl.ac.in/6534/2/E-3.pdf

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully