pub fn format_partition_as_ext4<P: AsRef<Path>>(
    shell: &SshShell,
    dry_run: bool,
    partition: &str,
    mount: P,
    owner: &str
) -> Result<(), Error>
Expand description

Formats and mounts the given device as ext4 at the given mountpoint owned by the given user. The given partition and mountpoint are assumed to be valid (we don’t check). We will assume quite a few things for simplicity:

  • the disk IS partitioned, but the partition is not formatted
  • the disk should be mounted at the mountpoint, which is a valid directory
  • you have sudo permissions
  • owner is a valid username

We need to be careful not to mess up the ssh keys, so we will first mount the new FS somewhere, copy over dotfiles, then unmount and mount to users…

In particular, this is useful for mounting a new partition as a home directory.

Warning!

This can cause data loss and seriously mess up your system. BE VERY CAREFUL. Make sure you are formatting the write partition.

Example

format_partition_as_ext4(root_shell, "/dev/sda4", "/home/foouser/")?;