To be able to migrate your Cloud Server to VPS, you must have at least 100 MB of free space in the root and boot directories of your server. This article explains how to free up storage space on your Cloud Server so that it can be migrated.

Check available storage space

To display the free space of the entire file system, enter the following command:

[root@localhost ~]# df -h

To display the used space of the entire file system, use the following command:

[root@localhost ~]# du -sh /

Empty log files

Log files become larger and larger over time. For this reason, it is advisable to empty them if you no longer need the data they contain.

Attention
  • Make sure that you do not delete the log files. If they are deleted, this can have unforeseen effects on running services.

  • If you delete a log file, the data will be irretrievably deleted. It is then no longer possible to restore the data.

To empty log files, proceed as follows:

  • Check whether there are any log files on your Cloud Server that are taking up a lot of memory. To do this, enter the following command:

    [root@localhost ~]# ls -l -S -h /var/log


    After entering the command, the log files of the system programmes are displayed in the /var/log directory. Example:

    [root@localhost ~]# ls -l -S -h /var/log
    total 351M
    -rw-rw----. 1 root utmp 183M May 7 09:12 btmp
    -rw-------. 1 root root 162M May 7 09:22 secure
    -rw-------. 1 root root 2.8M May 7 09:22 messages
    -rw-r--r--. 1 root root 1.0M Apr 11 21:03 dnf.log.1
    -rw------- 1 root root 314K May 7 09:18 cron
    -rw-r--r--. 1 root root 312K Apr 16 10:00 dnf.librepo.log
    -rw-rw-r--. 1 root utmp 285K May 7 09:22 lastlog
    -rw-r--r-- 1 root root 128K Apr 16 10:00 dnf.log
    -rw-r--r--. 1 root root 77K Apr 16 10:00 dnf.rpm.log
    -rw-r----- 1 root root 16K May 7 08:50 cloud-init.log
    -rw------- 1 root root 15K May 7 08:50 vmware-vmsvc-root.log
    -rw-r--r--. 1 root root 15K Apr 16 08:19 hawkey.log
    -rw-r----- 1 root adm 13K May 7 08:50 cloud-init-output.log
    -rw------- 1 root root 7.7K May 7 08:50 vmware-vgauthsvc.log.0
    -rw-rw-r--. 1 root utmp 7.2K May 7 09:22 wtmp
    -rw------- 1 root root 3.9K May 7 08:50 vmware-vmtoolsd-root.log
    -rw------- 1 root root 1.3K May 7 08:50 kdump.log
    -rw-r--r-- 1 root root 253 Feb 10 2022 vmware-network.4.log
    -rw-r--r-- 1 root root 250 Mar 7 10:42 vmware-network.2.log
    -rw-r--r-- 1 root root 195 Mar 11 15:18 vmware-network.1.log
    -rw-r--r-- 1 root root 195 Feb 10 2022 vmware-network.5.log
    -rw-r--r-- 1 root root 193 Mar 7 10:37 vmware-network.3.log
    -rw-r--r-- 1 root root 193 May 7 08:50 vmware-network.log
    drwx------. 2 root root 99 Apr 16 03:31 audit
    lrwxrwxrwx 1 root root 39 Mar 7 10:39 README -> ../../usr/share/doc/systemd/README.logs
    drwxr-x---. 2 chrony chrony 6 Jan 23 14:19 chrony
    drwx------. 2 root root 6 Feb 10 2022 private
    drwxr-x---. 2 sssd sssd 6 Feb 12 10:01 sssd
    -rw-------. 1 root root 0 Feb 10 2022 maillog
    -rw-------. 1 root root 0 Feb 10 2022 spooler
    -rw-------. 1 root root 0 Feb 10 2022 tallylog

  • Open the desired log file with the vi editor and check whether you still need the content. To do this, adapt the following command and then enter it:

    [root@localhost ~]# vi /var/log/DATEINAME


    Example:

    [root@localhost ~]# vi /var/log/dnf.log

  • If you do not need the entries in the respective log file, you can empty the log files. The file name remains unchanged. To empty a log file, replace the placeholder in the command listed below and then enter the command.

    [root@localhost ~]# > /var/log/DATEINAME.log


    Example:

    [root@localhost ~]# > /var/log/dnf.log.1

Delete backup files in Plesk

Plesk offers the option of creating regular backups of your entire server as well as backups of individual user accounts with websites or of individual subscriptions. If you regularly create backups with Plesk, we recommend that you delete backups that are no longer required.

You can find instructions in the following article:

Removing backup files from the server

Delete large files that are no longer required

To free up more storage space, you can delete large files that are no longer required. To do this, proceed as follows:

  • Change to the desired directory.
  • To display a list of the files in the directory, enter the following command:

    [root@localhost DIRECTORY]# du --block-size=MiB --max-depth=1 | sort -n


    Example:

    [root@localhost var]# du --block-size=MiB --max-depth=1 | sort -n
    1MiB ./crash
    1MiB ./local
    1MiB ./mail
    1MiB ./opt
    1MiB ./snap
    1MiB ./spool
    3MiB ./backups
    120MiB ./www
    141MiB ./cache
    672MiB ./tmp
    2231MiB ./lib
    4157MiB ./log
    7321MiB .

  • Delete files that are no longer required. To do this, customise one of the commands listed below and then enter it:

    Delete single file:

    [root@localhost ~]# rm DATEINAME


    Delete multiple files:

    [root@localhost ~]# rm DATEINAME1 DATEINAME2


    Delete read-only files:

    [root@localhost ~]# rm -i DATEINAME


    Delete files and subfolders in a specific folder

    [root@localhost ~]# rm -r DIRECTORYNAME/*

Uninstalling programmes that are no longer required

To free up additional memory space, you can uninstall programmes that are no longer required. In the commands listed below, replace the placeholder PAKETNAME with the name of the package you wish to uninstall.

CentOS 7

[root@localhost ~]# sudo yum remove PAKETNAME


Centos Stream 8 and 9, Rocky Linux 8 and 9 and AlmaLinux 8 and 9

[root@localhost ~]# sudo dnf remove PAKETNAME


Debian / Ubuntu

[root@localhost ~]# sudo apt purge PAKETNAME

Delete old kernels

Over time, old kernels accumulate due to updates. Depending on their number, these old kernels can take up a lot of memory. To delete old kernels, proceed as follows:

  • To check the kernel version in use, enter the following command:

    [root@localhost ~]# uname -r

  • To display a list of all kernel packages installed on the system, enter the following command:

    Debian / Ubuntu

    [root@localhost ~]# dpkg --list 'linux-image-*'


    CentOS, Rocky Linux and AlmaLinux

    [root@localhost ~]# rpm -qa kernel

Attention

CentOS: Make sure that the latest and penultimate new CentOS kernel remains installed to ensure the stability of the system.

Other distributions: Ensure that the latest kernel remains installed to ensure system stability.

  • To uninstall a kernel, customise the following command and then enter it:


    Debian / Ubuntu

    [root@localhost ~]# apt-get remove kernel-image-x-xx-xx


    CentOS, Rocky Linux and AlmaLinux

    [root@localhost ~]# yum remove kernel-x.x.x-xxx

  • Check the available memory. To do this, enter the following command:

    [root@localhost ~]# df -h