0

I'm running ubuntu 18 cli server and I'm totally new The server provider gave me 50G more disk space but I need to add it myself. I know how to add with removing my data and configs but I want to keep all my current data and configs.

MY DF:

root@vps81785:~# df
Filesystem     1K-blocks     Used Available Use% Mounted on
udev              493172        0    493172   0% /dev
tmpfs             100848     7884     92964   8% /run
/dev/vda1       82534960 72218004   6106508  93% /
tmpfs             504236      124    504112   1% /dev/shm
tmpfs               5120        0      5120   0% /run/lock
tmpfs             504236        0    504236   0% /sys/fs/cgroup
tmpfs             100844        0    100844   0% /run/user/0
Levi
  • 3
  • 3
  • Does this answer your question? [How to extend my root (/) partition?](https://askubuntu.com/questions/492054/how-to-extend-my-root-partition) – Pablo Bianchi Jan 21 '22 at 16:57
  • Does this answer your question? [How to resize partitions?](https://askubuntu.com/questions/126153/how-to-resize-partitions) – user68186 Jan 21 '22 at 17:22
  • @PabloBianchi That's for GUI and I'm asking about cli – Levi Jan 21 '22 at 17:56
  • Are you trying to modify the system's partitions while the system is using them? [You cannot](https://askubuntu.com/a/492066/349837) modify the structure of a mounted partition. – Pablo Bianchi Jan 21 '22 at 18:16
  • If you are using gpt partitioning you can add another one as long as not changing existing partitions. And then could use new partition as /home. To move /home uses rsync- Be sure to use parameters to preserve ownership & permissions https://help.ubuntu.com/community/Partitioning/Home/Moving & https://ubuntuforums.org/showthread.php?t=2455822&p=14010437#post14010437 Or you can create data partition(s) for data now in /home. – oldfred Jan 21 '22 at 18:50

1 Answers1

0

Please make sure you have a backup before you the following.

You need to first increase the size of the partition, and then the size of the file system in it.

I find resizing partitions easiest with cfdisk. So it would probably be sudo cfdisk /dev/sda (but the /dev/sda could be different, look into /etc/fstab to find out your root partition device).

cfdisk should show you free space after the root partition (assuming it's /dev/sda1). Choose resize at the bottom. It will automatically propose the new maximum possible size. Write the changes and quit cfdisk.

Once that's done, best do a reboot, so that the partition table is re-read.

Then resize your filesystem. If it's the usual ext4, it's as simple as resize2fs /dev/sda1.

nagelp
  • 383
  • 2
  • 8
  • Thank you I've also updated the question with more details. – Levi Jan 21 '22 at 16:48
  • Ok, so with the `df` output now we know /dev/vda1 is your root partition. So when you do `sudo cfdisk /dev/vda` you should see the empty space below the /dev/vda1 partition. Please proceed as I've written in my answer above, just using 'vda' wherever I wrote 'sda'. – nagelp Jan 21 '22 at 19:29