From 8b65490d0e1255f486cad4dde1b1e57e7a00bcd6 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Fri, 20 Mar 2026 19:31:57 -0600 Subject: [PATCH] feat: add progress step for btrfs conversion during setup/init --- core/locales/i18n.yaml | 7 +++++++ core/src/bins/start_init.rs | 1 + core/src/disk/main.rs | 18 +++++++++++++++--- core/src/setup.rs | 12 ++++++++++-- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/core/locales/i18n.yaml b/core/locales/i18n.yaml index cce91b5e5..f1ba7dbe4 100644 --- a/core/locales/i18n.yaml +++ b/core/locales/i18n.yaml @@ -872,6 +872,13 @@ disk.main.disk-not-found: fr_FR: "Disque StartOS non trouvé." pl_PL: "Nie znaleziono dysku StartOS." +disk.main.converting-to-btrfs: + en_US: "Performing file system conversion to btrfs. This can take many hours, please be patient and DO NOT unplug the server." + de_DE: "Dateisystemkonvertierung zu btrfs wird durchgeführt. Dies kann viele Stunden dauern, bitte haben Sie Geduld und trennen Sie den Server NICHT vom Strom." + es_ES: "Realizando conversión del sistema de archivos a btrfs. Esto puede tardar muchas horas, tenga paciencia y NO desconecte el servidor." + fr_FR: "Conversion du système de fichiers vers btrfs en cours. Cela peut prendre de nombreuses heures, soyez patient et NE débranchez PAS le serveur." + pl_PL: "Wykonywanie konwersji systemu plików na btrfs. To może potrwać wiele godzin, prosimy o cierpliwość i NIE odłączaj serwera od zasilania." + disk.main.incorrect-disk: en_US: "A StartOS disk was found, but it is not the correct disk for this device." de_DE: "Eine StartOS-Festplatte wurde gefunden, aber es ist nicht die richtige Festplatte für dieses Gerät." diff --git a/core/src/bins/start_init.rs b/core/src/bins/start_init.rs index 5c53a6e0c..b47bfb075 100644 --- a/core/src/bins/start_init.rs +++ b/core/src/bins/start_init.rs @@ -159,6 +159,7 @@ async fn setup_or_init( } else { Some(DEFAULT_PASSWORD) }, + Some(&handle), ) .await?; if tokio::fs::metadata(REPAIR_DISK_PATH).await.is_ok() { diff --git a/core/src/disk/main.rs b/core/src/disk/main.rs index da0007caf..80ba3fa64 100644 --- a/core/src/disk/main.rs +++ b/core/src/disk/main.rs @@ -12,6 +12,7 @@ use super::util::pvscan; use crate::disk::mount::filesystem::block_dev::BlockDev; use crate::disk::mount::filesystem::{FileSystem, ReadWrite}; use crate::disk::mount::util::unmount; +use crate::progress::FullProgressTracker; use crate::util::Invoke; use crate::{Error, ErrorKind, ResultExt}; @@ -216,6 +217,7 @@ pub async fn import>( datadir: P, repair: RepairStrategy, password: Option<&str>, + progress: Option<&FullProgressTracker>, ) -> Result { let scan = pvscan().await?; if scan @@ -264,7 +266,7 @@ pub async fn import>( .arg(guid) .invoke(crate::ErrorKind::DiskManagement) .await?; - mount_all_fs(guid, datadir, repair, password).await + mount_all_fs(guid, datadir, repair, password, progress).await } #[instrument(skip_all)] @@ -274,6 +276,7 @@ pub async fn mount_fs>( name: &str, repair: RepairStrategy, password: Option<&str>, + progress: Option<&FullProgressTracker>, ) -> Result { let orig_path = Path::new("/dev").join(guid).join(name); let mut blockdev_path = orig_path.clone(); @@ -305,6 +308,11 @@ pub async fn mount_fs>( // Convert ext4 → btrfs on the package-data partition if needed let fs_type = detect_filesystem(&blockdev_path).await?; if fs_type == "ext2" { + let mut convert_phase = + progress.map(|p| p.add_phase(t!("disk.main.converting-to-btrfs").into(), Some(50))); + if let Some(ref mut phase) = convert_phase { + phase.start(); + } tracing::info!("Running e2fsck before converting {name} from ext4 to btrfs"); Command::new("e2fsck") .arg("-fy") @@ -330,6 +338,9 @@ pub async fn mount_fs>( .await?; unmount(&tmp_mount, false).await?; tokio::fs::remove_dir(&tmp_mount).await?; + if let Some(ref mut phase) = convert_phase { + phase.complete(); + } } let reboot = repair.fsck(&blockdev_path).await?; @@ -367,10 +378,11 @@ pub async fn mount_all_fs>( datadir: P, repair: RepairStrategy, password: Option<&str>, + progress: Option<&FullProgressTracker>, ) -> Result { let mut reboot = RequiresReboot(false); - reboot |= mount_fs(guid, &datadir, "main", repair, password).await?; - reboot |= mount_fs(guid, &datadir, "package-data", repair, password).await?; + reboot |= mount_fs(guid, &datadir, "main", repair, password, progress).await?; + reboot |= mount_fs(guid, &datadir, "package-data", repair, password, progress).await?; Ok(reboot) } diff --git a/core/src/setup.rs b/core/src/setup.rs index e6aa68212..042e91c71 100644 --- a/core/src/setup.rs +++ b/core/src/setup.rs @@ -219,6 +219,7 @@ pub async fn attach( } else { Some(DEFAULT_PASSWORD) }, + Some(&*progress), ) .await?; let _ = setup_ctx.disk_guid.set(disk_guid.clone()); @@ -396,8 +397,14 @@ pub async fn setup_data_drive( encryption_password, ) .await?; - let _ = crate::disk::main::import(&*guid, DATA_DIR, RepairStrategy::Preen, encryption_password) - .await?; + let _ = crate::disk::main::import( + &*guid, + DATA_DIR, + RepairStrategy::Preen, + encryption_password, + None, + ) + .await?; let _ = ctx.disk_guid.set(guid.clone()); Ok(guid) } @@ -726,6 +733,7 @@ async fn migrate( } else { Some(DEFAULT_PASSWORD) }, + Some(&ctx.progress), ) .await?;