mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
feat: add progress step for btrfs conversion during setup/init
This commit is contained in:
@@ -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."
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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<P: AsRef<Path>>(
|
||||
datadir: P,
|
||||
repair: RepairStrategy,
|
||||
password: Option<&str>,
|
||||
progress: Option<&FullProgressTracker>,
|
||||
) -> Result<RequiresReboot, Error> {
|
||||
let scan = pvscan().await?;
|
||||
if scan
|
||||
@@ -264,7 +266,7 @@ pub async fn import<P: AsRef<Path>>(
|
||||
.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<P: AsRef<Path>>(
|
||||
name: &str,
|
||||
repair: RepairStrategy,
|
||||
password: Option<&str>,
|
||||
progress: Option<&FullProgressTracker>,
|
||||
) -> Result<RequiresReboot, Error> {
|
||||
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<P: AsRef<Path>>(
|
||||
// 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<P: AsRef<Path>>(
|
||||
.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<P: AsRef<Path>>(
|
||||
datadir: P,
|
||||
repair: RepairStrategy,
|
||||
password: Option<&str>,
|
||||
progress: Option<&FullProgressTracker>,
|
||||
) -> Result<RequiresReboot, Error> {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user