[gparted] Default to GPT on disks >= 2 TiB (#711098)



commit 07bd72ba805e74517e0d3dc97c5c4462095e8266
Author: Phillip Susi <psusi ubuntu com>
Date:   Fri Dec 13 11:37:27 2013 -0500

    Default to GPT on disks >= 2 TiB (#711098)
    
    MSDOS partition table is limited to addressing 2^32 sectors, limiting
    disks using 512 byte sectors to 2 TiB in size.  Fdisk reports the
    following warning on disks 2 TiB and larger.
    
        # truncate -s 2T /var/tmp/loop-2T
        # losetup /dev/loop0 /var/tmp/loop-2T
        # fdisk /dev/loop0
    
        WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
        DOS partition table format can not be used on drives for volumes
        larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
        partition table format (GPT).
    
    (Fdisk arguably reports this warning one sector too early.  Anyway for
    safety and consistency GParted will use this limit too).  Continue to
    use MSDOS as the default partition table type for disks smaller than 2
    TiB and use GPT as the default for disks 2 TiB and larger.  This
    maximises compatibility.
    
    Also remove the advanced expander and always show the partition table
    list box.
    
    Bug #711098 - Default partition table can not handle > 2 TiB disks

 include/Dialog_Disklabel.h |    1 -
 include/GParted_Core.h     |    2 +-
 src/Dialog_Disklabel.cc    |   16 +---------------
 src/GParted_Core.cc        |   14 ++++++++++----
 src/Win_GParted.cc         |    2 +-
 5 files changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/include/Dialog_Disklabel.h b/include/Dialog_Disklabel.h
index 8ce6fcc..25455e9 100644
--- a/include/Dialog_Disklabel.h
+++ b/include/Dialog_Disklabel.h
@@ -38,7 +38,6 @@ public:
        Glib::ustring Get_Disklabel( ) ;
        
 private:
-       Gtk::Expander expander_advanced ;
        Gtk::Image image ;
        Gtk::ComboBoxText combo_labeltypes ;
        std::vector<Glib::ustring> labeltypes ;
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index fc1ce9c..8f60183 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -56,7 +56,7 @@ public:
        
        const std::vector<FS> & get_filesystems() const ;
        const FS & get_fs( GParted::FILESYSTEM filesystem ) const ;
-       std::vector<Glib::ustring> get_disklabeltypes() ;
+       std::vector<Glib::ustring> get_disklabeltypes( Device *device ) ;
        std::vector<Glib::ustring> get_all_mountpoints() ;
        std::map<Glib::ustring, bool> get_available_flags( const Partition & partition ) ;
        Glib::ustring get_libparted_version() ;
diff --git a/src/Dialog_Disklabel.cc b/src/Dialog_Disklabel.cc
index 5b3c83c..74e75a8 100644
--- a/src/Dialog_Disklabel.cc
+++ b/src/Dialog_Disklabel.cc
@@ -53,28 +53,14 @@ Dialog_Disklabel::Dialog_Disklabel( const Glib::ustring & device_path, const std
                        str_temp += "</span>\n";
                        vbox->pack_start(*Utils::mk_label(str_temp), Gtk::PACK_SHRINK);
 
-                       str_temp = _("Default is to create an MS-DOS partition table.");
-                       str_temp += "\n";
-                       vbox->pack_start(*Utils::mk_label(str_temp, true, true),
-                                       Gtk::PACK_SHRINK);
-
-                       str_temp = "<b>";
-                       str_temp += _("Advanced");
-                       str_temp += "</b>";
-                       expander_advanced.set_label(str_temp);
-                       expander_advanced.set_use_markup(true);
-
-                       vbox->pack_start(expander_advanced, Gtk::PACK_SHRINK);
-
                        hbox = manage(new Gtk::HBox(false, 5));
                        hbox->set_border_width(5);
                        str_temp = _("Select new partition table type:");
                        str_temp += "\t";
                        hbox->pack_start(*Utils::mk_label(str_temp), Gtk::PACK_SHRINK);
+                       vbox->pack_start(*hbox, Gtk::PACK_SHRINK);
                }
 
-               expander_advanced.add(*hbox);
-
                //create and add combo with partition table types (label types)
                this ->labeltypes = disklabeltypes ;
 
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 83609c1..9ce1a97 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -824,16 +824,22 @@ const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const
                return FILESYSTEMS[ unknown ] ;
 }
 
-std::vector<Glib::ustring> GParted_Core::get_disklabeltypes() 
+std::vector<Glib::ustring> GParted_Core::get_disklabeltypes( Device *device )
 {
        std::vector<Glib::ustring> disklabeltypes ;
+       const char *default_label ;
        
-       //msdos should be first in the list
-       disklabeltypes .push_back( "msdos" ) ;
+       //Default to MSDOS partition table type for disks < 2^32 sectors
+       //  (2 TiB with 512 byte sectors) and GPT for larger disks.
+       if ( device ->length < 4LL * GIBIBYTE )
+               default_label = "msdos";
+       else
+               default_label = "gpt";
+       disklabeltypes.push_back( default_label ) ;
        
         PedDiskType *disk_type ;
         for ( disk_type = ped_disk_type_get_next( NULL ) ; disk_type ; disk_type = ped_disk_type_get_next( 
disk_type ) ) 
-                if ( Glib::ustring( disk_type->name ) != "msdos" )
+                if ( Glib::ustring( disk_type->name ) != default_label )
                        disklabeltypes .push_back( disk_type->name ) ;
 
         return disklabeltypes ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 5b99d5e..9f59027 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -2333,7 +2333,7 @@ void Win_GParted::activate_disklabel()
        }
 
        //Display dialog for creating a new partition table.
-       Dialog_Disklabel dialog( devices[ current_device ] .get_path(), gparted_core .get_disklabeltypes() ) ;
+       Dialog_Disklabel dialog( devices[ current_device ] .get_path(), gparted_core .get_disklabeltypes( 
&devices[ current_device ] ) ) ;
        dialog .set_transient_for( *this );
 
        if ( dialog .run() == Gtk::RESPONSE_APPLY )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]