Practical LPIc-3 300

Practical LPIC-3 300 made it to the Best Linux Books of All Time

BookAuthority Best Linux Books of All Time

I’m happy to announce that my book, “Practical LPIC-3 300: Prepare for the Highest Level Professional Linux Certification”, made it to BookAuthority’s Best Linux Books of All Time:
BookAuthority collects and ranks the best books in the world, and it is a great honor to get this kind of recognition. Thank you for all your support!
The book is available for purchase on Amazon.

GUID partition tables (GPT)

When partitioning a disk, most of the times people still use the old MBR partition scheme. This standard dates back to the 80s, so it is not surprising that it has many limitations in today’s world. One of those limitations is the maximum size of 2TB for this type of partition.

2TB was obviously an enormous amount of space when MBR was designed, but today it is not uncommon for any server to need bigger than that, when this happens we need to use a newer partition scheme such as GUID partition tables (GPT).

However, if we have an MBR partition that is less than 2TB in size and we need to expand it beyond that size we might have a problem, as we’ll have to delete the relabel the partition as a GPT partition, losing all the information in the process. There is a possibility, though, not to lose the information. This could work if we recreate the partition with the same beginning.

NOTE: This doesn’t mean we don’t need to have a backup. Having a backup is absolutely mandatory, however if we manage to recover the original information we can save up a lot of time because we won’t need to restore the backup.

To create GPT partitions we can no longer use fdisk, we need to use parted instead. First of all we’ll take a look at the original partition.

root@raspberrypi:~# parted /dev/sda
GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: Generic Flash Disk (scsi)
Disk /dev/sda: 8054MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  8054MB  8053MB  primary  fat32        boot


We note down he start of the partition. The we’ll use mklabel to create a new partition table.

(parted) help mklabel                                                     
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition

	LABEL-TYPE is one of: aix, amiga, bsd, dvh, gpt, mac, msdos, pc98, sun,
(parted) mklabel gpt                                                      
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 

If we print the partition table we’ll see that we have a gpt partition scheme and a single partition.

(parted) print                                                            
Model: Generic Flash Disk (scsi)
Disk /dev/sda: 8054MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  8053MB  8052MB  fat32        primary

Once created the partition table we create the partition itself with mkpart, we create the partition with the same start and the same file system.

(parted) help mkpart   mkpart PART-TYPE [FS-TYPE] START END     make a partition     PART-TYPE is one of: primary, logical, extended         FS-TYPE is one of: zfs, btrfs, ext4, ext3, ext2, fat32, fat16, hfsx,         hfs+, hfs, jfs, swsusp, linux-swap(v1), linux-swap(v0), ntfs, reiserfs,         freebsd-ufs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs, amufs5, amufs4,         amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4,         affs3, affs2, affs1, affs0, linux-swap, linux-swap(new),         linux-swap(old)         START and END are disk locations, such as 4GB or 10%.  Negative values         count from the end of the disk.  For example, -1s specifies exactly the         last sector.         'mkpart' makes a partition without creating a new file system on the         partition.  FS-TYPE may be specified to set an appropriate partition         ID. 
(parted) mkpart primary fat32 1049kB 8054MB

And that’s it. If everything is correct we should be able to mount the filesystem an access it. But, as now the the partition type is GPT it can be expanded beyond 2TB

Yet another Linux blog ;-)