Add Hard disk in VirtualBox and Disk format and Mount Steps on Linux

How to Add Hard disk in VirtualBox and Disk format and Mount Steps on Linux: In this article we are going to discuss about How to Add Hard disk in VirtualBox and Disk format and Mount Steps on Linux.

Note:

After installing Oracle linux 7.8 operating system, I want to prepare this server for Oracle database installation. To do this, I will install Oracle database software on new disk on the server, so i should add a disk to Virtualbox and Linux.

To add a disk, it is shut down by using shutdown -h now command from within the virtual machine or by turning OFF the Power on Virtualbox. Then, 2 disks are added.

Follow below steps to add a disk and mount :

add_hard_disk_1
raw disk add for asmdisk
raw disk add for asmdisk
raw disk add for asmdisk
raw disk add for asmdisk

The second disk to be added is going through the same steps above.

Now you can see two RAW disks are addedAfter you create both disks, the disks should look like the following on the Virtualbox Storage tab.

raw disk add for asmdisk

Now two disks are added and open the server via Virtualbox. When lsblk is checked when the server is turned on, you can see that the two newly added disks are /dev/sdb and /dev/sdc.

raw disk add for asmdisk

Here we will partition /dev/sdb with the following steps and mount the partition as /u03.

[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xa380bd4c.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x38374a34.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#
[root@localhost ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb      8:16   0   20G  0 disk
└─sdb1   8:17   0   20G  0 part /u03
sr0     11:0    1 58.3M  0 rom  /run/media/prasanta/VBox_GAs_6.1.18
sdc      8:32   0   20G  0 disk
└─sdc1   8:33   0   20G  0 part
sda      8:0    0  100G  0 disk
├─sda4   8:4    0    1K  0 part
├─sda2   8:2    0   35G  0 part /u01
├─sda7   8:7    0    4G  0 part [SWAP]
├─sda5   8:5    0    5G  0 part /home
├─sda3   8:3    0   20G  0 part /
├─sda1   8:1    0    1G  0 part /boot
├─sda8   8:8    0   30G  0 part /u02
└─sda6   8:6    0    5G  0 part /tmp
[root@localhost ~]#

This disk that we partition with the Fdisk tool is formatted in ext4 format as follows.

[root@localhost ~]# mkfs -t ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242624 blocks
262131 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

[root@localhost ~]#

Mount the formatted /dev/sdb1 disk in linux with the following steps.

[root@localhost ~]# mkdir /u03
[root@localhost ~]#
[root@localhost ~]# mount -t ext4 /dev/sdb1 /u03
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.5G     0  1.5G   0% /dev
tmpfs           1.5G     0  1.5G   0% /dev/shm
tmpfs           1.5G  9.3M  1.5G   1% /run
tmpfs           1.5G     0  1.5G   0% /sys/fs/cgroup
/dev/sda3        20G   11G  9.5G  53% /
/dev/sda2        35G   33M   35G   1% /u01
/dev/sda8        30G   33M   30G   1% /u02
/dev/sda6       5.0G   33M  5.0G   1% /tmp
/dev/sda5       5.0G   37M  5.0G   1% /home
/dev/sda1      1014M  210M  805M  21% /boot
tmpfs           300M     0  300M   0% /run/user/0
network_drive   200G  128G   73G  64% /media/sf_network_drive
tmpfs           300M   12K  300M   1% /run/user/42
/dev/sdb1        20G   45M   19G   1% /u03
[root@localhost ~]#
[root@localhost ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb      8:16   0   20G  0 disk
└─sdb1   8:17   0   20G  0 part /u03
sr0     11:0    1 58.3M  0 rom
sdc      8:32   0   20G  0 disk
sda      8:0    0  100G  0 disk
├─sda4   8:4    0    1K  0 part
├─sda2   8:2    0   35G  0 part /u01
├─sda7   8:7    0    4G  0 part [SWAP]
├─sda5   8:5    0    5G  0 part /home
├─sda3   8:3    0   20G  0 part /
├─sda1   8:1    0    1G  0 part /boot
├─sda8   8:8    0   30G  0 part /u02
└─sda6   8:6    0    5G  0 part /tmp
[root@localhost ~]#

/u03 disk is mounted on the linux server, but it will not automatically mount when the server restart. For auto-mount, you need to add entry in /etc/fstab with vi as follows.

[root@localhost ~]# vi /etc/fstab
[root@localhost ~]#
[root@localhost ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Mar 20 18:03:10 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9bfd803a-1d9f-450c-84a2-d2bfefc09ecb /                       xfs     defaults        0 0
UUID=73796cd7-bd49-4753-8dec-e8b8843e1717 /boot                   xfs     defaults        0 0
UUID=ac7d507b-4d98-4d41-8c9d-9a7201b2b41b /home                   xfs     defaults        0 0
UUID=d223d382-bf5a-4446-bc91-076277ae842d /tmp                    xfs     defaults        0 0
UUID=c6496416-ea0e-4eda-85d8-17ab8b55119b /u01                    xfs     defaults        0 0
UUID=a9b1c1be-45d9-461a-8029-cf11e02fde93 /u02                    xfs     defaults        0 0
UUID=d329baed-46cf-433d-8aa6-fc070b67113a swap                    swap    defaults        0 0

/dev/sdb1 /u03 ext4 defaults 0 0
[root@localhost ~]#

I hope my written content will helped you. Your suggestions/feedback are most welcome from orakldba.com.
Keep learning… Have a great day!!!
Please comment here for your any query related to above content. You can write to mail me through : orakldba@gmail.com.

1 thought on “Add Hard disk in VirtualBox and Disk format and Mount Steps on Linux”

Leave a Comment