Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How to resize this partition
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

How to resize this partition

Hi,

How to resize vda4 partition after some space on vps added? I guess the problem that the system has separated partitions. reseze2fs does not work :-(

root@server:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.5G     0  1.5G   0% /dev
tmpfs           301M  4.2M  297M   2% /run
/dev/vda2        28G  2.1G   24G   8% /
tmpfs           1.5G     0  1.5G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.5G     0  1.5G   0% /sys/fs/cgroup
/dev/vda4       2.4T  1.5T  804G  66% /home
root@server:~# sudo resize2fs /dev/vda4
resize2fs 1.44.5 (15-Dec-2018)
The filesystem is already 647379968 (4k) blocks long.  Nothing to do!

Thanks!

Comments

  • Mr_TomMr_Tom Member, Host Rep

    Does the output of fdisk -l show that /dev/vda4 is bigger than df shows it as? You might need to reboot for the disk changes to take place, depending on how the VPS is setup.

  • Reboot your VPS from the panel first. Then try it again.

  • DPDP Administrator, The Domain Guy

    GParted.

    Thanked by 1jokotan
  • virtua_cloudvirtua_cloud Member, Patron Provider

    You can use cfdisk to resize the partition first, then execute resize2fs.
    We made a quick video for our users here: https://streamable.com/e9qqsc.
    Hope it helps!

    Thanked by 1RedSox
  • jokotanjokotan Member
    edited December 2020

    It was rebooted before I started this thread. As I see now by fdisk -l additional space already present.

    @Mr_Tom said:
    Does the output of fdisk -l show that /dev/vda4 is bigger than df shows it as? You might need to reboot for the disk changes to take place, depending on how the VPS is setup.

    root@server:~# fdisk -l
    The backup GPT table is not on the end of the device. This problem will be corrected by write.
    Disk /dev/vda: 3 TiB, 3221225472000 bytes, 6291456000 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
    Disklabel type: gpt
    Disk identifier: XXXXXXX-XXXXX-XXXXX-XXXX-XXXXXXXXX
    
    Device        Start        End    Sectors  Size Type
    /dev/vda1      2048       4095       2048    1M BIOS boot
    /dev/vda2      4096   58597375   58593280   28G Linux filesystem
    /dev/vda3  58597376   63838207    5240832  2.5G Linux swap
    /dev/vda4  63838208 5242877951 5179039744  2.4T Linux filesystem
    

    Interesting. It say " The backup GPT table is not on the end of the device. This problem will be corrected by write."

    https://www.golinuxcloud.com/extend-resize-primary-partition-non-lvm-linux/ look like need to do something like this. Not so easy and possible to lose data... It looks like I need to take care of a full fresh backup first.

  • Mr_TomMr_Tom Member, Host Rep

    Probably work doing something like cfdisk /dev/vda and resizing vda4 into the free space.

    Writing that might solve the GPT table warning too, resize2fs should work as intended then.

    Thanked by 1jokotan
  • dfroedfroe Member, Host Rep

    Since vda4 is at the end of your disk, it is pretty easy to extend this partition. No need for LVM etc.

    You are using GPT (instead of MBR). GPT stores a copy of the partition table at the beginning and at the end of your disk. Since your disk has been extended, there is no backup GPT at the (new) end of your disk. This is the explanation behind the (new) message you are seeing. As stated, a new backup GPT will be written by fdisk.

    You "only" have to re-create vda4, beginning at exactly the same sector (to keep your existing filesystem intact). Then you can use resize2fs to make use of the whole space.

    So basically in fdisk, note the current start sector of vda4 (63838208). Delete partition 4. Create a new partition 4, enter exactly the same sector as start, and just hit enter for the end sector, which will make the partition as large as possible. Write your changes in fdisk (which will also correct the missing backup GPT).

    Reboot your machine and run resize2fs on vda4. That's it.

  • jokotanjokotan Member
    edited December 2020

    @Mr_Tom said:
    Probably work doing something like cfdisk /dev/vda and resizing vda4 into the free space.

    cfdisk solution looks like pretty simple vs. fdisk described by @dfroe
    It request only to enter dev/vda4 new size. And it show default value New size: 2.9T. Seems it is correct, but not sure that this default suggestion from cfdisk will not break my system. Is it safe to fill new size like "2.9T"? I have in mind to change it to New size: 6291455966S.

    6291455966 - this value from "end" for "Free space" at cfdisk, and 6291456000 is actual disk end.

    Seems that 34 bytes (6291456000-6291455966) is GPT backup at the end of the disk mentioned by @dfroe

    Edit: looks like a bad idea with 6291455966S. Not enough space for "backup GPT" header. At the start of the disk it hold 2048 sectors

  • dfroedfroe Member, Host Rep

    In the end fdisk and cfdisk are doing exactly the same thing - changing the partition table. cfdisk is more modern and convenient while fdisk is the classical tool most likely everybody knows for ages, requiring more manual steps and thus knowledge of what you are doing.

    You won't break your filesystem if your partition always starts at exactly the same sector and the size of the partition (end sector) never shrinks. Always double check this simple rule by reviewing the partition table before writing any changes.

    Regarding the end sector, simply use the default suggestion from (c)fdisk. There will be some space left for backup GPT and most likely 4K alignment. You usually don't need to care about this. (c)fdisk will not let you make your partition to large.

    Thanked by 2RedSox jokotan
  • jokotanjokotan Member
    edited December 2020

    @dfoe thanks, now i feel much safer

    Thanks you all! Resized! And without second reboot :-)

    Thanked by 2RedSox virtua_cloud
Sign In or Register to comment.