Skip to content

Commit

Permalink
Merge pull request #11 from marcosps/enable-lvm-usage
Browse files Browse the repository at this point in the history
main.rs: Enable lvm usage
  • Loading branch information
arighi authored Oct 18, 2024
2 parents 6e2b515 + 7cf0345 commit cd797e0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ fn generate_sudoers() -> io::Result<()> {
Ok(())
}

// The /etc/lvm is usually only read/write by root. In order to allow commands like pvcreate to be
// run on rootless users just create a dummy directory and bind mount it in the same place.
fn generate_lvm() -> io::Result<()> {
utils::do_mkdir("/run/tmp/lvm");
utils::do_mount("/run/tmp/lvm", "/etc/lvm/", "", libc::MS_BIND as usize, "");
Ok(())
}

fn generate_hosts() -> io::Result<()> {
if let Ok(hostname) = env::var("virtme_hostname") {
std::fs::copy("/etc/hosts", "/run/tmp/hosts")?;
Expand All @@ -366,6 +374,7 @@ fn override_system_files() {
generate_shadow().ok();
generate_sudoers().ok();
generate_hosts().ok();
generate_lvm().ok();
}

fn set_cwd() {
Expand Down

0 comments on commit cd797e0

Please sign in to comment.