Libstorage is a C++ library for managing Linux storage devices. So far it was developed as part of YaST but since a few weeks it is an independent project.
Here is a code example creating a 1GB partition on /dev/sdb.
Environment env(false); StorageInterface* s = createStorageInterface(env); string name; // Create 1GB partition on /dev/sdb and format it with Ext4. s->createPartitionAny("/dev/sdb", 1048576, name); s->changeFormatVolume(name, true, EXT4); // Set mount-point to "/home" and fstab option to "relatime". s->changeMountPoint(name, "/home"); s->changeFstabOptions(name, "relatime"); // Set filesystem label to "HOME" and mount filesystem by label. s->changeLabelVolume(name, "HOME"); s->changeMountBy(name, MOUNTBY_LABEL); // Commit the change to the system. This will create the partition, // format and mount it and update /etc/fstab. s->commit(); destroyStorageInterface(s);
Besides of hard-disks libstorage handles RAID, LVM, NFS, various filesystems and encryption. Swig generated Python bindings are also provided. Libstorage has no dependencies on YaST, neither for building nor runtime. We hope libstorage will also be useful for other projects.
Comments are as always welcome.
Both comments and pings are currently closed.