function check_xen_dirlocation()
 {
     $diro = getFirstFromList($this->main->__t_new_xen_location_a_list);
     $dirlocation = $diro->nname;
     if (!csb($dirlocation, "lvm:")) {
         return;
     }
     $dirlocation = fix_vgname($dirlocation);
     $ret = exec_with_all_closed_output("vgdisplay -c {$dirlocation}");
     if (!csa($ret, ":")) {
         throw new lxException("the_lvm_doesnt_exist", 'nname', $dirlocation);
     }
 }
Esempio n. 2
0
 public function takeSnapshot()
 {
     lxshell_return("modprobe", "dm-snapshot");
     $tmp = "{$this->main->configrootdir}/snapshot_mount";
     lxfile_mkdir($tmp);
     $tmp = expand_real_root($tmp);
     $size = lvm_disksize($this->main->maindisk);
     $size = $size / 3;
     $size = round($size);
     $vgname = $this->main->corerootdir;
     $vgname = fix_vgname($vgname);
     $sfpath = "/dev/{$vgname}/{$this->main->nname}_snapshot";
     $out = exec_with_all_closed_output("lvdisplay -c {$sfpath}");
     if (csa($out, ":")) {
         lxshell_return("umount", $sfpath);
         lvm_remove($sfpath);
     }
     $out = exec_with_all_closed_output("lvdisplay -c {$sfpath}");
     if (csa($out, ":")) {
         throw new lxException("old_snapshot_exists_and_cant_remove");
     }
     $ret = lxshell_return("lvcreate", "-L{$size}M", "-s", "-n", "{$this->main->nname}_snapshot", $this->main->maindisk);
     if ($ret) {
         throw new lxException("could_not_create_snapshot_lack_of_space");
     }
     if (!$this->main->isWindows()) {
         lxshell_return("e2fsck", "-f", "-y", $sfpath);
         lxshell_return("mount", "-o", "ro", $sfpath, $tmp);
     } else {
         $tmp = $sfpath;
     }
     return $tmp;
 }
Esempio n. 3
0
function lvm_disksize($lvmpath)
{
    //$out = exec_with_all_closed_output("lvdisplay -c /dev/$vgname/$lvmname");
    //$out = explode(":", $out);
    //return $out[6] / 1024;
    $out = exec_with_all_closed_output("/usr/sbin/lvs --nosuffix --units b --noheadings -o lv_size {$lvmpath}");
    $out = trim($out);
    return $out / (1024 * 1024);
}