Filesystems: Difference between revisions

From Alpine Linux
(changed introduction paragraph, updated table format, fixed some case)
Line 1: Line 1:
Alpine Linux supports a number of filesystems.  
Alpine Linux supports all the popular filesystems for various storage media. Different packages/programs are used to format different types of filesystems.


== Filesystem Tools ==
== Filesystem tools ==


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 related to various filesystems available in Alpine Linux along with the '''command''' to format.
<onlyinclude>
<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;"
! Tool  
|width="15%" | Tool  
! Filesystem
|width="15%"| Filesystem
! Brief Notes
|width="55%"| Brief Notes
! Formatting command
|Formatting command  
|-
|-
| {{Pkg|btrfs-progs}}
| {{Pkg|btrfs-progs}}
Line 49: Line 49:
|{{Pkg|ntfs-3g}}  
|{{Pkg|ntfs-3g}}  
|NTFS  
|NTFS  
|Microsoft/Windows FUSE driver
|Full-featured, Microsoft/Windows FUSE driver
|
|mkfs.ntfs
|-
|-
|{{Pkg|xfsprogs}}  
|{{Pkg|xfsprogs}}  
Line 58: Line 58:
|}
|}
</onlyinclude>
</onlyinclude>
 
== Swap partition ==
== Swap Partition ==


Swap space is used for two purposes  
Swap space is used for two purposes  
Line 81: Line 80:


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.  
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.}}
{{Tip|Instead of using a separate partition for swap, [[Zram|zram]] based swap file can be used.}}
== Encrypted swap ==


== Encrypted swap ==
The below steps explains the steps to enable crypt-swap or Encrypted swap parition.
The below steps explains the steps to enable crypt-swap or Encrypted swap parition.


Edit the file {{Path|/etc/conf.d/dmcrypt}} to enable crypt-swap. '''Ensure that source device name is correct.''' :
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|
{{Cat|/etc/conf.d/dmcrypt|
swap{{=}}crypt-swap
swap{{=}}crypt-swap
source{{=}}'/dev/nvme0nXXX'
source{{=}}'/dev/nvme0nXXX'
Line 109: Line 106:
{{Note|The above instructions will reset/re-encrypt swap on every boot and thus no suspend to disk works with it.}}
{{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 ==


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

Revision as of 04:19, 20 February 2025

Alpine Linux supports all the popular filesystems for various storage media. Different packages/programs are used to format different types of filesystems.

Filesystem tools

The following table lists the packages related to various filesystems available in Alpine Linux along with the command to format.

Tool Filesystem Brief Notes Formatting command
btrfs-progs Btrfs mkfs.btrfs
dosfstools FAT12/FAT16/FAT32 used for EFI partition mkfs.vfat
e2fsprogs ext2/ext3/ext4 ext4 is current default in Linux mkfs.ext4
exfatprogs exfat Commonly used on USB flash drives and SD cards mkfs.exfat
f2fs-tools F2FS mkfs.f2fs
hfsprogs XFS HFS/HFS+ Apple/Mac products mkfs.hfsplus
jfsutils JFS mkfs.jfs
ntfs-3g NTFS Full-featured, Microsoft/Windows FUSE driver mkfs.ntfs
xfsprogs XFS mkfs.xfs

Swap partition

Swap space is used for two purposes

  1. Extend the virtual memory beyond the installed physical memory (RAM) to avoid Out of memory condition
  2. Suspend-to-disk or Hibernation support

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

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:

# mkswap /dev/sda2
# swapon /dev/sda2 
# rc-service swap start

The command free -m will show how much swap space is available (in MB).

To make the swap persistent across reboots, enable automatic start of swap:

# echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab
# rc-update add swap 

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 based swap file can be used.

Encrypted swap

The below steps explains the steps to enable crypt-swap or Encrypted swap parition.

Edit the file /etc/conf.d/dmcrypt to enable crypt-swap and ensure that source device name is correct:

Contents of /etc/conf.d/dmcrypt

swap=crypt-swap source='/dev/nvme0nXXX'

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 /etc/fstab

# 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