
If you’re running a server with CloudPanel and need more disk space to accommodate your growing data, this tutorial will guide you through the process of adding additional disk space to your server.
Format a new disk in Linux:
- Connect the new disk to your Linux server.
- Open a terminal or shell.
- Use the lsblk command to list all available disks and identify the new disk. It is usually identified as /dev/sdX, where X represents a specific letter assigned to the disk.
Sample output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
└─sda1 8:1 0 20G 0 part /
sdb 8:16 0 50G 0 disk
- Before formatting, ensure that there is no important data on the disk, as formatting will erase all existing data.
- Run the following command to format the disk with the ext4 file system (replace /dev/sdX with the appropriate disk identifier).
Sample output:
$ sudo mkfs.ext4 /dev/sdb
Creating filesystem with 13107200 4k blocks and 3276800 inodes
Filesystem UUID: 7f1c72b0-0ef4-4a2c-b0d1-7f5eae3a5d28
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done
- Confirm the formatting process by typing “y” when prompted.
- Once the format is complete, the new disk is ready to be mounted.
Mount the new disk at the mount point /home and transfer data:
- Create a temporary directory to copy the existing data from /home (if it exists) before mounting the new disk. Run the following command:
$ sudo mkdir /tmp/home_backup
- Copy the contents of the existing /home directory to the temporary backup directory by running the following command:
$ sudo cp -a /home/. /tmp/home_backup/
- Now, mount the new disk at /home using the following command (replace /dev/sdX with the appropriate disk identifier).
Sample output:
$ sudo mount /dev/sdb /home
- Verify that the new disk is mounted correctly by running df -h command and checking if the mount point /home shows the new disk.
Sample output:
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 50G 23G 25G 48% /home
- If the new disk was mounted successfully, move the data from the temporary backup directory to the new disk by running the following command:
$ sudo cp -a /tmp/home_backup/. /home/
- Check that the data has been transferred correctly by verifying the contents of /home.
- A fresh CloudPanel install will have created two folders clp and mysql in /home, run the following commands to set proper ownership and permissions:
$ sudo chown -R clp:clp /home/clp/
$ sudo chown -R mysql:mysql /home/mysql/
Auto-mount the new disk on reboot by editing /etc/fstab entries:
- Open the /etc/fstab file in a text editor with administrative privileges, such as:
$ sudo nano /etc/fstab
- Before modification, the /etc/fstab file may look like this:
/dev/sda1 / ext4 defaults 0 1
/dev/sdb1 /data ext4 defaults 0 2
…
- Add an entry at the end of the file to auto-mount the new disk at /home during system boot. Use the following format:
/dev/sdb /home ext4 defaults 0 2
- After modification, the /etc/fstab file should look like this:
/dev/sda1 / ext4 defaults 0 1
/dev/sdb1 /data ext4 defaults 0 2
/dev/sdb /home ext4 defaults 0 2
…
- Save the changes and exit the text editor.
- To test if the auto-mount works without a reboot, run the following command to mount all file systems defined in /etc/fstab:
$ sudo mount -a
- Verify that the new disk is mounted at /home by running df -h command and checking the mount point.
Sample output:
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 50G 23G 25G 48% /home
- Restart your Linux server to ensure that the new disk is automatically mounted at /home during the boot process.
Following these steps, you should be able to add additional disk space to your CloudPanel server by formatting a new disk, mounting it at /home, transferring data, and configuring auto-mounting on reboot.
Read the full article
