Ejemplo n.º 1
0
/* Deactivate all VGs. */
static int
deactivate (void)
{
  return vgchange ("-an");
}
Ejemplo n.º 2
0
/* Reactivate all VGs. */
static int
reactivate (void)
{
  return vgchange ("-ay");
}
Ejemplo n.º 3
0
 // 
 // P R O T E C T E D
 // 
 bool HDDisk::removeExistingLVMPartitions() {
   
   // use the "bash" wrapper, as calling vgchange directly won't work...
   // reason is unknown...  got the error: "command unknown, try "help""
   // which seems to come from vgchange directly
   Command vgchange("bash");
   vgchange << "-xc" << "vgchange -an";
   
   if( vgchange.waitUntilFinished() != 0 ) {
     LOG_E() << "failed to disable all logical volumes... Abort!";
     LOG_E() << "need to disable them, so we could create a clean partition table...";
     return false;
   }
   
   return true;
   
   /*
   LOG_I() << "searching for existing LVM volumes...";
   
   // FIXME: what if we got an LVM volume in an LVM volume?
   
   // 
   // get list of volumes
   // 
   
   // should output something like: /dev/vdb3:vg_service_data
   Command pvs;
   pvs << "pvs" << "--noheadings" << "--separator" << ":" << "--options" << "pv_name,vg_name";
   if( pvs.waitUntilFinished() != 0 ) {
     LOG_E() << "faild to get list of LVM partitions... Abort!";
     return false;
   }
   
   std::string pvs_output = pvs.getStdoutOutput().str();
   boost::trim(pvs_output);
   
   std::vector<std::string> pvs_lines, lvm_volumes, split_volumens;
   boost::split(pvs_lines, pvs_output, boost::is_any_of("\n"), boost::algorithm::token_compress_on);
   
   // prepare device check
   std::size_t path_length = c_config->index().length();
   
   // check available volumes
   for( auto& line : pvs_lines ) {
     boost::trim(line);
     if( line.substr(0, path_length) == c_config->index() ) {
       boost::split(split_volumens, line, boost::is_any_of(":"));
       if( split_volumens.size() < 2 ) {
         LOG_W() << "pvs line seems to be unuseable: " << line << " won't use it... Abort!";
         return false;
       }
       lvm_volumes.push_back( split_volumens[1] );
       split_volumens.clear();
     }
   }
   
   // remove matching volumes
   for( auto& volume : lvm_volumes ) {
     Command vgremove;
     vgremove << "vgremove" << "-f" << volume;
     if( vgremove.waitUntilFinished() != 0 ) {
       LOG_E() << "volume group could not be removed... Abort!";
       return false;
     }
     LOG_I() << "volume group " << volume << " removed!";
   }
   
   return true;*/
 }