Jumat, 07 Januari 2022

How to permanently mount disk on Linux VPS

How to permanently mount disk on Linux VPS

 If you want additional disk capacity on a VPS, usually the provider already provides it, you just need to order. After the additional disk is paid for, then mounting the additional disk to an existing server. In this tutorial I will show you how to permanently mount a disk on a Linux VPS.

The meaning here is permanent, when the server is rebooted, the disk (file system) is still detected (read) by the Linux system.


With root level, follow these steps:

1. Check file system

df -h

Output

Filesystem     1K-blocks     Used Available Use% Mounted on
udev             8153480        0   8153480   0% /dev
tmpfs            1637100     9504   1627596   1% /run
/dev/sda1      229698892 65885836 152075304  31% /
tmpfs            8185484        0   8185484   0% /dev/shm
tmpfs               5120        0      5120   0% /run/lock
tmpfs            8185484        0   8185484   0% /sys/fs/cgroup

In the description of the results of the disk file system check, only /dev/sda1 is detected ( just an example, because the name can be different, for example: /dev/sda2 ), even though there are other block devices, if you check with the command list block device: it lsblkwill be visible.

2. Check list block devices

lsblk

Result

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223.6G  0 disk
|-sda0   8:1    0     1M  0 part
`-sda1   8:2    0 223.6G  0 part /
sdb      8:16   0 931.5G  0 disk
`-sdb1   8:17   0 931.5G  0 part
sr0     11:0    1  1024M  0 rom

Description of the results of check block devices, there is a partition on /dev/sdb1.

We can also confirm by checking block devices ID

blkid



Result

/dev/sda1: UUID="6adff89c-3178-4090-a98f-d16bc4704590" TYPE="ext4" PARTUUID="d9b163d1-0885-401d-a818-820c4drc2ea4"
/dev/sdb1: UUID="5a7db959-0c6d-4abe-9fa9-d6fad78d4880" TYPE="ext4" PARTUUID="8016131f-8c9d-4238-8a16-1266ad5era67"

Description of block devices and UUID will appear. We will use the value of this UUID to create a new row in the file system table or fstablater.

3. Mounting

I gave an example from the description of the additional disk output above, for example, the name of the block devices /dev/sdb1and I will mount it to a directory /backup(free directory name).

Now we will mount /dev/sdb1/to /backup. Follow these steps:

mount command /dev/sdb1/to/backup

mount /dev/sdb1 /backup

4. Mount permanen

After successfully mounting, so that it is permanent and can be read when the machine is restarted, register it to /etc/fstab

nano /etc/fstab

Add a new line according to the UUID of the partition.

UUID=5a7db959-0c6d-4abe-9fa9-d6fad78d4880 /backup ext4 defaults 0

5. Check the file system again

df -h

Make sure there is a list/dev/sdb1 /backup

Done, hopefully useful.

If you have problems, please contact and order additional VPS disk mounting services.

Setting the time zone WIB, WITA, WIT on PHP, MySQL and Linux systems

 First we will set the time zone for the West Indonesia Region (WIB) then Central Indonesia Time (WITA) and East Indonesia Time (WIT).

With the root account follow and run the following command line:

1. Preparation

Reset current timezone settings

unlink /etc/localtime

2. Linux system time zone settings

This will set the date and time for the Linux system

For WIB

ln -s /usr/share/zoneinfo/Asia/Jakarta /etc/localtime

For WITA

ln -s /usr/share/zoneinfo/Asia/Ujung_Pandang /etc/localtime

For WIT

ln -s /usr/share/zoneinfo/Asia/Jayapura /etc/localtime

3. Setting the time zone for PHP

For the date and time in PHP we need to set it too because it usually doesn't follow the system.

Edit the PHP configuration file or php.inifind the line ; date.timezone = edit and set timezone

For WIB

date.timezone = 'Asia/Jakarta'

For WITA

date.timezone = 'Asia/Ujung_Pandang'

For WIT

date.timezone = 'Asia/Jayapura'

4. Setting the time zone for the MySQL/MariaDB database

Likewise for MySQL databases, the time and date need to be determined so that create, update and delete are accurate with the application system used.

Edit the MySQL/MariaDB configuration file, in the column [mysqld]add the following lines and specify the timezone

For WIB

default-time-zone = "+07:00"

For WITA

default-time-zone = "+08:00"

For WIT

default-time-zone = "+09:00"

5. Reboot (optional)

To make sure everything runs smoothly and the timezone is as specified, please reboot the machine. Or restart each service: Apache , Nginx , PHP and MySQL/MariaDB databases .

Done, hopefully useful.

How to archive and extract .ZST Linux files

 Zstandard is a fast compression algorithm, providing a high compression ratio. It also offers a special mode for small data, called dictionary compression .

Here's how to install Zstandard, create archives and extract .ZST files on Linux

Install Zstandard

CentOS

yum install zstd

Ubuntu

apt installl zstd

How to create a .ZST archive

The order zstd namafile_atau_folder -o nama.zst

zstd zstd

How to extract .ZST

There are two options with options -dor via commandunzstd

Example:

zstd -d namafile.zst

or

unzst namafile.zst

Zstandard is really a very powerful compression tool, we can save diskspace, for example from 900 MB TAR archive files can be compressed up to 90 MB into ZST archive .

So highly recommended before compressing to ZST:

  • Kompres file ke TAR
  • Then compress the TAR file to ZST

Well done, hopefully useful.

How to install Docker

 Guide on how to install docker on Linux for Ubuntu, Debian, CentOS and other distros using the Docker CE for Linux script to make it easier to install Docker. Here are the steps

System updates

For Debian/Ubuntu

apt update -y

For CentOS

yum update -y

Install Curl

For Debian/Ubuntu

apt install curl -y

For CentOS

yum install curl -y

Install Docker

This will download the Docker installation script and execute it

curl -fsSL https://get.docker.com | sh

The script will install docker-ce-cli docker-scan-plugin docker-ceincluding containerd.io. Wait until the process is complete.

Creating a sudo user

If you already have a sudo user, please skip this step . If not, I suggest creating a sudo user.

Here I give an example of creating a user with the name omar , and creating a password for the user omar . Run per line one by one.

For Ubuntu/Debian

adduser omar
usermod -aG sudo omar

For CentOS

adduser omar
passwd omar
usermod -aG wheel omar

Adding users to groups docker

This is intended if you login with a user other than rootwhen running a command docker(Docker command-line) so that you don't always run sudo, for example you login with user omar, add the user omarto the users group docker

usermod -aG docker omar

Test

Docker installation is complete, now let's try to run docker

docker run hello-world

The result, something like this, if successful.

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Okay, that's all for the Docker tutorial. In the future I want to learn and share about Docker, hopefully this short article is useful.

Thank you for the support friends give.

Reference:

  • https://www.docker.com
  • https://docs.docker.com