Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save crossi202/8964162eefb84e384058 to your computer and use it in GitHub Desktop.
Save crossi202/8964162eefb84e384058 to your computer and use it in GitHub Desktop.
Guide to overcome the 2TB limitation for CentOS 6.7 at Hetzner

Installing CentOS 6.7 on Hetzner with partitions larger than 2TB

Install the CentOS 6.7 64 bit minimal

  • Start the server in Rescue mode [1],
  • Type
$ installimage
  • Select CentOS -> CentOS-67-64-minimal
  • Configure the installation by modifying the configuration file, here's an example:
## ======================================================
##  Hetzner Online GmbH - installimage - standard config
## ======================================================
DRIVE1 /dev/sda
DRIVE2 /dev/sdb
DRIVE3 /dev/sdc
DRIVE4 /dev/sdd

SWRAID 1
SWRAIDLEVEL 5

BOOTLOADER grub

HOSTNAME <hostname>

PART swap swap 16G
PART /boot ext3 512M
PART / ext4 100G
PART /data ext4 all

IMAGE /root/.oldroot/nfs/install/../images/CentOS-67-64-minimal.tar.gz

Note: The / partition here should not be larger than 2TiB.

  • Type F10 and Save,
  • The script will show the message:
CentOS only supports MS-DOS partition tables when using grub. We changed the space of your "all" partition to match the 2TiB limit.
  • Press Enter and go ahead,
  • The script will ask you to delete the data on the disks, click on 'Yes' and go ahead
  • After the installation, type:
$ reboot

Convert MBR to GPT

  • Access via SSH the server,
  • Umount the 'all' partition (here /data) and comment the /etc/fstab entry:
$ umount /data
$ grep data /etc/fstab
#/dev/md/3 /data ext4 defaults 0 0 
  • Remove the RAID device:
$ mdadm --stop /dev/md3
$ mdadm --remove /dev/md3 
  • Type the command:
$ gdisk /dev/sda
  • Follow the instructions, as shown below:
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
  • Perform the previous command and instructions for all the disks,

  • Reinstall the boot loader:

$ grub-install /dev/sda
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(hd0) /dev/sda
(hd1) /dev/sdb
(hd2) /dev/sdc
(hd3) /dev/sdd
  • Perform the previous command for all the disks,

  • Reboot:

reboot

Prepare the new partitions

  • Type:
$ gdisk /dev/sda
  • Follow the instructions, as shown below:
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sda: 11721045168 sectors, 5.5 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 6D41909E-8BB0-4FD1-8649-E87690A0A995
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 11721045134
Partitions will be aligned on 2048-sector boundaries
Total free space is 7323667561 sectors (3.4 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        33556480   16.0 GiB    FD00  Linux RAID
   2        33558528        34607104   512.0 MiB   FD00  Linux RAID
   3        34609152       104513536   33.3 GiB    FD00  Linux RAID
   5       104517632      4397387776   2.0 TiB     FD00  Linux RAID

Command (? for help): d
Partition number (1-5): 5

Command (? for help): n
Partition number (4-128, default 4): 5
First sector (34-11721045134, default = 104515584) or {+-}size{KMGTP}: 104517632
Last sector (104517632-11721045134, default = 11721045134) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): FD00
Changed type of partition to 'Linux RAID'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
  • Perform the previous command and instructions for all the disks,
  • Reboot:
$ reboot

Create the RAID device and format the partition

  • Create the RAID device:
$ mdadm --create --verbose /dev/md3 --level=5 --raid-devices=4 /dev/sda5 /dev/sdb5 /dev/sdc5 /dev/sdd5

Note. The actual number of devices for the RAID will depend on the avaialable disks, as well as the RAID level.

  • Update accordingly the file /etc/mdadm.conf based on the output of the command:
$ mdadm --detail --scan
  • Generate the new initramfs:
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.old
dracut --mdadmconf --force /boot/initramfs-$(uname -r).img $(uname -r)
  • Create the filesystem:
$ mkfs.ext4 /dev/md3
  • Comment out the /etc/fstab:
$ grep data /etc/fstab
/dev/md3 /data ext4 defaults 0 0
  • Et voilà!

Final notes

If you have a partition larger than 16TiB, the mkfs.ext4 provided by the CentOS distribution will not work, exiting with the message:

$ mkfs.ext4 /dev/md3
mke2fs 1.41.12 (17-May-2010)
mkfs.ext4: Size of device /dev/md3 too big to be expressed in 32 bits
	using a blocksize of 4096.

The solution is to compile and execute the latest version of e2fsprogs Ext2/3/4 file system utilities:

$ yum install gcc
$ curl -L -o e2fsprogs-v1.42.13.tar.gz https://github.com/tytso/e2fsprogs/archive/v1.42.13.tar.gz
$ tar xvzf e2fsprogs-v1.42.13.tar.gz
$ cd e2fsprogs-1.42.13/
$ ./configure --prefix=<your prefix>
$ make
$ make install
$ cd <your prefix>/sbin
$ ./mkfs.ext4 /dev/md3

[1] http://wiki.hetzner.de/index.php/Hetzner_Rescue-System/en

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment