I recently expanded my RAID 5 Storage Virtual Drive from 6TB to 9TB. The Dell OMSA and the bios for the RAID controller both show I'm at 8382GB. Which is fine.
But when get into Debian and poke around it's still only seeing the 6TB.
When I do an fdisk -l I get this:
Disk /dev/sda: 9000.1 GB, 9000103968768 bytes
255 heads, 63 sectors/track, 1094200 cylinders, total 17578328064 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 4294967295 2147483647+ ee GPT
So it now sees that it's 9TB. But the sda1 partition does not. How do I expand this to reflect the size change.... WITHOUT LOSING ANY DATA!
Thanks
There is no easy way to do so, if you're not using LVM.
Here is a procedure you can follow safely, if you are very very careful. The best way to be careful would be to backup your data before, obviously.
Fortunately, your partition starts at first sector, so you don't need to worry on this one. Your problem is on the end, which is not your (new) last sector. So you need to update it. So you need to destroy your partition, and create a new one (without formating it!).
fdisk -u /dev/sda
Then, in fdisk utility:
d
to delete the partition1
p
to make sure you have no partition leftn
to create a new partition:p
to make it a primary partition1
to make it the first partition1
to make it start on sector 1 (as it was)Optionnal (to make your partition bootable):
a
to toogle the flag, and the1
to specify the partitionNow you have to write your changes:
w
You can now quit fdisk, and reboot your server. Once done, extend your partition at the filesystem level (
resize2fs /dev/sda1
)As @duskwuff already mentioned, this is a
GPT
partition table, sofdisk
only shows protective MBR content. Usegdisk -l /dev/sda
instead. You may be having more than one partition, in which case you will only be able to resize the last one.The workaround (not recommended) may be software RAID0 (called
mdraid
in Linux) spanning the partition you want to expand and one created in the new space, visible as one big space to the OS. To avoid data loss you have to use a variant of mdraid without metadata (mdadm --build ...
, notmdadm --create ...
), checkman mdadm
. This will however degrade performance, pose another difficulties if applied to root filesystem partition, and has the potential to wipe your data on any mistake.Possibly there's another, non-destructive solution - if you have a single partition on the disk and you find your filesystem's offset, you can delete the partition and mount the whole disk partitionless, providing offset= value on mount. Not sure if it works with a proper block device (only used with a loop and image files). If it works with partitions still in place then it will work without them too, so you can experiment with mount & offset before touching partition layout. The downside is that such a layout may confuse data recovery software if you need it some day.
To avoid this kind of problems, I always try to use different volume groups for boot/rootfs - partitioned disk, and for data - partitionless disk (expanding it online is a piece of cake, just resizing of the filesystem -
resize2fs /dev/sda
, assuming it's an EXT{2..4}). This is THE solution for the future.