mirror of
https://gitlab.com/ahoneybun/nyxi-installer.git
synced 2025-05-12 11:04:02 -06:00
start work on encrypt feature
This commit is contained in:
parent
0d32bf0d6e
commit
27e5e98669
1 changed files with 39 additions and 1 deletions
40
src/main.rs
40
src/main.rs
|
@ -47,6 +47,42 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn format_drive_encrypt(drive_name: &str) -> rsfdisk::Result<()> {
|
||||
let mut disk = Fdisk::builder()
|
||||
.assign_device(drive_name)
|
||||
.enable_read_write()
|
||||
.wipe_device_metadata()
|
||||
.build()?;
|
||||
|
||||
disk.partition_table_create(PartitionTableKind::GPT)?;
|
||||
|
||||
let partition_type = PartitionKind::builder().guid(Guid::EfiSystem).build()?;
|
||||
|
||||
let boot = Partition::builder()
|
||||
.partition_type(partition_type)
|
||||
.name("EFI")
|
||||
//Assuming 512 bytes per sector, 2_097_152 sectors <=> 1 GiB.
|
||||
.size_in_sectors(2_097_152)
|
||||
.build()?;
|
||||
|
||||
let _ = disk.partition_add(boot)?;
|
||||
|
||||
let partition_type = PartitionKind::builder()
|
||||
.guid(Guid::LinuxRootx86_64)
|
||||
.build()?;
|
||||
|
||||
let root = Partition::builder()
|
||||
.partition_type(partition_type)
|
||||
.name("Root")
|
||||
.build()?;
|
||||
|
||||
let _ = disk.partition_add(root)?;
|
||||
|
||||
disk.partition_table_write_to_disk()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn format_partitions(drive_name: &str) {
|
||||
let efi_path = format!("{}p1", drive_name);
|
||||
let root_path = format!("{}p2", drive_name);
|
||||
|
@ -228,7 +264,9 @@ fn main() {
|
|||
grab_gnome();
|
||||
|
||||
// Partitioning the selected drive
|
||||
let _ = format_drive(drive_name);
|
||||
//let _ = format_drive(drive_name);
|
||||
|
||||
let _ = format_drive_encrypt(drive_name);
|
||||
|
||||
// Formatting the partitions
|
||||
format_partitions(drive_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue