Storage and Filesystem Management
MocaccinoOS supports the storage devices and filesystems provided by the Linux kernel and its userspace tools. Storage devices can be managed through graphical applications or command-line utilities.
This page covers common storage administration tasks, including identifying disks, creating filesystems, mounting partitions, configuring persistent mounts and monitoring disk usage.
Warning: Partitioning, formatting and filesystem operations can permanently destroy data. Always verify the target device before running commands that modify a disk. Make sure important data is backed up.
Identify Storage Devices
The lsblk utility displays block devices, their partitions and mount points.
List available devices:
|
|
For additional filesystem information:
|
|
Example output:
|
|
The output shows:
- Device names such as
sdaandnvme0n1. - Partitions such as
sda1andnvme0n1p1. - Filesystem types.
- Filesystem labels and UUIDs.
- Current mount points.
To display partition tables and disk sizes:
|
|
To inspect filesystem identifiers:
|
|
These commands are useful when preparing a disk for mounting or checking which filesystem is present on a partition.
Partition Management
A disk can contain one or more partitions. Each partition can hold a filesystem, swap space or another storage structure.
Common partitioning tools include:
- KDE Partition Manager: Graphical partition management.
- GNOME Disks: Graphical disk and partition management.
- fdisk: Command-line partition management.
- parted: Command-line partition management, including GPT and MBR partition tables.
For example, to inspect a disk using fdisk:
|
|
Replace /dev/sdX with the actual disk device.
Partitioning tools can create, delete and resize partitions. These operations should only be performed after understanding the existing partition layout and backing up important data.
Important: A disk and a partition are not the same thing. For example,
/dev/sdaidentifies an entire disk, while/dev/sda1identifies its first partition. Always verify the target before making changes.
Create a Filesystem
A partition needs a filesystem before it can be used for ordinary file storage.
Common Linux filesystems include:
- ext4: A widely used general-purpose Linux filesystem.
- Btrfs: A filesystem with features such as snapshots and checksums.
- XFS: A high-performance journaling filesystem.
- FAT32: Commonly used for EFI System Partitions and removable media.
- exFAT: Commonly used for removable storage shared between operating systems.
- NTFS: Commonly used by Windows installations and external drives.
To create an ext4 filesystem:
|
|
Replace /dev/sdX1 with the intended partition.
For other filesystem types, use the corresponding creation utility, such
as mkfs.xfs or mkfs.btrfs.
Warning: Creating a filesystem overwrites existing filesystem structures and can make existing data inaccessible. Do not run
mkfson a partition containing data you want to keep.
Mount a Filesystem
Linux makes filesystems accessible by attaching them to directories in the filesystem hierarchy. This is called mounting.
Create a mount point:
|
|
Mount a partition:
|
|
The filesystem is now accessible under /mnt/data.
To inspect mounted filesystems:
|
|
To inspect a particular mount point:
|
|
To unmount the filesystem:
|
|
Make sure applications are no longer using files on the filesystem before unmounting it. Otherwise, the operation may fail with a device-busy error.
Configure Persistent Mounts
A filesystem mounted manually with mount is not automatically mounted
again after a reboot.
To configure a persistent mount, add an entry to:
|
|
First, identify the filesystem UUID:
|
|
Using a UUID is recommended instead of relying on device names such as
/dev/sda1. Device names can change depending on the order in which
storage devices are detected.
An /etc/fstab entry for an ext4 filesystem could look like this:
|
|
The six fields are:
- Device: The device, UUID or label identifying the filesystem.
- Mount point: The directory where the filesystem is mounted.
- Filesystem type: For example,
ext4,xfsorbtrfs. - Options: Mount options such as
defaults,roornoauto. - Dump: Used by the legacy dump backup utility. Usually
0. - Pass: Filesystem check order at boot. Usually
2for additional filesystems and0when filesystem checks should not be performed.
Create the mount point before configuring the entry:
|
|
After editing /etc/fstab, test the configuration:
|
|
If the command completes without errors, inspect the mount:
|
|
On MocaccinoOS, systemd reads /etc/fstab and generates the corresponding
mount units. If you change the file, you can reload the systemd manager
configuration:
|
|
Important: Incorrect
/etc/fstabentries can cause boot delays or prevent the system from starting normally. Always test changes before rebooting.
Removable Storage
USB drives and other removable storage devices are normally detected automatically by the desktop environment.
When a supported filesystem is detected, it can usually be accessed through the file manager.
Before physically disconnecting a storage device, unmount or safely eject it through the desktop environment.
From the command line, identify the device:
|
|
Unmount its mount point:
|
|
The actual mount point depends on the desktop environment and device label.
Use findmnt or lsblk to identify it rather than assuming a fixed path.
Disk Usage
The df utility reports filesystem capacity and available space.
Display usage in a human-readable format:
|
|
Include filesystem types:
|
|
To inspect the space used by a directory:
|
|
To find the largest directories under a location:
|
|
These commands help identify filesystems that are running out of space and directories that contain large amounts of data.
Swap Space
Swap provides additional virtual memory by using disk storage.
To inspect active swap devices and files:
|
|
You can also inspect memory and swap usage with:
|
|
Swap can be configured as a partition or a file. Existing swap configuration
is normally managed through /etc/fstab or systemd swap units.
For example, an existing swap partition can be enabled with:
|
|
To disable it:
|
|
Replace the example device with the actual swap partition.
Note: Hibernation requires additional configuration beyond having swap enabled. Refer to the Power Management documentation for more information.
SSD Maintenance
Solid-state drives support TRIM, which allows the operating system to inform the storage device about blocks that are no longer in use.
On systems using systemd, periodic TRIM can be managed through
fstrim.timer.
Check its status:
|
|
Enable periodic TRIM if it is not already enabled:
|
|
To run TRIM manually on a mounted filesystem:
|
|
Periodic TRIM is generally preferable to enabling continuous discard through filesystem mount options.
Troubleshooting
Filesystem Does Not Mount
Inspect the filesystem and mount configuration:
|
|
For filesystems configured in /etc/fstab, check the entry carefully and
test it:
|
|
Inspect system logs for related errors:
|
|
Filesystem Is Full
Check available space:
|
|
Find directories consuming the most space:
|
|
Check other relevant locations such as /home and /var/log.
Device Is Busy When Unmounting
If a filesystem cannot be unmounted because it is busy, identify processes using the mount point:
|
|
Close applications using the filesystem before trying again.
Filesystem Errors
Filesystem repair tools must only be used when the filesystem is unmounted. Running repair operations on a mounted read-write filesystem can cause additional damage.
For ext4 filesystems, e2fsck can check and repair filesystem errors:
|
|
Replace the example device with the correct partition.
Warning: Filesystem repair can modify or remove damaged filesystem structures. Back up recoverable data before attempting repairs.
Further Reading
- Gentoo Wiki: Filesystems
- Gentoo Wiki: /etc/fstab
- Gentoo Wiki: SSD
- systemd.mount
- systemd.swap
man lsblkman mountman fstabman findmntman swapon