Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:user-guide:filesystems-and-partitions [2017/10/30 20:23] – ↷ Page name changed from docs:user-guide:advancedfilesystem to docs:user-guide:filesystems-and-partitions bobafetthotmaildocs:guide-user:storage:filesystems-and-partitions [2024/09/04 08:38] – [Partitions] artoria2e5
Line 1: Line 1:
 ====== Filesystems ====== ====== Filesystems ======
-This page contains advanced information about creating file systems on external disks.+This page contains basic information about filesystems (file systems) and partitionsA filesystem is "how data is written in a partition of the storage device". Windows, macOS, and Linux use different default filesystems, and not all filesystems work equally well across operating systems.\\
  
-A filesystem is "how data is written in partition of the storage device".\\  +OpenWrt is a Linux-based operating system and thus typically works best with filesystems native to LinuxHowever it can also read/write data with many filesystems, albeit sometimes slower or less reliable than with native Linux filesystems. In case you wonder, the reason for this reduced performance is patents and other ways to impede the adoption of Microsoft or Apple filesystems by other parties.\\
-Windows, macOS/OSX and LEDE (Linux) use different default filesystems, and not all filesystems can be read by all equally well (if at all).\\ +
-LEDE is a Linux-based system, so it can read and write data written in Windows and macOS filesystems, it will be slower, more limited and less reliable than when reading/writing data from native linux filesystems. So if you want to transfer data they may be good enough, but for a storage device permanently attached to your LEDE device, using a native Linux filesystem is recommended.\\ +
-In case you wonder, the reason for this lack of performance/reliability is patents, trade secrets and other ways to impede the adoption of Windows or Apple filesystems by other parties.+
  
-===== Currently supported filesystems ===== +Installing these additional filesystems in OpenWrt is commonly for file sharing using [[:docs:guide-user:storage:usb-drives-quickstart|USB 3.0 storage]] and [[:docs:guide-user:services:nas:cifs.server|Samba]]
-To see what filesystems can be read by the firmware currently installed, write ''cat /proc/filesystems''.\\  +
-This is an example output from a LEDE x86 Virtual Machine, it can read many filesystems as space is not an issue. +
-For most devices, you will have to choose what filesystems you need to be able to access, and install the package with the filesystem driver for it. +
-<code>nodev   sysfs +
-nodev   rootfs +
-nodev   ramfs +
-nodev   bdev +
-nodev   proc +
-nodev   tmpfs +
-nodev   binfmt_misc +
-nodev   debugfs +
-nodev   sockfs +
-nodev   bpf +
-nodev   pipefs +
-nodev   devpts +
-        ext3 +
-        ext2 +
-        ext4 +
-        squashfs +
-nodev   overlay +
-        btrfs +
-        f2fs +
-        xfs +
-        vfat</code>+
  
-===== LEDE/Linux filesystems ===== +==== Check available filesystems ==== 
-There are 2 main filesystems you are going to be interested in[[wp>ext4]] and [[wp>f2fs]].\\  +To see what filesystems can be read currentlyenter ''cat /proc/filesystems''.\\ 
-In short:\\ +
-  * ext4 is best suited for hard drives +
-  * f2fs is best suited for flash drives (SSDs and usb thumbdrives)+
  
-Choose the one most suited to your storage device and proceed.\\+A full list of filesystems available in OpenWrt can be obtained by writing\\  
 +''opkg update && opkg list | grep kmod-fs'' 
 + 
 +The tools for the filesystem of your choosing can be found by writing\\ 
 +''opkg list | grep FILESYSTEM_NAME'' 
 + 
 +OpenWrt has drivers and filesystem tools available for ext2/3/4, f2fs, btrfs, and many other filesystems supported by Linux. 
 + 
 +===== OpenWrt/Linux filesystems ===== 
 +The two most common Linux filesystems are [[wp>ext4]] and [[wp>f2fs]], with [[wp>btrfs]] growing in popularity:\\  
 + 
 +  * ext4 is well suited for HDDs and SSDs (using TRIM) and is the default filesystem of most desktop Linux distributions. 
 +  * f2fs is well suited for flash (SSDs or USB thumbdrives). The format can be incompatible between kernel versions, requiring some time for "fsck" to upgrade the filesystem. 
 +  * btrfs is the default filesystem for more cutting-edge Linux distributions. It is considered the sucessor to ext4, with the author stating "there will be no ext5". It has some more advanced features such as checksumming.
  
-<WRAP center round todo 90%> +==== ext4 ====
-WARNING: **fsck.f2fs** from **f2fstools** 1.7.0 is broken on **ar71xx** (mips32 big endian) platform. +
-**fsck.f2fs** corrupts valid f2fs partitions. Current **f2fstools** version in LEDE 17.01.1 (released mid-April) is version 1.8.0, which does not have this issue, check versions and upgrade at once. +
-</WRAP>+
  
-==== Setup ext4 ==== 
 This command will download the tools needed to create and fix ext4 (and older versions)\\ This command will download the tools needed to create and fix ext4 (and older versions)\\
 ''opkg install e2fsprogs'' ''opkg install e2fsprogs''
Line 53: Line 32:
 ''opkg install kmod-fs-ext4'' ''opkg install kmod-fs-ext4''
  
-==== Setup f2fs ====+==== f2fs ====
 This command will download the tools needed to create and fix f2fs\\ This command will download the tools needed to create and fix f2fs\\
 ''opkg install f2fs-tools'' ''opkg install f2fs-tools''
Line 60: Line 39:
 ''opkg install kmod-fs-f2fs'' ''opkg install kmod-fs-f2fs''
  
-===== Other Linux filesystems (for advanced users) ===== +==== btrfs ==== 
-a full list of supported linux filesystems can be obtained by writing\\  +This command will download the tools needed to create and fix btrfs\\ 
-''opkg update && opkg list | grep kmod-fs''+''opkg install btrfs-progs''
  
