Score:0

How to expand a root partition without of removing any data?

kp flag

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
vn flag
Does this answer your question? [How to extend my root (/) partition?](https://askubuntu.com/questions/492054/how-to-extend-my-root-partition)
ar flag
Does this answer your question? [How to resize partitions?](https://askubuntu.com/questions/126153/how-to-resize-partitions)
Levi avatar
kp flag
@PabloBianchi That's for GUI and I'm asking about cli
vn flag
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.
oldfred avatar
cn flag
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.
Score:0
eg flag

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.

Levi avatar
kp flag
Thank you I've also updated the question with more details.
eg flag
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'.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.