Filesystems: Difference between revisions

From Alpine Linux
(changed introduction paragraph, updated table format, fixed some case)
(→‎Overview: Add mention of ZFS)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Alpine Linux supports all the popular filesystems for various storage media. Different packages/programs are used to format different types of filesystems.
This page documents the Alpine Linux supported filesystems needed for various storage media.  


== Filesystem tools ==
== Overview ==


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


Swap space is used for two purposes
Additionally, Alpine has [[ZFS|excellent support]] for [https://en.wikipedia.org/wiki/ZFS ZFS], a highly robust copy-on-write filesystem / volume manager.
# Extend the virtual memory beyond the installed physical memory (RAM) to avoid [https://en.wikipedia.org/wiki/Out_of_memory Out of memory] condition 
# Suspend-to-disk or Hibernation support


Below Instructions explain how to use a seperate partition for swap:
== Filesystem labels ==


The following commands prepares the unmounted partition (/dev/sda2) for swap space, activates the prepared swap space and starts the swap service to manage swap space immediately:
Most of the commonly used filesystems store the '''volume label''' or '''filesystem label''' in their metadata/superblock.


# mkswap /dev/sda2
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]].
# swapon /dev/sda2
# rc-service swap start


The command {{Codeline|free -m}} will show how much swap space is available (in MB).
{| 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;"
To make the swap persistent across reboots, enable automatic start of swap:
|width="8%" | Filesystem
 
|width="18%"| Tool
# echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab
|width="25%"| Filesystem creation
# rc-update add swap
|width="35%"| Existing filesystem
 
|Mounted/Unmounted
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.  
|-
{{Tip|Instead of using a separate partition for swap, [[Zram|zram]] based swap file can be used.}}
|[[btrfs]]||{{Pkg|btrfs-progs}}||mkfs.btrfs -L "label" /dev/sdXY||btrfs filesystem label /mount/point "newlabel"||Mounted
== Encrypted swap ==
|-
 
|FAT32||{{Pkg|dosfstools}} ||mkfs.fat -n "LABEL" /dev/sdXY ||fatlabel /dev/sdXY "NEWLABEL"||Unmounted
The below steps explains the steps to enable crypt-swap or Encrypted swap parition.
|-
 
|ext4||{{Pkg|e2fsprogs-extra}} ||mkfs.ext4 -L "label" /dev/sdXY||tune2fs -L "newlabel" /dev/sdXY||Unmounted
Edit the file {{Path|/etc/conf.d/dmcrypt}} to enable crypt-swap and ensure that source device name is correct: {{Cat|/etc/conf.d/dmcrypt|
|-
swap{{=}}crypt-swap
|NTFS ||{{Pkg|ntfs-3g-progs}} ||mkfs.ntfs -L "label" /dev/sdXY||ntfslabel /dev/sdXY "newlabel"||Unmounted
source{{=}}'/dev/nvme0nXXX'
|-
}}
|XFS||{{Pkg|xfsprogs}} ||mkfs.xfs -L "label" /dev/sdXY||xfs_admin -L "newlabel" /dev/sdXY||Unmounted
 
|}
To use dmcrypt, start dmcrypt service and enable swap immediately:
# /etc/init.d/dmcrypt start
# swapon /dev/mapper/crypt-swap
 
To make the encrypted swap persistent across reboots, enable automatic start of encryption & swap:
 
# rc-update add dmcrypt
# rc-update add swap
 
To enable automatic swapon, add the relevant entry to {{Path|/etc/fstab}}
 
{{Cmd|# echo /dev/mapper/crypt-swap swap swap defaults 0 0 >> /etc/fstab}}
 
{{Note|The above instructions will reset/re-encrypt swap on every boot and thus no suspend to disk works with it.}}


== See also ==
== See also ==


* [[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]
* [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]



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