Visit Counter

Saturday, May 26, 2018

How to add new drives to a VirtualBox virtual machine (Oracle VM)



1. Open Oracle Virtual Box Manager
2. Select shutdown virtual machine like ( RAC01 VM)
3. Goto Setting option
4. Storage option select add hard disk
5. define name & size of disk.
6. reboot machine
7. Login as root




Run this command and make note of the sdx entries




[root@rac01 dev]# ls /dev/sd*


/dev/sda   /dev/sda2  /dev/sda4  /dev/sda6  /dev/sdb1  /dev/sdc1  /dev/sdd1
/dev/sda1  /dev/sda3  /dev/sda5  /dev/sdb   /dev/sdc   /dev/sdd   /dev/sde
[root@rac01 dev]#
[root@rac01 dev]#


Once rebooted you should see you have an unpartitioned hard-drive ready to go. To check this run from the terminal:



[root@rac01 dev]# fdisk -l

Disk /dev/sda: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c50f9

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3825    30720000   83  Linux
/dev/sda2            3825       15298    92160000   83  Linux
/dev/sda3           15298       16828    12288000   83  Linux
/dev/sda4           16828       19582    22117376    5  Extended
/dev/sda5           16829       18231    11264000   83  Linux
/dev/sda6           18231       19506    10240000   82  Linux swap / Solaris

Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x639a1683

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        6527    52428096   83  Linux

Disk /dev/sdc: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2735c183

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        6527    52428096   83  Linux

Disk /dev/sdd: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1b50aafd

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        6527    52428096   83  Linux

Disk /dev/sde: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sde doesn't contain a valid partition table
[root@rac01 dev]#





To fix this we need to first partition the new drive.


[root@rac01 Desktop]# fdisk /dev/sde

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc8f14ebc.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-13054, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054):
Using default value 13054

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@rac01 Desktop]# fdisk -l

Disk /dev/sda: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c50f9

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3825    30720000   83  Linux
/dev/sda2            3825       15298    92160000   83  Linux
/dev/sda3           15298       16828    12288000   83  Linux
/dev/sda4           16828       19582    22117376    5  Extended
/dev/sda5           16829       18231    11264000   83  Linux
/dev/sda6           18231       19506    10240000   82  Linux swap / Solaris

Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x639a1683

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        6527    52428096   83  Linux

Disk /dev/sdc: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2735c183

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        6527    52428096   83  Linux

Disk /dev/sdd: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1b50aafd

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        6527    52428096   83  Linux

Disk /dev/sde: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc8f14ebc

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1       13054   104856223+  83  Linux
[root@rac01 Desktop]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              29G  5.5G   22G  20% /
tmpfs                 1.9G  639M  1.3G  34% /dev/shm
/dev/sda5              11G  179M  9.9G   2% /opt
/dev/sda2              87G   22G   61G  26% /ora
/dev/sda3              12G  662M   11G   6% /tmp
122new                1.8T  1.2T  630G  66% /media/sf_122new
pack-RAC              1.8T  1.2T  630G  66% /media/sf_pack-RAC
/dev/sr0               62M   62M     0 100% /media/VBOXADDITIONS_4.3.6_91406



Good so we now have a partition at /dev/sde that we can now format with our chosen filesystem.
To do this run:



[root@rac01 Desktop]# mkfs -t ext4 /dev/sde
mke2fs 1.41.12 (17-May-2010)
/dev/sde is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 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, 7962624, 11239424, 20480000, 23887872

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

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@rac01 Desktop]#








[root@rac01 Desktop]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              29G  5.5G   22G  20% /
tmpfs                 1.9G  639M  1.3G  34% /dev/shm
/dev/sda5              11G  179M  9.9G   2% /opt
/dev/sda2              87G   22G   61G  26% /ora
/dev/sda3              12G  662M   11G   6% /tmp
122new                1.8T  1.2T  630G  66% /media/sf_122new
pack-RAC              1.8T  1.2T  630G  66% /media/sf_pack-RAC
/dev/sr0               62M   62M     0 100% /media/VBOXADDITIONS_4.3.6_91406


Great, now all we need to do is mount our fresh filesystem. In my case I'm going to mount it at /home as I've already moved the original /home directory out of the way.


[root@rac01 Desktop]# mount /dev/sde /home

[root@rac01 Desktop]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              29G  5.5G   22G  20% /
tmpfs                 1.9G  639M  1.3G  34% /dev/shm
/dev/sda5              11G  179M  9.9G   2% /opt
/dev/sda2              87G   22G   61G  26% /ora
/dev/sda3              12G  662M   11G   6% /tmp
122new                1.8T  1.2T  630G  66% /media/sf_122new
pack-RAC              1.8T  1.2T  630G  66% /media/sf_pack-RAC
/dev/sr0               62M   62M     0 100% /media/VBOXADDITIONS_4.3.6_91406
/dev/sde               99G  188M   94G   1% /home



[root@rac01 Desktop]# cd /home
[root@rac01 home]# ls
lost+found



[root@rac01 home]# chown -R oracle:oinstall /home
[root@rac01 home]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              29G  5.5G   22G  20% /
tmpfs                 1.9G  639M  1.3G  34% /dev/shm
/dev/sda5              11G  179M  9.9G   2% /opt
/dev/sda2              87G   22G   61G  26% /ora
/dev/sda3              12G  662M   11G   6% /tmp
122new                1.8T  1.2T  630G  66% /media/sf_122new
pack-RAC              1.8T  1.2T  630G  66% /media/sf_pack-RAC
/dev/sr0               62M   62M     0 100% /media/VBOXADDITIONS_4.3.6_91406
/dev/sde               99G  188M   94G   1% /home



[root@rac01 home]#