1

I have a Mac Server running 10.10. The sole purpose of it at the moment is to take time machine backups from multiple devices.

The server itself uses a Thecus NAS AFP share to store the time machine backups. Typically the process I've used in the past to increase storage space is the following

Extend the iSCSI size in the Thecus. This is now 8.8TB (from 6.6TB)

On the server -

Terminal - Sudo up

sh-3.2# df
Filesystem    512-blocks       Used Available Capacity   iused   ifree %iused  Mounted on
/dev/disk0s2    83214256   40438952  42263304    49%   5118867 5282913   49%   /
devfs                362        362         0   100%       627       0  100%   /dev
map -hosts             0          0         0   100%         0       0  100%   /net
map auto_home          0          0         0   100%         0       0  100%   /home
map -fstab             0          0         0   100%         0       0  100%   /Network/Servers
/dev/disk1s2  4294295472 4242994728  51300744    99% 530374339 6412593   99%   /Volumes/Backups
sh-3.2# 


Confirm in Disk Utility the disk size has increased

Eject/Unmount the partition


sh-3.2# gpt show /dev/disk1
       start        size  index  contents
           0           1         PMBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34           6         
          40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      409640  4294295472      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  4294705112  4295229447         
  8589934559          32         Sec GPT table
  8589934591           1         Sec GPT header
sh-3.2# 
sh-3.2# 

sh-3.2# 
sh-3.2# gpt destroy /dev/disk1
sh-3.2# 
sh-3.2# gpt create -f /dev/disk1
sh-3.2# 
sh-3.2# gpt add -b 409640 -s 4294295472 /dev/disk1
/dev/disk1s1 added
sh-3.2# 

The problem this time is I don't have the original -b number.

I've tried the following

sh-3.2# gpt destroy /dev/disk1
sh-3.2# gpt create -f /dev/disk1
sh-3.2# gpt show /dev/disk1
        start         size  index  contents
            0            1         PMBR
            1            1         Pri GPT header
            2           32         Pri GPT table
           34  17179869117         
  17179869151           32         Sec GPT table
  17179869183            1         Sec GPT header
sh-3.2# gpt add -b 409640 -s 17179869117
usage: gpt add [-b lba] [-i index] [-s lba] [-t uuid] device ...
sh-3.2# gpt add -b 409640 -s 17179869117 /dev/disk1
gpt add: /dev/disk1: error: no space available on device

I've tried a couple of different options when creating the partition and get 'no space available' each time.

If I try

gpt add -b 34 -s 17179869117

It will create the partition but be totally unreadable.

The current output of df is

macserver:~ tech$ df
Filesystem                               512-blocks        Used  Available Capacity    iused      ifree %iused  Mounted on
/dev/disk0s2                               83214256    53119064   29583192    65%    6703881    3697899   64%   /
devfs                                           360         360          0   100%        625          0  100%   /dev
map -hosts                                        0           0          0   100%          0          0  100%   /net
map auto_home                                     0           0          0   100%          0          0  100%   /home
map -fstab                                        0           0          0   100%          0          0  100%   /Network/Servers
//Admin.@192.168.3.1/TimeMachineBackups 23241211968 14320040480 8921171488    62% 1790005058 1115146436   62%   /Volumes/TimeMachineBackups

The above 62% free share is what I am targeting.

Can someone please offer any assistance?

1

gpt is a tool to edit the GUID partition table of a disk. It only modifies the primary and secondary GPT header and table and the MBR. Or with other words: it only modifies the first 34 blocks and the last 33 blocks of a device. This means: if you add a partition starting at block 40 and ending at block 409640 (these are the boundaries of a typical OS X EFI partition) it doesn't write anything to the blocks 40-409640 but only to the GPT headers/tables.

Adding a partition doesn't result in a file system and far less in a readable file system. To create a file system you have to format the partition with an appropriate tool like newfs_hfs! After formatting a partition the file system is essentially empty except the necessary parts which "represent" the file system like catalog file, allocation file etc.

If you remove a partition with a file system or remove the whole partition table containing several formatted partitions with gpt remove|destroy ... the file system(s) won't be touched. So after restoring a partition or a partition table with the same values they had previously the file system(s) with all content will "reappear".

One (rare) case exists where a partition might be enlarged: if some unallocated disk space is directly "behind" a partition. If you first remove a partition with gpt and then re-add the partition with the same start block but a larger size the previous file system is completely in the boundaries of the new partition. But at least the allocation file (~volume bitmap) is corrupted and the alternative volume header is at the wrong location. Usually such an "intentionally corrupted" file system can be repaired with diskutil repairVolume .... You are highly discouraged though to use this method to enlarge a partition.


Modifying disk partitions with gpt like in your question or as described below will delete any current partition (and its content) with a high probability. To resize (expand or shrink) a current partition while keeping the content use diskutil!

Starting using an empty disk with a default GPT partition table you get the following partition scheme:

sh-3.2# gpt show /dev/disk1
        start         size  index  contents
            0            1         PMBR
            1            1         Pri GPT header
            2           32         Pri GPT table
           34  17179869117         
  17179869151           32         Sec GPT table
  17179869183            1         Sec GPT header

Though newer disks report a logical block size of 512 Bytes they usually have a physical block size of 4096 Bytes.

  • 1st rule: start blocks and partition sizes should be dividable by 8 to align partitions to physical blocks
  • 2nd rule: you can't assign more blocks than available (the max. available number of blocks is: 17179869117 (and aligning to physical blocks: 2147483639 x 8 = 17179869112 blocks)
  • 3rd rule: try to specify a GUID type

One viable option is:

gpt add -b 40 -i 1 -s 17179869112 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk1

Or you might add an EFI partition and leave some space at the end of the disk (as Apple does):

gpt add -b 40 -i 1 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk1
gpt add -b 409640 -i 2 -s 17179197368 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk1

After adding the partitions you have to format the main partition:

newfs_hfs -J -v "Name" /dev/disk1s1

or if you chose the second partition table (with EFI partition)

newfs_hfs -J -v "Name" /dev/disk1s2
  • Thank you. I tried the first option before your edit when -s was at a different value, this creates a disk but 'The disk you inserted was not readable by this computer'. Perhaps because I haven't formatted yet? After the edit, the same steps say 'no space available on the device'. For the formatting stage, this is rather scary - will this definitely not erase any data? – jblz Mar 9 '16 at 21:43
  • @jbiz You can't resize partitions with gpt while keeping the content. Modified answer/added preface – klanomath Mar 9 '16 at 21:46
  • Damn. This is the same process I used to extend before, I must have used 'gpt add' incorrectly. I've accepted your answer as I did not make it clear I wanted to retain the data. Thank you for your assistance. – jblz Mar 10 '16 at 0:45
  • @jblz To properly resize a volume with a file system preserving the content use diskutil resizeVolume /dev/diskXsY size with size=xy% or Bytes (e.g. 95% or 14000G) – klanomath Mar 10 '16 at 0:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .