Create GUID partition table (GPT) during Ubuntu Server install

59,240

Solution 1

Test this:

You switch to a text console via Alt + F2.

Try to create a partition start GNU parted as follows:

sudo -i
parted /dev/sda

Output:

GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

Creates a new GPT disklabel i.e. partition table:

mklabel gpt

Sample outputs:

Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes

Next, set the default unit to TB, enter:

unit TB

To create a 2TB partition size, enter:

mkpart primary 0.00TB 2.00TB

To print the current partitions, enter:

print

Sample outputs:

Model: ATA ST33000651AS (scsi)
Disk /dev/sda: 2.00TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name     Flags
 1      0.00TB  2.00TB  2.00TB  ext4         primary

Quit and save the changes, enter:

quit

Use the mkfs.ext4 command to format the file system, enter:

mkfs.ext4 /dev/sda1

Solution 2

I suppose a direct 'yes' solution to your question is to ensure your machine boots in UEFI-only mode. This worked flawlessly for me on a SuperMicro X11 mainboard with the official 14.04.4 server installer. I did have to change the BIOS boot mode from "DUAL" (which also allows "LEGACY" boots) to "UEFI".

This yielded a /dev/sda root disk that was GPT partitioned (with a bootable fat32 partition type EF00) without any manual intervention. I was also able to adjust the "guided" partitioning - just because I wanted different sizes and layout, there was no need to do anything special relating to GPT.

It would be interesting to know if there are any downsides to booting in UEFI mode. Can't help but think the technology's been around long enough for issues to have been ironed out...

see also attached screenshot

Solution 3

To find the gdisk package: find /cdrom | grep gdisk

To install it: udpkg -i /cdrom/<blah>

You will need to repeat this a couple of times to install libstdc++, libgcc_s and perhaps one or two other shared libraries that are missing from the Ubuntu Server 15.10 installer image, before the installed gdisk package will run.

You'll get a couple of errors while installing shared libraries because udpkg is not apt-get and does not resolve dependencies. Ignore the errors, gdisk will still work.

Solution 4

Fdisk does not work for GPT, currently. But parted does. Or you can just easily install gdisk.

At the current time the installer does not let you select. At some point over 1.5TB (if drive is unpartitioned) or is UEFI it defaults to GPT, otherwise it defaults to MBR and is not otherwise selectable.

Convert to msdos or gpt, if you have data may be destructive, so have good backups:

sudo parted /dev/sda
mklabel msdos/gpt
quit

You can easily install gdisk:

sudo apt-get install gdisk

http://www.rodsbooks.com/gdisk/

GPT Advantages (older but still valid) see post#2 by srs5694:

http://ubuntuforums.org/showthread.php?t=1457901

https://wiki.archlinux.org/index.php/GUID_Partition_Table#Advantages_of_GPT

Solution 5

The simplest way for me was to boot into the the existing installation :

apt-get install gdisk gdisk /dev/vda

& write (option o in gdisk) a GPT partition table (which allocated 1 MiB of space at the beginning & end of the disk & preserved a protected copy of the MBR).

I then rebooted from the CD & chose Rescue Mode& mounted the root partition from the existing installation & ran :

/sbin/gdisk /dev/vda

& created the gpt partitions setting the correct partition types :

enter image description here

You will need to reboot the machine again so the kernel reads the new partition table & begin the installation.

During installation I set :

Partition 1:

1 MiB EF02 as filesystem type reserved-bios

Partition 2:

250 MiB EF00 as ext4 with noatime,nodiratime mounted @ /boot & marked bootable

Share:
59,240

Related videos on Youtube

azimut
Author by

azimut

Sometimes, you get many upvotes for an answer which feels trivial to you. And sometimes, you feel like giving a very nice answer, but nobody cares. Here is a link to one of these cases... (0 upvotes within more than a year)

Updated on September 18, 2022

Comments

  • azimut
    azimut over 1 year

    On a computer with a new empty hard drive of capacity < 2 TB, I install Ubuntu Server with the standard text-mode installer. I choose to manually partition the disk. Then I can create a new empty partition table. This will be a legacy partition table. However, I want a GPT one, but I didn't find a way to select it.

    I've tried to switch to a text console via Alt + F2. However, the command gdisk is not available (neither is fdisk).

    I know that I could boot some live linux first to create the partition table (which seems unnecessarily cumbersome). So my question is explicitly about the standard Ubuntu Server text-mode installer. Is there a way to create a GUID partition table (GPT) during the install?

  • Fabby
    Fabby about 9 years
    @azimut This answer provides you with a way of using parted to create the GPT in a tty (which is what you tried with fdisk which won't work as it doesn't support GPT). If you want, I can provide you with a simpler answer but that would just read "No, from the text-mode installer itself it is currently not possible to do this" and then close your question as "off-topic: bugs should be filed to launchpad"... Leave me a comment if that’s preferable to someone actually trying to help you... :P ;-)
  • azimut
    azimut about 9 years
    @Fabby: Right, I gave a "yes or no" question, and that is basically what I wanted as an answer: Either "no" or "yes" + how. I wrote twice that this question is explicitely about the standard Ubuntu Server installer, so I think it's only fair to expect that this point isn't completely ignored.
  • azimut
    azimut about 9 years
    Thanks for this answer. I will check if parted is available from the Server installer text console.
  • Fabby
    Fabby about 9 years
    @azimut: :D I understand now! ;-) Well, you've got it in a comment below the answer now! :P ;-) oldfred: please edit your answer and start with "No, this is not possible, but here's a workaround:" and leave all the rest intact. After that, I think someone is going to push the little sad grey check-mark and turn it a beautiful green hue... ;-)
  • Keith
    Keith about 8 years
    @kyodake, @azimut: no, unfortunately, parted is not available in the Server installer text console :-(
  • Keith
    Keith about 8 years
    After some more research it is possible (at least on the 16.04 Xenial server installer): From the server installer you can pop to a different console (e.g. using Alt-F2) and run udpkg -i /cdrom/pool/main/p/parted/parted-udeb_3.2-15_amd64.udeb
  • azimut
    azimut about 8 years
    @ph0t0nix: Thanks. I will try that at my next install after the official release of 16.04
  • sxc731
    sxc731 almost 8 years
    Thanks for this. I haven't attempted it but does this method allow preserving the existing installation or do you have to re-install on top of the manually created partitions?
  • sxc731
    sxc731 almost 8 years
    @ph0t0nix : excellent tip, which also works on a 14.04.4 CD/ISO, except for a slightly different path (due to different version). Use udpkg -i /cdrom/pool/main/p/parted/parted-udeb_2.3-19ubuntu1.14.04.1_‌​amd64.udeb
  • Stuart Cardall
    Stuart Cardall almost 8 years
    @sxc731 - you will need to reinstall