Skip to content

Commit

Permalink
wip: Attempt to fix mount ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Feb 12, 2025
1 parent 2547682 commit d1866ec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
26 changes: 18 additions & 8 deletions src/backend/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ impl InstallationState {
sender: &relm4::Sender<InstallationMessage>,
) -> Result<()> {
if cfg!(debug_assertions) {
let installation_state_dump_path = std::env::temp_dir().join("readymade-installation-state.json");
tracing::debug!("Dumping installation state to {}", installation_state_dump_path.display());
let installation_state_dump_path =
std::env::temp_dir().join("readymade-installation-state.json");
tracing::debug!(
"Dumping installation state to {}",
installation_state_dump_path.display()
);
std::fs::write(installation_state_dump_path, serde_json::to_string(self)?)?;
}

let mut command = Command::new("pkexec");
command.arg(std::env::current_exe()?);
command.arg("--non-interactive");
Expand Down Expand Up @@ -263,6 +267,8 @@ impl InstallationState {
lang: self.langlocale.clone().unwrap_or_else(|| "C.UTF-8".into()),
};

// /etc should exist, so the mount order is somehow fucked up
std::fs::create_dir_all("/etc/").wrap_err("cannot create /etc")?;
std::fs::write("/etc/fstab", fstab).wrap_err("cannot write to /etc/fstab")?;

for module in &self.postinstall {
Expand Down Expand Up @@ -370,7 +376,8 @@ impl InstallationState {
let root_file = cfgdir.join("50-root.conf");
let f = std::fs::read_to_string(&root_file)?;
let f = Self::set_encrypt_to_file(&f, self.tpm);
std::fs::write(root_file, f)?;
std::fs::write("/tmp/50-root.conf", f)?;
// TODO: somehow actually use this config file
Ok(())
}

Expand Down Expand Up @@ -401,14 +408,14 @@ impl InstallationState {
"--json",
"pretty",
];

if use_keyfile {
let keyfile_path = consts::LUKS_KEYFILE_PATH;
tracing::debug!("Using keyfile for systemd-repart: {keyfile_path}");
args.push("--key-file");
args.push(keyfile_path);
}

args.extend(&[blockdev.to_str().unwrap()]);

tracing::debug!(?dry_run, ?args, "Running systemd-repart");
Expand All @@ -428,11 +435,14 @@ impl InstallationState {
}

let out = std::str::from_utf8(&repart_cmd.stdout)?;

// Dump systemd-repart output to a file if in debug mode
if cfg!(debug_assertions) {
let repart_out_path = std::env::temp_dir().join("readymade-repart-output.json");
tracing::debug!("Dumping systemd-repart output to {}", repart_out_path.display());
tracing::debug!(
"Dumping systemd-repart output to {}",
repart_out_path.display()
);
std::fs::write(repart_out_path, out)?;
}

Expand Down
5 changes: 5 additions & 0 deletions src/backend/repart_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ impl RepartOutput {
// todo: is there a way for cryptsetup to output the /dev/mapper path so we don't have to guess?
.output()?;

if !cmd.status.success() {
color_eyre::eyre::bail!("cryptsetup failed: {}", String::from_utf8_lossy(&cmd.stderr));
}

// TODO: mount? (/dev/mapper?)
//
let mapper = PathBuf::from(format!("/dev/mapper/{label}"));

for (mntpoint, mntpoint_opts) in mntpoints {
tracing::debug!("Mounting encrypted partition: {}", mntpoint);
let mnt_target = MountTarget {
target: PathBuf::from(mntpoint),
flags: MountFlags::empty(),
Expand Down
13 changes: 7 additions & 6 deletions templates/wholedisk/50-root.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[Partition]
Subvolumes=/ /home
CopyFiles=/:/
CompressionLevel=1
MountPoint=/:subvol=/,compress=zstd:1
MountPoint=/home:subvol=/home,compress=zstd:1
DefaultSubvolume=/
Type=root
Compression=zstd
ExcludeFiles=/boot/
Format=btrfs
CopyFiles=/:/
Subvolumes=/ /home
CompressionLevel=1
ExcludeFiles=/boot/
Compression=zstd
Encrypt=key-file
Type=root

0 comments on commit d1866ec

Please sign in to comment.