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
This commit is contained in:
Phillip Susi 2013-12-13 11:37:27 -05:00 committed by Mike Fleetwood
parent 06c4929353
commit 07bd72ba80
5 changed files with 13 additions and 22 deletions

View File

@ -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 ;

View File

@ -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() ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 )