import java.io.*; import java.util.Map; import com.redhat.et.libguestfs.*; public class Test { public static void main (String[] argv) { try { // Delete any previous test file if one was left around. File old = new File ("test.img"); old.delete (); RandomAccessFile f = new RandomAccessFile ("test.img", "rw"); f.setLength (500 * 1024 * 1024); f.close (); GuestFS g = new GuestFS (); g.add_drive ("test.img"); g.launch (); g.pvcreate ("/dev/sda"); g.vgcreate ("VG", new String[] {"/dev/sda"}); g.lvcreate ("LV1", "VG", 200); g.lvcreate ("LV2", "VG", 200); g.mkfs ("ext2", "/dev/VG/LV1"); g.close (); } catch (Exception exn) { System.err.println (exn); System.exit (1); } } }