2

I have a CentOS 7 machine with two disks mounted [ /dev/sda and /dev/sdb ] using ext4.

I need to extend /dev/sdb1 to over 2 TB.

I extended the disk from 2 TB to 2.5 TB (google cloud)

After using fdisk to delete and recreate the partition, after the reboot the resize2fs /dev/sdb1 does not resize the partition to 2.5 TB, since it looks like fdisk has reached the magical 2 TB limit.

Is there a way to extend /dev/sdb1 to lets say 3 TB without losing the data?

Thanks

update

as suggested by the fellow serverfault user @mzhaase I tried the gdisk with the following steps. The disk was formated with fdisk in total size of 2T

  1. stop all services using the /dev/sdb1 partition
  2. umount the device
  3. Create a backup/snapshot
  4. Extend the disk to 3T
  5. install gdisk if not already installed on the instance
  6. gdisk procedure
    gdisk /dev/sdb
    p #print and save the GUID
    o #delete all partitions
    n #create new partition
    c #label press ENTER or name if it had it
    x #enter expert mode
    g #paste the GUID
    w #write changes

  7. umount /dev/sdb1 #if it gets remounted by gdisk

  8. e2fsck -f /dev/sdb1 #check disk
  9. resize2fs /dev/sdb1 #resize the partition
  10. mount -a #check if the partitions mount as per fstab
  11. reboot #just to be sure
  • I would not use fdisk on such large disks. It messes up a lot of things! – Alexis Wilke Sep 26 '16 at 16:45
6

There are two major partitioning schemes in use today: MBR and GPT.

The older, deprecated, and probably still most used one is MBR. However, MBR uses 32 bit to address storage space, using 512 Byte blocks, and 2^32 * 512 Byte are.. 2 TB. So no, you cannot extend an MBR partition over 2 TB. You will need to use GPT for that.

I have never done it myself, but it seems to be possible to convert MBR to GPT without losing data, using gdisk. Try it on your own risk.

  • that means what the data will have to be destroyed and restored from a backup, right? – nelasx Sep 26 '16 at 12:42
  • 1
    @nelasx I made another edit. Apparently you can do it without data loss using gdisk. Good luck! – mzhaase Sep 26 '16 at 12:45
  • 2
    Taking a backup in any case is prudent if you care about the data. Worst case you do a restore. – John Mahowald Sep 26 '16 at 13:03
  • there is a nice document on docs amazon aws explaining how to do it with gdisk. I tried it on a dev instance and it worked out. aws docs – nelasx Sep 26 '16 at 13:06
  • @mzhaase thanks again for your tip on using gdisk it was a life saver. – nelasx Sep 28 '16 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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