How to get Newly Expanded RAID to show correct size in Debian
Solution 1:
As @duskwuff already mentioned, this is a GPT
partition table, so fdisk
only shows protective MBR content. Use gdisk -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 ...
, not mdadm --create ...
), check man 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.
Solution 2:
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 left -
n
to create a new partition:-
p
to make it a primary partition -
1
to make it the first partition -
1
to make it start on sector 1 (as it was) - make the last sector your 'End' of your partition (should be the default answer)
-
Optionnal (to make your partition bootable):
-
a
to toogle the flag, and the1
to specify the partition
Now 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
)