-the tools for the filesystem of your choosing can be found by writing\\ +If in the list of supported filesystems in your device you don't see btrfs, you must install also the driver itself\\ 
-''opkg list | grep FILESYSTEM_NAME''+''opkg install kmod-fs-btrfs'' 
 + 
 +===== Windows filesystems ===== 
 + 
 +The two most common filesystems used by Windows are [[wp>NTFS]] and [[wp>exFAT]] as described below. 
 + 
 +==== NTFS ==== 
 + 
 +NTFS is the primary Windows filesystem and is available via the ''NTFS-3G'' driver. With kernel 5.15 onward the new [[https://www.phoronix.com/news/NTFS3-For-Linux-5.15|NTFS3 driver]] called ''NTFS3'' aims to provide improved performance as an in-kernel driver similar to other Linux filesystems. Either driver may be used in OpenWrt, however below is written for the legacy driver.\\ 
 + 
 +Download and install via the NTFS-3G driver\\ 
 +''opkg install ntfs-3g'' 
 + 
 +This command will download the tools needed to create and fix NTFS\\  
 +''opkg install ntfsprogs_ntfs-3g'' 
 + 
 +See [[docs:guide-user:storage:writable_ntfs|Writable NTFS]] for important information on mounting options for better performance and features. TRIM is supported under Linux/OpenWRT. 
 + 
 +===== Apple filesystems ===== 
 +In Apple land you have [[wp>HFS]], [[wp>HFS+]] and [[wp>APFS]]. There is a driver available for HFS and HFS+ but it has low performance and does not support all features. APFS was introduced in 2017 but there is currently no support for it in OpenWrt (nor in Linux). 
 + 
 +==== HFS and HFS+ ==== 
 +This command will download the tools needed to create and fix HFS and HFS+\\ 
 +''opkg install hfsfsck'' 
 + 
 +If in the list of supported filesystems in your device you don't see **hfs** and **hfsplus**, you must install also the drivers\\ 
 +''opkg install kmod-fs-hfs kmod-fs-hfsplus''
  
-As of this writing (2017) LEDE has drivers and filesystem tools for ext2/3/4, f2fs, xfs and btrfs, and drivers for most other filesystems supported by Linux. 
  
 ===== Multiplatform filesystems ===== ===== Multiplatform filesystems =====
-The only filesystem that is recommended for drives you will use for multiplatform usage is [[wp>FAT32]]. It will be read by Windows, macOS/OSX, Linux, and any other device you might have (smartTV, tablets, car sound systems with usb port...). 
-Its main drawback (for a data drive) is that it cannot store a file bigger than 3.9 GiB even if the drive itself is bigger than that. 
-It is also prone to corruption if the device is disconnected while still writing, which can lead to data loss if the device is written again without running a filesystem check. 
  
-==== Setup FAT32 ==== +==== FAT32 ==== 
-this command will download the tools needed to create and fix FAT32 (and older versions)\\ +[[wp>FAT32]] was a common multiplatform file system. It can be read/write by Windows, macOS, Linux, and any other device you might have (smartTV, tablets, car audio with usb, etc). Its has two major drawbacks given its age: it cannot store files larger than 3.9 GB, and it lacks journaling support, meaning it's also prone to corruption if the device is disconnected while writing. This can lead to data loss if the device is written again without running a filesystem check. 
-''opkg install dosfstools'' (The dosfstools package includes the [[https://linux.die.net/man/8/mkfs.vfat|mkfs.fat]] and [[https://linux.die.net/man/8/fsck.vfat|fsck.fat]] utilities, which respectively make and check MS-DOS FAT filesystems. Also stated above.)+ 
 +This command will download the tools needed to create and fix FAT32 (and older versions)\\ 
 +''opkg install dosfstools'' (The dosfstools package includes the [[https://linux.die.net/man/8/mkfs.vfat|mkfs.fat]] and [[https://linux.die.net/man/8/fsck.vfat|fsck.fat]] utilities, which respectively make and check MS-DOS FAT filesystems.)
  
 If in the list of supported filesystems in your device you don't see **vfat**, you must install also the driver itself\\ If in the list of supported filesystems in your device you don't see **vfat**, you must install also the driver itself\\
 ''opkg install kmod-fs-vfat'' ''opkg install kmod-fs-vfat''
  
-==== Available NLS files ====+=== Available NLS files ===
  
-For some filesystems, like for VFATyou need to additionally install language packages (codepages / charsets) to handle the filenames.  If your mount fails, look in dmesg - a message like\\+Some filesystems, like FAT32may need additional Native Language Support (NLS) packages (codepages / charsets) to handle the filenames. If your mount fails, look in dmesg - a message like\\
 ''FAT: codepage cp437 not found''\\ ''FAT: codepage cp437 not found''\\
 means that you need NLS codepage 437, and a message like\\ means that you need NLS codepage 437, and a message like\\
Line 89: Line 92:
 means that you need NLS ISO 8859-1. means that you need NLS ISO 8859-1.
  
-Available NLS files and their packages can be listed by writing ''opkg updateopkg list "kmod-nls*"''.+Available NLS packages can be listed by writing ''opkg update && opkg list "kmod-nls*"''. There will be many available, below are a few examples.
  
 ^ Name                ^ Description  ^ ^ Name                ^ Description  ^
Line 97: Line 100:
 | kmod-nls-cp775      | Kernel module for NLS Codepage 775 (Baltic Rim)            | | kmod-nls-cp775      | Kernel module for NLS Codepage 775 (Baltic Rim)            |
 | kmod-nls-cp850      | Kernel module for NLS Codepage 850 (Europe)                | | kmod-nls-cp850      | Kernel module for NLS Codepage 850 (Europe)                |
-| kmod-nls-cp852      | Kernel module for NLS Codepage 852 (Europe)                | 
 | kmod-nls-cp866      | Kernel module for NLS Codepage 866 (Cyrillic)              | | kmod-nls-cp866      | Kernel module for NLS Codepage 866 (Cyrillic)              |
 | kmod-nls-iso8859-1  | Kernel module for NLS ISO 8859-1 (Latin 1)                 | | kmod-nls-iso8859-1  | Kernel module for NLS ISO 8859-1 (Latin 1)                 |
-| kmod-nls-iso8859-13 | Kernel module for NLS ISO 8859-13 (Latin 7; Baltic)        | 
-| kmod-nls-iso8859-15 | Kernel module for NLS ISO 8859-15 (Latin 9)                | 
-| kmod-nls-iso8859-2  | Kernel module for NLS ISO 8859-2 (Latin 2)                 | 
 | kmod-nls-koi8r      | Kernel module for NLS KOI8-R (Russian)                     | | kmod-nls-koi8r      | Kernel module for NLS KOI8-R (Russian)                     |
 | kmod-nls-utf8       | Kernel module for NLS UTF-8                                | | kmod-nls-utf8       | Kernel module for NLS UTF-8                                |
  
-===== Windows filesystems ===== +==== exFAT ====
-The only filesystem used on Windows PC is [[wp>NTFS]], on LEDE (Linux) it is available but it's performance is low, avoid it if you can.\\ +
-Another filesystem that is used on newer SD cards bigger than 32 GiB is [[wp>exFAT]], which is also available and has better performance and reliability than NTFS on LEDE. It is recommended to simply format these SD cards with FAT32, if the limitations aren't an issue for you.+
  
-==== Setup NTFS ==== +exFAT is commonly used by OEMs for external SSDs and SD cards. The downside to this filesystem is the lack of journaling support, which makes breakage during sudden poweroff more likely. exFAT will provide good performance while maintaining compatibility with Windows and macOS.
-This command will download the tools needed to create and fix NTFS\\  +
-''opkg install ntfsprogs_ntfs-3g''+
  
-If in the list of supported filesystems in your device you don't see **ntfs**you must install also the driver itself\\ +As of Linux kernel 5.4 there is a [[https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.4-Released|new exFAT driver]] this is available with low overhead. This new driver is quite performant and will max out gigabit LAN at 120 MB/s using USB 3.0 external drives on some targetsas tested on the [[:toh:linksys:wrt_ac_series]]. 
-''opkg install ntfs-3g''+
  
-==== Setup exFAT ==== +This will install the driver to use exFAT and the tool to be able to run check disk if needed:\\ 
-This command will download the driver to read exfat filesystems, there are no tools available to format and check exfat in LEDE (as of 2017).\\ +''opkg install kmod-fs-exfat exfat-fsck''
-''opkg install kmod-fs-exfat''+
  
-''opkg install libblkid''+Under Windows, exFAT does not support TRIM; but under Linux/OpenWRT, it does.
  
-===== Apple filesystems ===== +===== Partitions =====
-In Apple land you have [[wp>HFS]], [[wp>HFS+]] and [[wp>APFS]]. Same as with Windows filesystems, there is a driver available for HFS and HFS+ but it has low performance and does not support all features.\\ +
-APFS is too new (as of 2017) and there is no support at all for it in LEDE (nor in Linux) +
- +
-==== Setup HFS and HFS+ ==== +
-This command will download the tools needed to create and fix HFS and HFS+\\ +
-''opkg install hfsfsck'' +
- +
-If in the list of supported filesystems in your device you don't see **hfs** and **hfsplus**, you must install also the drivers\\ +
-''opkg install kmod-fs-hfs kmod-fs-hfsplus''+
  
 +A [[wp>Disk_partitioning|partition]] is a way to split the storage space in more different sections, each using its own independent filesystem.
  
 +This can be useful to separate different types of data, for example to keep your expanded firmware separate from the actual data you want to store and share, or data that must be easily accessible from Windows or macOS directly if you disconnect the external drive.
  
 +Discussing advanced partitioning is beyond the scope of this article, as OpenWrt uses the same commandline tools used by any other Linux system.
  
 +  * **fdisk** tool is used to create/modify partitions on a drive initialized with MBR scheme; since version 2.23 (OpenWRT is on 2.37, as of 2024!), it also supports GPT just fine.
 +  * **gdisk** tool is used to create/modify partitions on a drive initialized with GPT scheme.
  • Last modified: 2024/10/31 23:23
  • by palebloodsky