It is a regular practice for server administrators. In most cases, large storage devices are divided into separate sections called partitions.
At first, verify that you have available space on the server for partitions.
fdisk -l
Following command will list all detected hard disks:
fdisk -l | grep '^Disk'
Choose disk or device you want to create or make partition (such as /dev/vda, /dev/vda1, /dev/sda, /dev/sdb etc). Here I will partition the disk /dev/sda (256GB) into /dev/sda1 (100GB) and /dev/sda2 (156GB). Please follow the following steps to create partitions accordingly:
- Run
fdisk /dev/sda
- Type ‘n’ to create a new partition (/dev/sda1)
- Select partition type (default p)
- Set partition number (default 1)
- Set First sector (default 2048)
- Set Last sector of the partition: +100G
- Type ‘p’ to view the partition.
- Then type ‘n’ to create another partition (/dev/sda2)
- Select default partition type, default partition number, default First sector and Last sector
- Type ‘p’ to view the partition.
- Type ‘w” to save the partition.
- Run the command ‘partprobe’ to have the OS detect the new partition table.
partprobe
- Format partitions with the ext4 file system
mkfs.ext4 /dev/sda1 mkfs.ext4 /dev/sda2
- Create a directory to mount the new drive, for example: /data, /backup [Learn more]
- Create directory within root
mkdir ~/data
- Create directory within /
mkdir -p /backup
- Create directory within root
- To enable persistent mounting of the file system, even after a reboot, add the following to /etc/fstab:
/dev/sda1 /mnt/data ext4 defaults 0 0 /dev/sda2 /mnt/backup ext4 defaults 0 0
fstab [Learn more]
- Directory Tree Structure In Linux [Learn more]
Leave a Reply