| Crates.io | auto_mount |
| lib.rs | auto_mount |
| version | 0.2.0 |
| created_at | 2022-08-19 06:25:06.893947+00 |
| updated_at | 2025-09-01 06:59:36.938052+00 |
| description | Safe and intelligent Rust library for automatic SATA device mounting with smart GPT conversion, comprehensive error handling, and backup mechanisms. |
| homepage | |
| repository | https://github.com/ski0090/auto_mount |
| max_upload_size | |
| id | 648576 |
| size | 59,058 |
A safe and intelligent Rust library that automatically mounts newly inserted SATA devices with proper error handling and backup mechanisms.
/etc/fstab backup and validationuse auto_mount::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Automatically handles everything with intelligent decisions
smart_auto_mount()?;
// Alternative options:
// simple_auto_mount()?; // No GPT conversion
// gpt_auto_mount()?; // Force GPT for all devices
Ok(())
}
use auto_mount::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let devices = find_connected_satas()?;
let devices = filter_unmounted_hdd_devices(devices)?;
// Optional: Convert to GPT (only for disks > 2TB)
change_devices_to_gpt(&devices)?;
let devices = create_partition(&devices)?;
format_devices(&devices)?;
mount_devices(&devices)?;
Ok(())
}
use auto_mount::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Custom smart mounting
let config = MountConfig {
force_gpt: false,
gpt_threshold_gb: 1000, // Use GPT for disks >= 1TB
skip_gpt: false,
};
smart_auto_mount_with_config(config)?;
// Custom filesystem
format_devices_with_type(&devices, FilesystemType::Xfs)?;
Ok(())
}
// List all supported filesystems
let supported = FilesystemType::supported_type_names();
println!("Supported: {:?}", supported);
// Check if filesystem is supported
if FilesystemType::is_supported("xfs") {
let fs_type: FilesystemType = "xfs".parse()?;
}
/etc/fstabâ ī¸ This tool formats storage devices!
/dev/sd* will be formattedsudo accesslsblk, parted, mkfs.*, blkid, mountAdd to your Cargo.toml:
[dependencies]
auto_mount = "0.2.0"
All functions return proper Result types with detailed error information:
match smart_auto_mount() {
Ok(()) => println!("â
Successfully mounted devices"),
Err(SmartMountError::NoDevicesFound) => println!("âšī¸ No devices to mount"),
Err(e) => eprintln!("â Error: {}", e),
}
We welcome contributions! Please:
This project is licensed under the terms specified in the LICENSE file.
â ī¸ Use at your own risk. Always backup important data before running disk operations.