Skip to content

Commit cf185a2

Browse files
committed
Support auto expand for ext4 fs
1 parent c0279f4 commit cf185a2

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

dstack-util/src/system_setup.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,16 +561,29 @@ impl<'a> Stage0<'a> {
561561
}
562562
}
563563
FsType::Ext4 => {
564-
if cmd!(mountpoint -q $mount_point).is_err() {
565-
cmd!(mount $fs_dev $mount_point)
566-
.context("Failed to mount ext4 filesystem")?;
567-
}
564+
Self::mount_e2fs(&fs_dev, mount_point)
565+
.context("Failed to mount ext4 filesystem")?;
568566
}
569567
}
570568
}
571569
Ok(())
572570
}
573571

572+
fn mount_e2fs(dev: &impl AsRef<Path>, mount_point: &impl AsRef<Path>) -> Result<()> {
573+
let dev = dev.as_ref();
574+
let mount_point = mount_point.as_ref();
575+
cmd! {
576+
info "Checking filesystem";
577+
e2fsck -f -p $dev;
578+
info "Trying to resize filesystem if needed";
579+
resize2fs $dev;
580+
info "Mounting filesystem";
581+
mount $dev $mount_point;
582+
}
583+
.context("Failed to check filesystem")?;
584+
Ok(())
585+
}
586+
574587
fn luks_setup(&self, disk_crypt_key: &str, name: &str) -> Result<()> {
575588
let root_hd = &self.args.device;
576589
let sector_offset = PAYLOAD_OFFSET / 512;

0 commit comments

Comments
 (0)