add partition function

This commit is contained in:
Aaron Honeycutt 2025-04-10 18:09:18 -06:00
parent df7ab3e3ad
commit 329b99443d

View file

@ -34,9 +34,10 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
let root = Partition::builder()
.partition_type(partition_type)
.name("Root")
.size_in_sectors(121_634_816)
// 500GB
//.size_in_sectors(499_033_071_61)
// Flash drive testing
// .size_in_sectors(121_634_816)
// Internal drive testing
.size_in_sectors(499_033_071_61)
.build()?;
let _ = disk.partition_add(root)?;
@ -46,6 +47,21 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
Ok(())
}
fn format_partitions() {
let _efi_partition = Command::new("mkfs.fat")
.arg("-F32")
.arg("-n")
.arg("EFI")
.arg("/dev/nvme1n1p1")
.output()
.expect("Failed to partition boot partition as FAT32");
let _root_partition = Command::new("mkfs.ext4")
.arg("/dev/nvme1n1p2")
.output()
.expect("Failed to partition root partition as ext4");
}
// fn mount_parts() {}
fn grab_flake() {
@ -120,6 +136,8 @@ fn main() {
println!("");
println!("Use the full drive path such as /dev/nvme0n1 or /dev/sda");
println!("Which drive do we want to use for this installation?: {}", drive_name);
println!("");
println!("If you're on the Lemur nvme1n1 is the test drive");
io::stdin()
.read_line(&mut drive_name)
@ -131,18 +149,7 @@ fn main() {
let _ = format_drive(drive_name);
// Formatting the partitions
let _efi_partition = Command::new("mkfs.fat")
.arg("-F32")
.arg("-n")
.arg("EFI")
.arg("/dev/sda1")
.output()
.expect("Failed to partition boot partition as FAT32");
let _root_partition = Command::new("mkfs.ext4")
.arg("/dev/sda2")
.output()
.expect("Failed to partition root partition as ext4");
format_partitions();
// Download nix files
grab_flake();
@ -201,4 +208,4 @@ fn main() {
_ => println!("Invalid choice, try again."),
}
}
}
}