Filter out local swap files from fstab (fix #17)

This commit is contained in:
Roey Darwish Dror 2018-11-26 09:28:22 +02:00
parent c65004d570
commit 7b81e6b3cf
2 changed files with 17 additions and 8 deletions

View File

@ -81,6 +81,14 @@ struct ChrootCommand {
block_device: PathBuf, 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> { fn create(command: CreateCommand) -> Result<(), Error> {
let sgdisk = Tool::find("sgdisk")?; let sgdisk = Tool::find("sgdisk")?;
let pacstrap = Tool::find("pacstrap")?; let pacstrap = Tool::find("pacstrap")?;
@ -147,12 +155,13 @@ fn create(command: CreateCommand) -> Result<(), Error> {
]).args(&command.extra_packages) ]).args(&command.extra_packages)
.run(ErrorKind::Pacstrap)?; .run(ErrorKind::Pacstrap)?;
let fstab = genfstab let fstab = fix_fstab(
.execute() genfstab
.arg("-U") .execute()
.arg(mount_point.path()) .arg("-U")
.run_text_output(ErrorKind::Fstab)? .arg(mount_point.path())
.replace("relatime", "noatime"); .run_text_output(ErrorKind::Fstab)?,
);
debug!("fstab:\n{}", fstab); debug!("fstab:\n{}", fstab);
fs::write(mount_point.path().join("etc/fstab"), fstab).context(ErrorKind::Fstab)?; fs::write(mount_point.path().join("etc/fstab"), fstab).context(ErrorKind::Fstab)?;
@ -257,7 +266,7 @@ fn main() {
Err(error) => { Err(error) => {
error!("{}", error); error!("{}", error);
if let Some(cause) = error.cause() { if let Some(cause) = error.cause() {
error!(" {}", cause); error!("Caused by: {}", cause);
} }
exit(1); exit(1);
} }

View File

@ -47,7 +47,7 @@ impl<'a> MountStack<'a> {
Some(source), Some(source),
target.as_ref(), target.as_ref(),
Some(filesystem.to_type()), Some(filesystem.to_type()),
MsFlags::empty(), MsFlags::MS_NOATIME,
options, options,
)?; )?;
self.targets.push(target); self.targets.push(target);