- Check the attached disks by using below command, verify the space
df -h
Filesystem Size Used Avail Use% Mounted on
udev 491M 0 491M 0% /dev
tmpfs 103M 771k 102M 1% /run
/dev/xvda1 8.3G 1.2G 7.1G 15% /
tmpfs 514M 0 514M 0% /dev/shm
tmpfs 5.3M 0 5.3M 0% /run/lock
tmpfs 514M 0 514M 0% /sys/fs/cgroup
/dev/loop0 102M 102M 0 100% /snap/core/9289
/dev/loop1 19M 19M 0 100% /snap/amazon-ssm-agent/1566
tmpfs 103M 0 103M 0% /run/user/1000
- Run the below to list all the available disks
sudo fdisk -l
Disk /dev/loop0: 97 MiB, 101724160 bytes, 198680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 18 MiB, 18857984 bytes, 36832 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/xvda: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb93804ca
Device Boot Start End Sectors Size Id Type
/dev/xvda1 * 2048 16777182 16775135 8G 83 Linux
Disk /dev/xvdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
In the above /dev/xvdb
is not used.
-
Run the below to make the drive ready
sudo mkfs.ext4 /dev/xvdb
-
Create directory to mount
sudo mkdir -p /var/data
-
Mount the disk
sudo mount /dev/xvdb /var/data
- Add the entry to filesystem table (fstab)
Example:
/dev/xvdb /var/data ext4 errors=remount-ro 0 2
/dev/xvdb is our disk.
/var/data is the folder we mount to attach or ‘mount’ the drive to – called a mountpoint.
ext4 is the file system we chose for the drive.
errors=remount-ro means if any disk errors are detected the file system will be mounted as read-only
0 or the fifth parameter is called the fs_freq and is used to determine which files need to be dumpted. 0 signified no dump required.
1 or the sixth paramter is called the fs_passno and is used to determin the in file system checkers are carried out at boot time.
- Add the above line in fstab file
sudo vim /etc/fstab