1

We have a dedicated server with OVH. We can access the server via SSH and WHM Cpanel. We want to increase the size of the /dev/sda2 partition. It is only 20 GB. And running out of space frequently (every other day). We want to increase the size to at least to 50GB. How can we do it. Can you please provide technical guidelines to increase the space on the /dev/sda2the partition without disrupting the files. We have several websites hosted in that server, so we don't want to disrupt the live websites, but we want to increase the space in that disk.

After logging in to the server as root and SSH ; We have used df -h to see how much space is left. as you can see from the screenshot /dev/sda2 has only 20 gb space and out of which 17Gb is full.

enter image description here

we are not knowledgeable enough in server administration and Linux, so we cannot get much information from the similar type questions.

Additional information:

/var/log is filling up all the space. We clear the folder as temporary fix.

enter image description here

karel
  • 2,030
Bashabi
  • 155
  • 1
    Just my 2 cents: if you got no idea how to manage a linux server, maybe you shouldn't be operating one. Seeing as this server seems to run without lvm, you will need to repartition the harddrive (sda). – Panki Jan 29 '20 at 11:06
  • 3
    Please do not post pictures of text. Post the text. – Paulo Tomé Jan 29 '20 at 11:07
  • Yes I agree. Currently we do not have anyone to manage it. And OVH whom we got the server does not provide any support at all. We are willing to hire someone for a day or week who has experience in that. But we do not know where to look and how to decide the right person – Bashabi Jan 29 '20 at 11:09
  • @Panki - Does re partitioning (sda) will cause any disruption to the data? We are willing to hire some one for the job . Can you please guide us where to look for a freelancer and how to decide the right person. – Bashabi Jan 29 '20 at 11:15
  • If you do it wrong, yes it will. And no, I will not do your HR work. – Panki Jan 29 '20 at 12:27
  • 2
    There is no reason to be rude. Thanks – Bashabi Jan 29 '20 at 13:12

1 Answers1

2

In Linux nearly everything is possible. The main question is, what is the reason, and what is the goal.

Your sda disk has two main partition: sda2 as / (root of the filesystem) and sda3 as /home/ . There would be some swap partition (may be sda1), too. In such case, you cannot simply do any repartitioning, without stopping your system for at least hours. But there is more simple way: Try to investigate, what directory grows so quickly. You can do that with du command:

du /* -sh

it will take some time, but I can bet the most growing directory should be /var/ , and mainly due to its /var/log/ subdirectory. Hence you can save you time asking the system:

du /var/* -sh

If it is so, you can create new subdirectory var/log inside the /home/ directory, because this is on the biggest partition.

mkdir -p /home/var/log

Then copy all content of the of the /var/log directory into the new one

cp --recursive /var/log/* /home/var/log/

Then comes the most delicate moment: you must disable the current /var/log/ directory e.g. rename it to /var/log_old/ and immediately create symlink /var/log -> /home/var/log. It could be fine to look at some man pages to know, what the symlink realy is. You can do that with:

mv /var/log /var/log_old && ln -s /home/var/log /var/log

If everything gone well, your system will continue to write all the logs into the new place. The second question is, why you save so much logs. The bad reason could be, your system annonces you lot of errors. In that case you definitely must analyse the error logs, find the problem and remove it. The not too bad reason could be, your system is set to log too deep annonces, warnings etc. You can try to set your system to be less verbose or you can reconfigure your logrotate subsystem to keep less history.

Please! be carefull with this described method, choose the time of minimum activity.

schweik
  • 1,250
  • Thank you so much. Yes . you are right. this is due to var/log subdirectory growing fast. – Bashabi Jan 29 '20 at 14:08
  • mv /var/log /var/log_old && ln -s /home/var/log /var/log - shall I run this command after creating symlink with this - /var/log -> /home/var/log – Bashabi Jan 29 '20 at 14:09
  • 1
    /var/log -> /home/var/log is the graph only. The command to create the symlink is the ln -s .... It must be set at the end! The last command row contents two command mv and ln. The symbol && says: do the next command only if the first command succesfully ended. – schweik Jan 29 '20 at 14:16
  • Okay.. Thank you .. just to be clear... /var/log -> /home/var/log - is not a command. right.? Sorry for such a silly question. – Bashabi Jan 29 '20 at 14:26
  • 2
    You understand it well! No problem, we all started from the green table. You are welcome. – schweik Jan 29 '20 at 14:31
  • Hi Sorry to bother you again. Our server is full again and this time its not the var/log which is the largest folder . But the /var folder is almost 6 GB files in it. can you tell me which folders inside /var/ are okay t o clear. the biggesst folder inside var/ are var/cpanel (3.2GB); var/cache(1052MB) and var/softaculous (497M) . Are these folders are okay to clear? I have also asked the question here. https://unix.stackexchange.com/questions/565895/what-folder-contents-are-okay-to-delete-from-sda2-var-folder – Bashabi Feb 06 '20 at 10:34
  • I can recommend again: you have to move alle the content of /var/* directory to /home/var/* , then "disable" the directory /var/ by rename it to /var-old/ and immediately create the soft link named /var/ which links to the new location /home/var/ . This gives you time to investigate each /var/ subdirectory what it server for, and reconfig its user-application to produce less garbage. Usually the content of /var/cache/ is used temporarily, but you cannot delete the content of subdir simply by rm because the application which use it, may crash if it cannot use even empty files in it. – schweik Feb 06 '20 at 12:46