# alinux-storage

Part of **ALINUX**

# Alibaba Cloud Linux Storage and Filesystem Console Guide

## Operations Overview

| Operation | Console Entry | Prerequisites | Description |
|----------|---------------|---------------|-------------|
| Create EROFS Image | Documentation Portal > Products > Operating Systems > Alibaba Cloud Linux > File System > EROFS Usage Guide | erofs-utils package installed, root or sudo access | Create and mount high-performance read-only filesystem images using EROFS |
| Monitor Storage I/O D2C Time | Documentation Portal > Products > Operating Systems > Alibaba Cloud Linux > Kernel Features | Alibaba Cloud Linux 3, sudo access | View cumulative device-to-controller I/O latency from /proc/diskstats |
| Tune Filesystem Dirty Page Settings | Documentation Portal > Products > Operating Systems > Alibaba Cloud Linux > System Tuning Guide | Root access, knowledge of device major:minor numbers, Alibaba Cloud Linux 2/3 | Adjust per-filesystem dirty page watermarks and writeback bandwidth limits |
| Cross Project Quota Hard Link Creation | Documentation Portal > Products > Operating Systems > Alibaba Cloud Linux > Kernel Features | Alibaba Cloud Linux 2/3, root access | Enable hard link creation across directories with different project quotas |

## Operation Steps

### Create EROFS Image

**Navigation**: Console > Products > Operating Systems > Alibaba Cloud Linux > File System > EROFS Usage Guide

**Prerequisites**:
- erofs-utils package installed
- Root or sudo access to the system

1. Verify erofs-utils installation by running a version check command  
   - Element: **mkfs.erofs -V** (text_input) — terminal command line  
   - Notes: If not installed, run `sudo yum install -y erofs-utils`

2. Generate an EROFS filesystem image from a source directory  
   - Element: **mkfs.erofs foo.erofs foo** (text_input) — terminal command line  
   - Notes: Supports options like `-C` for cluster size and `-zX` for compression algorithm (e.g., `-zlz4`)

3. Create a mount point and mount the EROFS image using loop device  
   - Element: **sudo mount -t erofs -o loop foo.erofs /mnt/erofs** (text_input) — terminal command line  
   - Notes: The `-o loop` option maps the file as a block device; ensure `/mnt/erofs` exists

4. Unmount the EROFS filesystem when done  
   - Element: **sudo umount /mnt/erofs** (text_input) — terminal command line  
   - Notes: Ensure no processes are accessing the mount point before unmounting

### Monitor Storage I/O D2C Time

**Navigation**: Console > Products > Operating Systems > Alibaba Cloud Linux > Kernel Features > View storage device IO D2C time in /proc/diskstats

**Prerequisites**:
- Alibaba Cloud Linux 3 operating system
- Sudo or root access

1. Read the /proc/diskstats file to view I/O metrics  
   - Element: **cat /proc/diskstats** (text_input) — terminal command line  
   - Notes: The last three columns show cumulative D2C time (in milliseconds) for reads, writes, and discards

2. Identify your target storage device (e.g., vda, nvme0n1) in the output  
   - Element: **device name column** (text_input) — terminal output  
   - Notes: D2C time reflects total time from dispatch to completion at the device controller

3. Monitor changes over time by repeating the command or using watch  
   - Element: **watch -n 1 'cat /proc/diskstats'** (text_input) — terminal command line  
   - Notes: Increasing D2C time may indicate storage performance degradation or contention

### Tune Filesystem Dirty Page Settings

**Navigation**: Console > Products > Operating Systems > Alibaba Cloud Linux > System Tuning Guide > Tune Filesystem Dirty Page Settings

**Prerequisites**:
- Root access to execute system configuration commands
- Knowledge of the target block device’s major:minor number (obtain via `lsblk -O`)
- Alibaba Cloud Linux 2 or 3 with compatible kernel version

1. Query current min_ratio value for a specific device  
   - Element: **cat /sys/class/bdi/259:0/min_ratio** (text_input) — terminal command line  
   - Notes: Replace `259:0` with actual major:minor number of your device

