• Arun Kumar

Mount Hard Disk in Linux

In this article we will be looking at mounting external hard drive in Linux onto a directory. This can be achieved by adding a hard disk to virtual machine, formatting the disk and mounting the disk on a specific Linux directory.



Add hard disk virtual-box

Shutdown the VM >> go to settings >> select storage and add new HDD. Give the HDD size as to how much space you want to add.


Format disk

Start the VM, and now it’s time to create one single partition on the newly added disk

# fdisk -l
-- select the name of the newly added hard disk. look at the size

# fdisk /dev/xvdb

n                        --> to create new partition
-- hit enter
-- hit enter
-- hit enter
-- hit enter
w                        --> to save newly created partition

Run below command to re-discover partitions without re-booting the server

partprobe

Format the newly created partition

mkfs.xfs <partition_name>

Mount disk

Once you have created a full partition on the new hard disk, create a directory where you will mount this disk

mkdir /u03

List the exact name of the partition using below command

# fdisk -l /dev/xvdb

Generally the partition will always be <disk_name> + 01 for first partition. Example, in our case, the partition name is /dev/xvdb01. Mount the partition on /u03 directory

# mount /dev/xvdb01 /u03

Verify the mount is done

df -h
lsblk
mount -a
lsblk

Update /etc/fstab file

We want the new hard disk to mount on /u03 even after server restart. To achieve that, we must add entry to /etc/fstab file. First thing, find the UUID of the hard disk

ls -lrt /dev/disk/by-uuid

Copy the UUID from above output for /dev/xvdb disk and add below entry to /etc/fstab file. Make sure to change the UUID as per your server details

vi /etc/fstab

UUID=2a20cd87-f89e-4c59-945f-3700d8d1e08f /u03 xfs defaults 0 0

361 views

Recent Posts

See All

Basic Linux Commands

This article describes basic Linux commands that you must know as a system or database administrator. Below commands in Linux help you manage any Linux server fast and smoothly. Linux Command List Che

Linux Firewall with iptables and firewalld

In this article will be covering details regarding iptables and firewalld which helps in Linux firewall management. We will also be looking at how to enable specific ports (1521 for Oracle) inside ipt

Passwordless SSH in Linux

Every time you ssh from one Linux server to another, you need to enter target server user's password. We can also setup passwordless ssh in Linux between two Linux servers so that you don't have to en

  • Facebook
  • Twitter
  • YouTube
  • Instagram

© 2020 by DBA Genesis