Filesystems: Difference between revisions

From Alpine Linux
m (added link to Zram page)
(→‎Overview: Add mention of ZFS)
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Alpine Linux supports a number of filesystems.  
This page documents the Alpine Linux supported filesystems needed for various storage media.  


== Filesystem Tools ==
== Overview ==


Alpine has multiple storage media formatting packages available. Different packages/programs are used to format different types of filesystems.
The following table lists the packages and tools related to various filesystems available along with the '''command''' to format.
 
<onlyinclude>
{| cellpadding="5" border="2" class="wikitable"
{| class="wikitable" align="center" style="width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;"
|-style="background:#333333; color:#ffffff; font-size: 1.2em; text-align:center;"
|width="18%" | Tool
|width="18%"| Filesystem
|width="15%"|Formatting command
|Brief Notes
|-
|{{Pkg|btrfs-progs}}||[[Btrfs]]||mkfs.btrfs||Combines copy-on-write and volume management, similar to ZFS.
|-
|-
! Tool
|{{Pkg|dosfstools}} ||FAT12/FAT16/FAT32||mkfs.vfat||Widely-used DOS filesystems. Also used for [[UEFI|EFI]] partitions.
! Filesystem
! Brief Notes
|-
|-
| {{Pkg|btrfs-progs}}
|{{Pkg|e2fsprogs}} ||ext2/ext3/ext4||mkfs.ext4||Journaling filesystems. ext4 is the current default on Linux.
|[[Btrfs]]
|
|-
|-
|{{Pkg|dosfstools}}  
|{{Pkg|exfatprogs}} ||exfat||mkfs.exfat||Commonly used on USB flash drives and SD cards.
|FAT12/FAT16/FAT32
|
|-
|-
|{{Pkg|e2fsprogs}}  
|{{Pkg|f2fs-tools}} ||[[F2FS]]||mkfs.f2fs||
|ext2/ext3/ext4
|ext4 is current default
|-
|-
|{{Pkg|f2fs-tools}}  
|{{Pkg|hfsprogs}} ||HFS/HFS+||mkfs.hfsplus||Used in older Apple/Mac products before APFS.
|[[F2FS]]
|
|-
|-
|{{Pkg|hfsprogs}}  
|{{Pkg|jfsutils}} ||JFS||mkfs.jfs||
|XFS HFS/HFS+
|Apple/Mac products
|-
|-
|{{Pkg|jfsutils}}  
|{{Pkg|ntfs-3g-progs}} ||NTFS ||mkfs.ntfs||Full-featured, Microsoft/Windows FUSE driver.
|JFS
|-
|-
|{{Pkg|ntfs-3g}}  
|{{Pkg|squashfs-tools}} ||[[SquashFS]]||mksquashfs||Compressed read-only file system.
|NTFS
|Microsoft/Windows FUSE driver
|-
|-
|{{Pkg|xfsprogs}}  
|{{Pkg|xfsprogs}} ||XFS||mkfs.xfs||
|XFS
|}</onlyinclude>
|
|}


== Formatting Partitions ==
Additionally, Alpine has [[ZFS|excellent support]] for [https://en.wikipedia.org/wiki/ZFS ZFS], a highly robust copy-on-write filesystem / volume manager.


Whenever a partition is [[Setting_up_disks_manually#Manual_partitioning|created]], the partition must be formatted first before using it.  Depending on the filesystem to be used, the necessary [[Filesystems#Filesystem_Tools|formatting tool]] for the filesystem must be installed first. The various formatting tools like <code> mkfs.ext4</code>, <code>mkfs.vfat</code>, <code>mkfs.btrfs</code> are part of file system tools {{pkg|dosfstools|repo=main}}, {{pkg|e2fsprogs|repo=main}}, {{pkg|btrfs-progs|repo=main}}.  Install the [[Filesystems#Filesystem_Tools|filesystem tools]] first, if not done already.
== Filesystem labels ==  


The following examples show how to use the formatting tools for different filesystems:
Most of the commonly used filesystems store the '''volume label''' or '''filesystem label''' in their metadata/superblock.


{{Warning|The {{Path|/dev/sdXY}} is only an example. Make sure you choose the right partition to format!  If you choose the wrong partition, your will lose your data. Make a backup first and do not proceed, if you are unsure.}}
Labels can be set during filesystem creation or at a later time. The below table lists the commands for both. The commands are non-destructive as long as the filesystem is '''Unmounted''', except for [[btrfs]].


=== e2fsprogs ===
{| class="wikitable" align="center" style="width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;"
ext4 is the default filesystem in Alpine Linux.
|-style="background:#333333; color:#ffffff; font-size: 1.2em; text-align:center;"
{{Cmd|# mkfs.ext4 /dev/sdaXY}}
|width="8%" | Filesystem
 
|width="18%"| Tool
=== btrfs-progs ===
|width="25%"| Filesystem creation
{{Cmd|# mkfs.btrfs /dev/sdaXY}}
|width="35%"| Existing filesystem
 
|Mounted/Unmounted
=== dosfstools ===
|-
{{Cmd|# mkfs.vfat /dev/sdaXY}}
|[[btrfs]]||{{Pkg|btrfs-progs}}||mkfs.btrfs -L "label" /dev/sdXY||btrfs filesystem label /mount/point "newlabel"||Mounted
 
|-
=== f2fs-tools ===
|FAT32||{{Pkg|dosfstools}} ||mkfs.fat -n "LABEL" /dev/sdXY ||fatlabel /dev/sdXY "NEWLABEL"||Unmounted
{{Cmd|# mkfs.f2fs /dev/sdaXY}}
|-
 
|ext4||{{Pkg|e2fsprogs-extra}} ||mkfs.ext4 -L "label" /dev/sdXY||tune2fs -L "newlabel" /dev/sdXY||Unmounted
== swap Partition ==
|-
Instead of using a seperate partition for swap, [[Zram|zram]] can be used as swap.
|NTFS ||{{Pkg|ntfs-3g-progs}} ||mkfs.ntfs -L "label" /dev/sdXY||ntfslabel /dev/sdXY "newlabel"||Unmounted
# <code>mkswap /dev/sda2</code>
|-
# <code>echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab</code>
|XFS||{{Pkg|xfsprogs}} ||mkfs.xfs -L "label" /dev/sdXY||xfs_admin -L "newlabel" /dev/sdXY||Unmounted
# <code>swapon /dev/sda2</code> (or <code>rc-service swap start</code>)
|}
 
{{Cmd|free -m}} will show how much swap space is available (in MB).
 
If you prefer maximum speed, you don't need configure any raid devices for swap. Just add 2 swap partitions on different disks and linux will stripe them automatically. The downside is that the moment one disk fails, the system will go down. For better reliability, put swap on RAID1.


{{Todo|Instructions for cryptswap?}}
== See also ==


For creating partitions refer [[Setting_up_disks_manually#Manual_partitioning|Manual partitioning]]
* [[Setting_up_disks_manually#Manual_partitioning|Manual partitioning]]
* [https://www.nico.schottelius.org/blog/2024-10-10-how-to-enable-encrypted-swap-in-alpine-linux/ How to enable encrypted swap in Alpine Linux]


[[Category:Storage]]
[[Category:Storage]]
[[Category:Installation]]
[[Category:Installation]]
[[Category:Filesystems]]
[[Category:Filesystems]]

Latest revision as of 03:17, 12 April 2026

This page documents the Alpine Linux supported filesystems needed for various storage media.

Overview

The following table lists the packages and tools related to various filesystems available along with the command to format.

Tool Filesystem Formatting command Brief Notes
btrfs-progs Btrfs mkfs.btrfs Combines copy-on-write and volume management, similar to ZFS.
dosfstools FAT12/FAT16/FAT32 mkfs.vfat Widely-used DOS filesystems. Also used for EFI partitions.
e2fsprogs ext2/ext3/ext4 mkfs.ext4 Journaling filesystems. ext4 is the current default on Linux.
exfatprogs exfat mkfs.exfat Commonly used on USB flash drives and SD cards.
f2fs-tools F2FS mkfs.f2fs
hfsprogs HFS/HFS+ mkfs.hfsplus Used in older Apple/Mac products before APFS.
jfsutils JFS mkfs.jfs
ntfs-3g-progs NTFS mkfs.ntfs Full-featured, Microsoft/Windows FUSE driver.
squashfs-tools SquashFS mksquashfs Compressed read-only file system.
xfsprogs XFS mkfs.xfs

Additionally, Alpine has excellent support for ZFS, a highly robust copy-on-write filesystem / volume manager.

Filesystem labels

Most of the commonly used filesystems store the volume label or filesystem label in their metadata/superblock.

Labels can be set during filesystem creation or at a later time. The below table lists the commands for both. The commands are non-destructive as long as the filesystem is Unmounted, except for btrfs.

Filesystem Tool Filesystem creation Existing filesystem Mounted/Unmounted
btrfs btrfs-progs mkfs.btrfs -L "label" /dev/sdXY btrfs filesystem label /mount/point "newlabel" Mounted
FAT32 dosfstools mkfs.fat -n "LABEL" /dev/sdXY fatlabel /dev/sdXY "NEWLABEL" Unmounted
ext4 e2fsprogs-extra mkfs.ext4 -L "label" /dev/sdXY tune2fs -L "newlabel" /dev/sdXY Unmounted
NTFS ntfs-3g-progs mkfs.ntfs -L "label" /dev/sdXY ntfslabel /dev/sdXY "newlabel" Unmounted
XFS xfsprogs mkfs.xfs -L "label" /dev/sdXY xfs_admin -L "newlabel" /dev/sdXY Unmounted

See also