2. Set minimum writeback bandwidth quota percentage  
   - Element: **sudo sh -c 'echo 20 > /sys/class/bdi/259:0/min_ratio'** (text_input) — terminal command line  
   - Notes: Value is a percentage (0–100); ensures baseline writeback bandwidth

3. Set maximum writeback bandwidth quota percentage  
   - Element: **sudo sh -c 'echo 60 > /sys/class/bdi/259:0/max_ratio'** (text_input) — terminal command line  
   - Notes: Prevents a single filesystem from consuming all dirty page writeback capacity

4. Enable strict per-filesystem dirty page limits (Alibaba Cloud Linux 3 only)  
   - Element: **sudo sh -c 'echo 1 > /sys/class/bdi/259:0/strict_limit'** (text_input) — terminal command line  
   - Notes: Requires kernel version 5.10.134-17 or later; isolates dirty page accounting per filesystem

5. Disable strict limits to revert to global control  
   - Element: **sudo sh -c 'echo 0 > /sys/class/bdi/259:0/strict_limit'** (text_input) — terminal command line  
   - Notes: Useful for temporary troubleshooting or compatibility

### Cross Project Quota Hard Link Creation

**Navigation**: Console > Products > Operating Systems > Alibaba Cloud Linux > Kernel Features > Cross Directory Quota Hard Link Creation

**Prerequisites**:
- Alibaba Cloud Linux 2 or 3 operating system
- Root access to modify kernel parameters

1. Check current hardlink_cross_projid setting  
   - Element: **cat /proc/sys/fs/hardlink_cross_projid** (text_input) — terminal command line  
   - Notes: Default value is `0`, which blocks cross-project hard links

2. Enable cross-project hard link creation  
   - Element: **echo 1 > /proc/sys/fs/hardlink_cross_projid** (text_input) — terminal command line  
   - Notes: Requires root privileges; applies globally to all ext4 filesystems with project quotas

3. Verify the change took effect  
   - Element: **cat /proc/sys/fs/hardlink_cross_projid** (text_input) — terminal command line  
   - Notes: Output should be `1`; setting persists until reboot unless saved via sysctl

## FAQ

Q: Do these operations require a graphical console or web UI?
A: No. All operations are performed via terminal commands on an Alibaba Cloud Linux instance. The "console" refers to accessing documentation through the Alibaba Cloud management portal, but actual execution happens in the OS shell.

Q: Can I create EROFS images without installing additional packages?
A: No. You must install the `erofs-utils` package first using `yum install erofs-utils`. This provides the `mkfs.erofs` tool required to build EROFS images.

Q: Is the D2C time in /proc/diskstats available on all Alibaba Cloud Linux versions?
A: No. This feature is only available in Alibaba Cloud Linux 3. Earlier versions do not expose D2C time in /proc/diskstats and require tools like blktrace for similar metrics.

Q: Will changing dirty page settings affect all filesystems or just one?
A: By default, dirty page settings are global. However, when `strict_limit=1` is enabled (on supported kernels), settings under `/sys/class/bdi/<major:minor>/` apply only to that specific block device/filesystem.

Q: Are hard links across project quotas allowed by default in ext4?
A: No. By default, ext4 enforces project quota isolation and blocks hard links between directories with different project IDs. You must explicitly enable this via the `hardlink_cross_projid` kernel parameter.

## Pricing & Billing

### Billing Model
All described storage and filesystem operations are provided as part of the Alibaba Cloud Linux operating system and are **free of charge**. These are kernel-level features and do not incur separate usage fees.

### Free Tier
There is no explicit free tier because these capabilities are included at no additional cost with any Alibaba Cloud Linux instance.

### Billing Notes
EROFS, D2C time monitoring, dirty page tuning, and cross-quota hard links are system-level functionalities. Their use does not generate billable events or metered usage. Costs are limited to the underlying compute and storage resources of your ECS instance.