mirror of
https://github.com/philmmanjaro/alma.git
synced 2025-07-26 06:59:28 +02:00
Filter out local swap files from fstab (fix #17)
This commit is contained in:
parent
c65004d570
commit
7b81e6b3cf
23
src/main.rs
23
src/main.rs
@ -81,6 +81,14 @@ struct ChrootCommand {
|
||||
block_device: PathBuf,
|
||||
}
|
||||
|
||||
fn fix_fstab(fstab: String) -> String {
|
||||
fstab
|
||||
.lines()
|
||||
.filter(|line| !line.contains("swap") && !line.starts_with('#'))
|
||||
.collect::<Vec<&str>>()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
fn create(command: CreateCommand) -> Result<(), Error> {
|
||||
let sgdisk = Tool::find("sgdisk")?;
|
||||
let pacstrap = Tool::find("pacstrap")?;
|
||||
@ -147,12 +155,13 @@ fn create(command: CreateCommand) -> Result<(), Error> {
|
||||
]).args(&command.extra_packages)
|
||||
.run(ErrorKind::Pacstrap)?;
|
||||
|
||||
let fstab = genfstab
|
||||
.execute()
|
||||
.arg("-U")
|
||||
.arg(mount_point.path())
|
||||
.run_text_output(ErrorKind::Fstab)?
|
||||
.replace("relatime", "noatime");
|
||||
let fstab = fix_fstab(
|
||||
genfstab
|
||||
.execute()
|
||||
.arg("-U")
|
||||
.arg(mount_point.path())
|
||||
.run_text_output(ErrorKind::Fstab)?,
|
||||
);
|
||||
debug!("fstab:\n{}", fstab);
|
||||
fs::write(mount_point.path().join("etc/fstab"), fstab).context(ErrorKind::Fstab)?;
|
||||
|
||||
@ -257,7 +266,7 @@ fn main() {
|
||||
Err(error) => {
|
||||
error!("{}", error);
|
||||
if let Some(cause) = error.cause() {
|
||||
error!(" {}", cause);
|
||||
error!("Caused by: {}", cause);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ impl<'a> MountStack<'a> {
|
||||
Some(source),
|
||||
target.as_ref(),
|
||||
Some(filesystem.to_type()),
|
||||
MsFlags::empty(),
|
||||
MsFlags::MS_NOATIME,
|
||||
options,
|
||||
)?;
|
||||
self.targets.push(target);
|
||||
|
Loading…
x
Reference in New Issue
Block a user