From LinuxMCE
Revision as of 13:52, 11 March 2008 by Razvang (Talk | contribs) (Formating the Partitions)

Jump to: navigation, search

If you want to create partitions larger than 2TB you'll have to use GTP partitioning system instead of classical MBR. Note that you BIOS knows only MBR partitioning schema and will not likely boot from a GTP partition. You cannot mix GTP and MBR partitions on a single drive so drives larger than 2TB will need to be completely GTP and will be non-bootable; you will need a separate hard drive that contains the system.

Creating Partitions

You'll need to use parted to create the partitions since fdisk only know to work with MBR. The next command will open a parted shell, you'll need to replace /dev/sda with the drive that you want to partition.

parted /dev/sda

The next commands should be typed int the parted shell.

WARNING: By running this commands you will delete you partition schema and won't be able to access the information that was stored on the disk (if any).

(parted) mklabel gpt                   <-- This one creates a empty partition table on the disk
(parted) print                         <-- List some information about the current partition table, size of the disc
(parted) mkpart primary 0 3000GB       <--- Creates a partition starting from the beginning trough the 3000GB location
(parted) mkpart primary 3000GB 5000GB  <--- Creates another partition starting from the 3000GB locations to the 5000GB location
(parted) quit                          <-- Exit the parted shell

After doing the previous command, you should have created two partitions, a 3TB and a 2TB one. In order for udev to create /dev/sda1 and /dev/sda2 devices associated with the partitions, you need to run the next command or reboot your computer:

partprobe /dev/sda

Formating the Partitions

Except of partition creation you won't see any difference between GPT and MBR in linux. So for formatting you can do it the same way as you would format any other discs. For example:

mkfs.ext3 /dev/sda1

Resize Partition Table

If you partitioned a raid array with GPT and you later increased the size by adding more disks you must run parted again on that drive and tell it to use all available space. A simple 'print' command in parted will use the warning message to which you you need to answe 'F'.

# parted /dev/sda
(parted) print
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all 
of the space (an extra 1953103872 blocks) or continue with the current setting? 
Fix/Ignore? F

Parted can also resize an existing partition to fill some unused space that you added. Before trying doing the partition resize check first that you partition is umounted and that it the filesystem on it is fine. Parted will complain about mounted partitions or inconsistent filesystem anyway.

For example, let's take a 5000GB drive that has a 4000GB ext3 partition on it.

(parted) print               
Model: AMCC 9650SE-16M DISK (scsi)
Disk /dev/sda: 5000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  4000GB  4000GB  ext3         primary

To resize that partition, you need to use the resize parted command which has the fallowing syntax :

resize <partition_no> <new_start> <new_end>

To transform the partition from our example from 4000GB to 5000GB :

(parted) resize 1 0GB 5000GB