My question is how to resize partition on Debian 8 without losing any data? I have 90 GB partition but my disk has 150 GB space on VPS server, so 50 GB is free and I want to add this 50 GB without losing any data, this is how it presents:
I've tried using resize2fs command but this didn't helped me because it shows me an error :
Filesystem is already n blocks long. Nothing to do!
I've already extended a partition on Debian 11 with resize2fs and everything was fine, here I don't know why but It doesn't want to work.
According to your disk layout, you have to
(0) move away the swap partition to leave space for extending
vda1; partition space must be contiguous. for this purpose:
/dev/vda2is your swap device file. Always check my arguments)
parted /dev/vda rm partnowhere partno is the swap partition number according to
parted /dev/vda, (it should 2 ?)
/dev/parted /dev/vda mkpart -4G -1s. Negative numbers here are references from the end of the disk, meaning that the partition spans the last 4GiB of the disk (
-1smeans the partition ends at the last sector of disk, which is impossible as this will overwrite the secondary GPT header, so
partedwill modify the exact start/end and alignment of the partition (you'll be prompted). The partition will be created with the same number 2. So the device file will be named
/dev/vda2. You have to check it.
/etc/initramfs-tools/conf.d/resumeif any. This line specifies the partition used for hibernation, and it is identified either with
LABEL=.... You can find the swap partition UUID or label using
/etc/fstab. Just update UUID, label or partition number (depending on how the swap partition is designated in the file)
Once swap is moved away, you have to
(1) resize your root partition, which now has free space next to it. You can use command
growpart (from package
cloud-utils) which makes a partition use all the available space. If you cannot get this package on your system, you can do it manually with the subcommand
parted, telling only partition number (1?) and the END position (in blocks). Refer to
parted /dev/vda to get expected END position.
parted will prevent you from accidentally overwrite the swap.
(2) resize the filesystem (ext4 can be grown online, no need to unmount it) using
These steps will solve your issue, normally with no dataloss. However it is recommended to backup the most important data.
External links referenced by this document: