Q:

Disk Utility Crashes during HDD Partition (16.04 LTS)

I have a 4TB internal hard drive that I am trying to partition so that I can mount it.  I first formatted the disk using the Disk utility.  Then I attempted to create a single partition on the disk.  The first couple of times that I tried the utility quit and a pop up box appeared saying the Ubuntu had suffered an internal error.  I tried restarting my machine after each failed attempt.  The utility still crashes, but now I no longer get the error messages. 
I am running Ubuntu 16.04 LTS, although I have upgraded my default gcc version to 6.3 from what came with the 16.04. What steps should I take to properly partition and mount this drive?  Is there a way that I can get around using Disks?  Thanks! 

A:

Two possibilities (which might interact) spring to mind:

A Disk Utility bug -- It could be that Disk Utility is simply buggy, particular with a disk that's over 2 TiB in size. That's an important boundary point because it's 2^32 sectors, which means you need an over-32-bit integer to store the size of the disk, the end point for a partition that fills the disk, and so on. If the code in Disk Utility uses 32-bit integers to hold sector values, it would misbehave, and possibly cause a program crash, on disks over 2 TiB in size.
Wrong partition table type -- The 32-bit limit also means that the old Master Boot Record (MBR) partition table type is inadequate for disks over 2 TiB in size. MBR is the default for some tools, though, and some cannot handle the newer GUID Partition Table (GPT), which is the partitioning method that's most commonly used on disks that are over 2 TiB in size. If Disk Utility set up an MBR partition table and then tried to create an over-2TiB partition, this would certainly fail, and might conceivably fail in a way that would cause a program crash.

Although Disk Utility (aka Palimpsest) may seem like the obvious partitioning tool to use, most Ubuntu users prefer to use something else, such as:

GParted -- This is a GUI tool that's generally the go-to tool for GUI partitioning or when people want to resize existing partitions. It supports both MBR and GPT partitions, but if you start with an empty disk, you may need to explicitly tell it to create GPT data structures to use GPT.
parted -- GParted is based around a library called libparted, and parted is a simpler text-mode tool that uses the same library. Although parted can't resize filesystems and is less user-friendly than GParted, it's still commonly used, particularly when a text-mode tool is preferred. Unlike GParted, parted does not enable creating filesystems in partitions; for that, you use other text-mode tools, like mkfs.
GPT fdisk -- This is a family of text-mode partitioning tools (gdisk, sgdisk, and cgdisk) that I wrote. They're designed exclusively for use on GPT disks, and gdisk, in particular, provides better control of GPT data structures than any other tool of which I'm aware. Unusually, GPT fdisk will automatically convert a disk from MBR to GPT form, which can be handy (but can also lead to trouble if you use it without knowing what you're doing). Like parted, GPT fdisk works on partition table data structures exclusively; you must use mkfs or other tools to create or manipulate filesystems.
fdisk -- This tool and its cousins (sfdisk and cfdisk) originally supported MBR and some other obscure partition table types. It's recently been updated to support GPT; the version delivered with Ubuntu 16.04 supports GPT. Like parted and GPT fdisk, fdisk requires use of other tools to create or manipulate filesystems. Note that the gdisk and cgdisk user interfaces are modeled after those of fdisk and cfdisk, respectively. (I wrote GPT fdisk long before fdisk acquired GPT functionality.)

At this point, I recommend you review your configuration with GParted or GPT fdisk. In particular, you can check the validity of the partition table with sgdisk's -v option, as in:
$ sudo sgdisk -v /dev/sda

No problems found. 6 free sectors (3.0 KiB) available in 1
segments, the largest of which is 6 (3.0 KiB) in size.

This will tell you whether there are any problems with the partition table on /dev/sda (change that detail as necessary) and how much space is unallocated. (This example shows just 3 KiB unallocated, but that's unusually small. Most disks will have at least 1-2 MiB unallocated.) If sgdisk shows that the disk has many GiB or even TiB unallocated, then something is wrong -- perhaps the disk was prepared as an MBR disk. The gdisk -l /dev/sda and parted /dev/sda print outputs will each show what partition table type the disk uses, each in its own way. For instance, the parted output will include something like this:
Partition Table: gpt

If that line reads msdos rather than gpt, the disk uses MBR. In this case, you might want to use gdisk on it, and write the changes back out, to convert from MBR to GPT. You can then use GParted to expand the existing partition. I don't recommend doing this without reading up on the procedure or providing more details of your configuration and asking for advice, though, since you can easily dig yourself into some very bad trouble trying to do this. For starters, see the GPT fdisk page on MBR-to-GPT conversions.

