How do I enlarge / sda2 and / sda3 on Linux?

Wo
6

I have installed a larger SSD disk in my notebook.

I now have enough storage space. Before that I cloned the old, small SSD with CloneZilla as an image. Then I restored this image with all partitions on the new SSD. However, the partition sizes have remained the same. The remaining free space is at the end of the partition table.

Please refer:

fdisk -l
Hard disk / dev / sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Hard drive model: Samsung SSD 870
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 label type: dos
Hard disk identifier: 0xf608aae7

Device Boot Start End Sectors Size Kn Typ
/ dev / sda1 * 2048 1026047 1024000 500M 83 Linux
/ dev / sda2 1026048 161503231 160477184 76.5G 83 Linux
/ dev / sda3 161503232 213583871 52080640 24.8G 83 Linux
/ dev / sda4 213583872 234441647 20857776 9.9G 82 Linux Swap / Solaris

How do I increase / sda2 and / sda3? I want to increase sda3 by 20GB and sda2 by the remaining free space. Is that possible with resize2fs?

Sh

Parted

Wo

I want to do this out of CloneZilla's Live USB system. Would that also work with resize2fs? / sda2 and / sda3 are formatted ext4.

Sh

Yes. Together with growpart or fdisk.

parted does both together in one go: enlarge partition and enlarge filesystem.

Mo

Clear. Gparted is also just a front end for command line tools like resize2fs. You just have to know exactly what you are doing, parted and gparted do that for you to a large extent. I don't know how it works with the live system from CloneZilla, but with the Debian live installation systems you can easily install gparted: apt-get update; apt-get install gparted.

mo

When cloning a disk, of course, the partition table is also adopted.
No wonder that it is then also available on the new record.
The disadvantage of this method is that you still only have the MBR format, but not the one with GPT.
Should it still be possible, I would create a GPT on the new SSD and repartition it. Linux then e.g. Reinstall a 32GB partition and distribute your own data from the old SSD to new partitions as you wish.
This is then very easy with cp.
Also note that with Linux you can also mount directories from "somewhere" to "somewhere". This also solves any space problem.

Wo

I got it baked with the live USB from the newest Ubuntu. It's amazing what you have to calculate if you would do it manually with parted, fdisk and resize2fs. O_O