Wednesday, October 12, 2011

GNU parted - GTP partition editor

Personally, I dislike "parted" because it works differently then all of the older utilities like fdisk and sfdisk.  Under the old system you could easily "fdisk -l /dev/some/device" and get a sensible reply.  If you try something similar with GNU's parted like "parted -l /dev/some/device", you get a listing of *all* of the devices on the system rather then just what you want to look at.  The syntax is instead "parted /dev/some/device print", and the device name has to come *first* in that command, otherwise it will complain about "print" not being a device.

So, you have a big disk, and you need to partition it, first let's look at the surviving disk in the Software RAID array:

# parted /dev/sde print

Model: ATA Hitachi HDS72202 (scsi)
Disk /dev/sde: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  2000GB  2000GB               primary  raid

Information: Don't forget to update /etc/fstab, if necessary. 

Now, let's look at the new disk:

# parted /dev/sdd print
Error: Unable to open /dev/sdd - unrecognised disk label.

Makes a lot of sense, doesn't it?  Real helpful! Good old GNU parted refuses to give us information about an entirely blank disk, not even helpful information like size (which "fdisk -l" will give us).

So go ahead and label that blank drive with a GPT disk label:

# parted /dev/sdd mklabel gpt


Now we'll actually get good information out of GNU parted's print command:

# parted /dev/sdd print     

Model: ATA ST2000VX002-1AH1 (scsi)
Disk /dev/sdd: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

Well, that's a start (but why couldn't it tell us that before?).

# parted /dev/sdd
(parted) mkpart primary 1 -1
(parted) set 1 raid on

# parted /dev/sdd print

Model: ATA ST2000VX002-1AH1 (scsi)
Disk /dev/sdd: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  2000GB  2000GB               primary  raid


 

No comments: