Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've extended my hardware RAID device on LSI MegaRAID controller by adding disks to the array. While making Linux notice the block device size change was not straight forward, I've found that one can rescan the device (using echo y > /sys/devices/pci0000:00/0000:00:02.2/0000:03:00.0/host0/target0:2:0/0:2:0:0/rescan in my case, for first logical drive) to fix that.

Unfortunately, I'm stuck at this point.

XenServer 6.0 by default uses GPT not MBR partitions and as such, using fdisk to modify partition table is impossible (the usual tool I've used to extend physical partitions). GPT labels save not only the position of partitions but also size of the disk (by saving the secondary GPT header at last 34, or so, sectors). Probably because of that, the gdisk and sgdisk utilities can't resize the last partition above the old drive limit.

I've tried fdisk (does not work with GPT), sfdisk (does not work with GPT), parted (not installed), cfdisk (not installed).

What tool and commands should I use to extend GPT partitions on system without parted?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

An hour of googling was 5 minutes short to find the answer... anyway:

gdisk and sgdisk allow to relocate the second GPT header in "expert mode".

If the basic situation was like this:

# sgdisk -p /dev/sda
Disk /dev/sda: 3902341120 sectors, 1.8 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 01BFC515-C093-495B-A33F-CA925FB74357
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1951170526
Partitions will be aligned on 2048-sector boundaries
Total free space is 6042 sectors (3.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         8388641   4.0 GiB     0700  
   2         8390656        16777249   4.0 GiB     0700  
   3        16779264      1951170526   922.4 GiB   8E00

(note the last usable sector is 1951170526)

By using the x command in gdisk and then e command, the partition table looks like this:

Expert command (? for help): p
Disk /dev/sda: 3902341120 sectors, 1.8 TiB
 Logical sector size: 512 bytes
Disk identifier (GUID): 01BFC515-C093-495B-A33F-CA925FB74357
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3902341086
Partitions will be aligned on 2048-sector boundaries
Total free space is 1951176602 sectors (930.4 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         8388641   4.0 GiB     0700  
   2         8390656        16777249   4.0 GiB     0700  
   3        16779264      1951170526   922.4 GiB   8E00 

(note the last usable sector is 3902341086)

After that, removing and re-creating a larger partition works without a problem.

share|improve this answer

gdisk got a look and feel of fdisk, but for GPT. Also, why not reboot to a live distro of partedmagic and just do partitioning there with the newest parted?

share|improve this answer
    
It's a XenServer - it's a server for running virtual machines. Rebooting it causes downtime of over half a dozen other machines... –  Hubert Kario Jun 25 '12 at 12:56
    
I figured it wasn't that important, since you're screwing with partitions on it ;) in that case, if you have enough space you can yum install gcc and compile gdisk or parted in Dom0. –  Marcin Jun 25 '12 at 13:58

You can also install parted with the following command:

yum --enablerepo=base install parted
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.