A file system is a method for storing and organizing data on storage devices. Examples of popular file systems in Linux:
ext4
: The default file system in many Linux distributions. Supports large file sizes and journaling.
XFS
: Designed for high performance on large files. Suitable for servers.
Btrfs
: Supports modern features such as snapshots, compression, and data integrity checks.
Tools for partition management:
fdisk
: For storage devices based on MBR.
parted
: For storage devices based on GPT.
Creating a Partition with fdisk:
Display storage devices:
sudo fdisk -l
Run fdisk for the device:
sudo fdisk /dev/sdX
Create a new partition:
n
to create a new partition.w
.Creating a File System:
Use the following command after creating a partition:
ext4
:
sudo mkfs.ext4 /dev/sdX1
XFS
:
sudo mkfs.xfs /dev/sdX1
Btrfs
:
sudo mkfs.btrfs /dev/sdX1
LVM allows flexible storage management by using logical volumes instead of physical partitions.
Main components of LVM:
Physical Volume (PV): Physical devices (disks or partitions).
Volume Group (VG): A collection of PVs.
Logical Volume (LV): Volumes used for the file system.
Create a Physical Volume (PV):
sudo pvcreate /dev/sdX1
Create a Volume Group (VG):
sudo vgcreate my_vg /dev/sdX1
Create a Logical Volume (LV):
sudo lvcreate -L 10G -n my_lv my_vg
Create a File System on the LV:
sudo mkfs.ext4 /dev/my_vg/my_lv
Mount the LV to a Directory:
sudo mount /dev/my_vg/my_lv /mnt
RAID (Redundant Array of Independent Disks) is a technology for combining multiple disks into a single logical unit to improve performance or redundancy.
Common RAID types:
RAID 0: Striping, improves performance without redundancy.
RAID 1: Mirroring, duplicates data for redundancy.
RAID 5: Parity, redundancy with storage efficiency.
RAID 10: Combination of RAID 1 and RAID 0.
Install mdadm
:
sudo zypper install mdadm
Create a RAID array:
Example of RAID 1:
sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdX1 /dev/sdY1
Create a file system on RAID:
sudo mkfs.ext4 /dev/md0
Mount RAID :
sudo mount /dev/md0 /mnt
Save RAID configuration:
sudo mdadm --detail --scan >> /etc/mdadm.conf
Mounting is the process of connecting a file system to a directory.
Manual Mounting Command:
sudo mount /dev/sdX1 /mnt
Viewing Mounted File Systems:
df -h
fstab
is a configuration file for automatic mounting at boot. File location:/etc/fstab
fstab
Format:
< device > < mount_point > < file_system > < options> < dump > < pass >
Example fstab
:
/dev/sdX1 /mnt ext4 defaults 0 2
Apply fstab
changes without rebooting:
sudo mount -a
Disk quota limits storage usage for specific users or groups.
Edit the /etc/fstab
file to add quota options:
/dev/sdX1 /mnt ext4 defaults,usrquota,grpquota 0 2
Remount the file system:
sudo mount -o remount /mnt
Create a quota file:
sudo quotacheck -cug /mnt
sudo quotaon /mnt
Assign Quota to a User:
sudo edquota -u username
Add soft and hard limits in the opened file.
Check Quota Usage:
quota -u username
Disable Quota:
sudo quotaoff /mnt