[gparted] Add creation of LVM2 PVs (#670171)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Add creation of LVM2 PVs (#670171)
- Date: Sat, 1 Sep 2012 17:03:38 +0000 (UTC)
commit c3ab62591b73266f43b379d9a7aef3be13f3c384
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Thu Jan 12 13:15:26 2012 +0000
Add creation of LVM2 PVs (#670171)
Add creation of Physical Volumes specifying LVM2 metatdata format:
lvm pvcreate -M 2 /dev/DEVICE
Also set the partition type to identify its contents as LVM. Note that
libparted treats every partition type as a file system except LVM which
it treats as a flag, hence GParted displaying "lvm" in the Manage Flags
dialog. Never the less libparted set the partition types correctly.
For MBR partitioning the type is 8e "Linux LVM" and for GPT partitioning
the type is E6D6D379-F507-44C2-A23C-238F2A3DF928. Setting the partition
type as LVM is not strictly required as LVM2 scans the contents of all
partitions looking for PVs, but it is best practice.
Bug #670171 - Add LVM PV read-write support
src/Dialog_Partition_New.cc | 3 +--
src/GParted_Core.cc | 31 ++++++++++++++++++++++++++-----
src/Win_GParted.cc | 3 +--
src/lvm2_pv.cc | 5 +++--
4 files changed, 31 insertions(+), 11 deletions(-)
---
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 6e75715..4121154 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -49,8 +49,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
std::vector< FS >::iterator f ;
for ( f = this->FILESYSTEMS .begin(); f != this->FILESYSTEMS .end(); f++ )
{
- if ( f ->filesystem == GParted::FS_UNKNOWN
- || f ->filesystem == GParted::FS_LVM2_PV
+ if ( f ->filesystem == GParted::FS_UNKNOWN
|| f ->filesystem == GParted::FS_LUKS
)
//Compensate for subsequent 'f++' ...
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index a664d2b..6261ebd 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2766,11 +2766,14 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet
{
operationdetail .add_child( OperationDetail(
String::ucompose( _("set partition type on %1"), partition .get_path() ) ) ) ;
-
+ //Set partition type appropriately for the type of file system stored in the partition.
+ // Libparted treats every type as a file system, except LVM which it treats as a flag.
+
bool return_value = false ;
if ( open_device_and_disk( partition .device_path ) )
{
+ //Lookup libparted file system type using GParted's name, as most match
PedFileSystemType * fs_type =
ped_file_system_type_get( Utils::get_filesystem_string( partition .filesystem ) .c_str() ) ;
@@ -2786,13 +2789,15 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet
if ( ! fs_type )
fs_type = ped_file_system_type_get( "ext2" ) ;
- if ( fs_type )
+ if ( fs_type && partition .filesystem != FS_LVM2_PV )
{
lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
- if ( lp_partition &&
- ped_partition_set_system( lp_partition, fs_type ) &&
- commit() )
+ //Also clear any libparted LVM flag so that it doesn't override the file system type
+ if ( lp_partition &&
+ ped_partition_set_flag( lp_partition, PED_PARTITION_LVM, 0 ) &&
+ ped_partition_set_system( lp_partition, fs_type ) &&
+ commit() )
{
operationdetail .get_last_child() .add_child(
OperationDetail( String::ucompose( _("new partition type: %1"),
@@ -2803,6 +2808,22 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet
return_value = true ;
}
}
+ else if ( partition .filesystem == FS_LVM2_PV )
+ {
+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
+
+ if ( lp_partition &&
+ ped_partition_set_flag( lp_partition, PED_PARTITION_LVM, 1 ) &&
+ commit() )
+ {
+ operationdetail .get_last_child() .add_child(
+ OperationDetail( String::ucompose( _("new partition flag: %1"),
+ ped_partition_flag_get_name( PED_PARTITION_LVM ) ),
+ STATUS_NONE,
+ FONT_ITALIC ) ) ;
+ return_value = true ;
+ }
+ }
close_device_and_disk() ;
}
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index b573e99..c7e71fd 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -407,10 +407,9 @@ Gtk::Menu * Win_GParted::create_format_menu()
for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() ; t++ )
{
- //Skip luks, lvm2, and unknown because these are not file systems
+ //Skip luks and unknown because these are not file systems
if (
gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LUKS ||
- gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2_PV ||
gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN
)
continue ;
diff --git a/src/lvm2_pv.cc b/src/lvm2_pv.cc
index 8188471..4d67aaa 100644
--- a/src/lvm2_pv.cc
+++ b/src/lvm2_pv.cc
@@ -30,7 +30,8 @@ FS lvm2_pv::get_filesystem_support()
LVM2_PV_Info lvm2_pv_info ;
if ( lvm2_pv_info .is_lvm2_pv_supported() )
{
- fs .read = GParted::FS::EXTERNAL ;
+ fs .read = FS::EXTERNAL ;
+ fs .create = FS::EXTERNAL ;
}
return fs ;
@@ -77,7 +78,7 @@ bool lvm2_pv::write_uuid( const Partition & partition, OperationDetail & operati
bool lvm2_pv::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return true ;
+ return ! execute_command( "lvm pvcreate -M 2 " + new_partition .get_path(), operationdetail ) ;
}
bool lvm2_pv::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]