Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/security-guide/cvm-boundaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This is the main configuration file for the application in JSON format:
| secure_time | 0.5.0 | boolean | Whether secure time is enabled |
| pre_launch_script | 0.4.0 | string | Prelaunch bash script that runs before execute `docker compose up` |
| init_script | 0.5.5 | string | Bash script that executed prior to dockerd startup |
| storage_fs | 0.5.5 | string | Filesystem type for the data disk of the CVM. Supported values: "zfs", "ext4". default to "zfs". **ZFS:** Ensures filesystem integrity with built-in data protection features. **ext4:** Provides better performance for database applications with lower overhead and faster I/O operations, but no strong integrity protection. |
| storage_fs | 0.5.5 | string | Filesystem type for the data disk of the CVM. Supported values: "zfs", "ext4", "xfs". default to "zfs". **ZFS:** Ensures filesystem integrity with built-in data protection features. **ext4:** Provides better performance for database applications with lower overhead and faster I/O operations, but no strong integrity protection. **xfs:** Scales well for large volumes and high-concurrency workloads |
| swap_size | 0.5.5 | string/integer | The linux swap size. default to 0. Can be in byte or human-readable format (e.g., "1G", "256M"). |


Expand Down
74 changes: 72 additions & 2 deletions dstack-util/src/system_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ enum FsType {
#[default]
Zfs,
Ext4,
Xfs,
}

impl Display for FsType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
FsType::Zfs => write!(f, "zfs"),
FsType::Ext4 => write!(f, "ext4"),
FsType::Xfs => write!(f, "xfs"),
}
}
}
Expand All @@ -111,7 +113,8 @@ impl FromStr for FsType {
match s.to_lowercase().as_str() {
"zfs" => Ok(FsType::Zfs),
"ext4" => Ok(FsType::Ext4),
_ => bail!("Invalid filesystem type: {s}, supported types: zfs, ext4"),
"xfs" => Ok(FsType::Xfs),
_ => bail!("Invalid filesystem type: {s}, supported types: zfs, ext4, xfs"),
}
}
}
Expand Down Expand Up @@ -691,7 +694,7 @@ impl<'a> Stage0<'a> {
async fn setup_swap(&self, swap_size: u64, opts: &DstackOptions) -> Result<()> {
match opts.storage_fs {
FsType::Zfs => self.setup_swap_zvol(swap_size).await,
FsType::Ext4 => self.setup_swapfile(swap_size).await,
FsType::Ext4 | FsType::Xfs => self.setup_swapfile(swap_size).await,
}
}

Expand Down Expand Up @@ -814,6 +817,15 @@ impl<'a> Stage0<'a> {
}
.context("Failed to create ext4 filesystem")?;
}
FsType::Xfs => {
info!("Creating xfs filesystem");
cmd! {
mkfs.xfs -f $fs_dev;
}
.context("Failed to create xfs filesystem")?;
Self::mount_xfs(&fs_dev, mount_point, false)
.context("Failed to mount newly created xfs filesystem")?;
}
}
} else {
self.vmm
Expand Down Expand Up @@ -843,6 +855,10 @@ impl<'a> Stage0<'a> {
Self::mount_e2fs(&fs_dev, mount_point)
.context("Failed to mount ext4 filesystem")?;
}
FsType::Xfs => {
Self::mount_xfs(&fs_dev, mount_point, true)
.context("Failed to mount xfs filesystem")?;
}
}
}
Ok(())
Expand Down Expand Up @@ -886,6 +902,60 @@ impl<'a> Stage0<'a> {
Ok(())
}

fn mount_xfs(
dev: &impl AsRef<Path>,
mount_point: &impl AsRef<Path>,
run_check: bool,
) -> Result<()> {
let dev = dev.as_ref();
let mount_point = mount_point.as_ref();
if run_check {
info!("Checking filesystem");

let repair_status = Command::new("xfs_repair")
.arg("-n")
.arg(dev)
.status()
.with_context(|| format!("Failed to run xfs_repair on {}", dev.display()))?;

match repair_status.code() {
Some(0) => {}
Some(1) => {
warn!(
"xfs_repair reported issues on {}, continuing without modification",
dev.display()
);
}
Some(code) => {
bail!(
"xfs_repair exited with status {code} while checking {}",
dev.display()
);
}
None => {
bail!(
"xfs_repair terminated by signal while checking {}",
dev.display()
);
}
}
}

cmd! {
info "Mounting filesystem";
mount $dev $mount_point;
}
.context("Failed to mount xfs filesystem")?;

cmd! {
info "Growing filesystem if needed";
xfs_growfs $mount_point;
}
.context("Failed to grow xfs filesystem")?;

Ok(())
}

fn luks_setup(&self, disk_crypt_key: &str, name: &str) -> Result<()> {
let root_hd = &self.args.device;
let sector_offset = PAYLOAD_OFFSET / 512;
Expand Down
4 changes: 3 additions & 1 deletion vmm/src/console.html
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,16 @@ <h2>Deploy a new instance</h2>
<span class="tooltip">
<strong>ZFS:</strong> Ensures filesystem integrity with built-in data protection features.<br><br>
<strong>ext4:</strong> Provides better performance for database applications
with lower overhead and faster I/O operations.
with lower overhead and faster I/O operations.<br><br>
<strong>XFS:</strong> Optimized for scaling large volumes and parallel I/O.
</span>
</span>
</label>
<select id="storageFs" v-model="vmForm.storage_fs">
<option value="">Default (ZFS)</option>
<option value="zfs">ZFS</option>
<option value="ext4">ext4</option>
<option value="xfs">XFS</option>
</select>
</div>

Expand Down