[TriLUG] how big and where is the GPT

William Sutton william at trilug.org
Mon Jul 28 07:44:31 EDT 2014


People are still using ext2 in 2014?  the horror :-)

William Sutton

On Mon, 28 Jul 2014, Ron Kelley wrote:

> Someone mentioned earlier the inability to script gparted (“but I can script writing bits”).  You can easily script parted using the “—script” command-line argument.  In fact, you can script an entire disk partition (including GPT or MSDOS disk labels).  Here is a quick way to script out parted on a 40G disk:
>
> ------------------------------------------------------
> parted -s /dev/sda mklabel msdos
> parted -s /dev/sda mkpart primary ext2 1 5000
> parted -s /dev/sda mkpart primary linux-swap 5001 7000
> parted -s /dev/sda mkpart primary ext2 7001 100%
> ------------------------------------------------------
>
> I use this in one of my CentOS kickstart scripts.
>
> If you just wanted to convert an msdos disk to a gpt disk, simply use “parted -s /dev/sda mklabel gpt”. Replace gpt with msdos to go the other way...
>
>
> Hope this helps.
>
> -Ron
>
>
>
> On Jul 28, 2014, at 12:26 AM, Aaron Joyner <aaron at joyner.ws> wrote:
>
> I haven't played with GPT much, so I was eager to see where this thread
> went, and read up some if time allowed.  Gregory's assertions do seem to
> align with the Wikipedia description of GPT:
> http://en.wikipedia.org/wiki/GUID_Partition_Table
>
> The image on that page is a most excellent and concise summary of the
> information you want, but I'd suggest the relevant text commentary from the
> page would be:
> ----- 8< snip 8<-----
> The header contains the disk globally unique identifier (GUID). It records
> its own size and location (always LBA 1!) and the size and location of the
> secondary GPT header and table (always the last sectors on the disk).
> ----- 8< snip 8<-----
>
> More reading of that page is required to understand the intricacies of why
> blocksize might be 512 or 4k, but suffice to say that the blocksize
> presented by the disk determines how large the headers are, so you should
> look to see what it is.  You can easily check with lsblk or hdparm:
> $ lsblk -o NAME,PHY-SeC
> $ sudo hdparm -I /dev/sda | grep -i physical
>
> To rephrase the answer into my own words, if you want to smash the GPT from
> a disk, you need to wipe out the headers which are used to determine
> there's a GPT on the disk.  These are stored as the first 2 blocks and the
> last block on the disk.  That's pretty straightforward with dd, if you know
> the LBA blocksize and the size of the disk expressed in those terms:
> $ dd if=/dev/zero of=/dev/your_disk bs=<blocksize, see above> count=2
> $ dd if=/dev/zero of=/dev/your_disk bs=<blocksize, see above> count=1
> oseek=<((size of disk in bytes / <blocksize>) - 1)>
>
> Please use caution determining the value of oseek correctly, or you'll be
> writing a small patch of zeros to some random part of the disk with
> potentially unknown consequences.
>
> Let us know how it goes!
> Aaron S. Joyner
> -- 
> This message was sent to: Ron Kelley <rkelleyrtp at gmail.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web	: http://www.trilug.org/mailman/options/trilug/rkelleyrtp%40gmail.com
> Welcome to TriLUG: http://trilug.org/welcome
>
> -- 
> This message was sent to: William <william at trilug.org>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web	: http://www.trilug.org/mailman/options/trilug/william%40trilug.org
> Welcome to TriLUG: http://trilug.org/welcome
>


More information about the TriLUG mailing list