How to add additional hard drive on Linux Guest in Vmware

Use df command to check the disk pace usage information of your file system

[root@db11gr2 oracle]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_db11gr2-lv_root
45038112 28408380 14359880 67% /
tmpfs 4194304 260 4194044 1% /dev/shm
/dev/sda1 495844 48558 421686 11% /boot
shmfs 4194304 260 4194044 1% /dev/shm

To see more information about disk space usage with Mount point use df with -a option as below.

[oracle@db11gr2 u02]$ df -a
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_db11gr2-lv_root
45038112 29302112 13466148 69% /
proc 0 0 0 – /proc
sysfs 0 0 0 – /sys
devpts 0 0 0 – /dev/pts
tmpfs 4194304 420 4193884 1% /dev/shm
/dev/sda1 495844 48558 421686 11% /boot
shmfs 4194304 420 4193884 1% /dev/shm
none 0 0 0 – /proc/sys/fs/binfmt_misc
vmware-vmblock 0 0 0 – /var/run/vmblock-fuse
sunrpc 0 0 0 – /var/lib/nfs/rpc_pipefs

To view all available Partition use the fdisk command with -l option

[root@db11gr2 oracle]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00067cb8

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM

Disk /dev/sdb: 11.8 GB, 11811160064 bytes
255 heads, 63 sectors/track, 1435 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: 0x0a0d039e

Device Boot Start End Blocks Id System

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xec4c5b96

Device Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 83 Linux

Disk /dev/dm-0: 46.9 GB, 46850375680 bytes
255 heads, 63 sectors/track, 5695 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/dm-0 doesn’t contain a valid partition table

Disk /dev/dm-1: 6308 MB, 6308233216 bytes
255 heads, 63 sectors/track, 766 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/dm-1 doesn’t contain a valid partition table

I have total 3 Partition, sda, sdb, sdc. Now I am adding one additional SCSI drive on my Linux Guest from Vmware. Right click on the running machine and select settings
from the Hardware tab click on Add and select hard drive from the list and click next then click on Create New Virtual Disk then click on SCSI and click next then specify the Disk capacity here I am gonna put 20GB then click on store

virtual disk as single file then specify virutal hard drive name and click on Finish.

Now since the virtual machine is running you will not be able to see the hard drive which you have added as you can see from the output below it has not yet detected the Virtual hard drive which we added.

[root@db11gr2 oracle]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00067cb8

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM

Disk /dev/sdb: 11.8 GB, 11811160064 bytes
255 heads, 63 sectors/track, 1435 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: 0x0a0d039e

Device Boot Start End Blocks Id System

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xec4c5b96

Device Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 83 Linux

Disk /dev/dm-0: 46.9 GB, 46850375680 bytes
255 heads, 63 sectors/track, 5695 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/dm-0 doesn’t contain a valid partition table

Disk /dev/dm-1: 6308 MB, 6308233216 bytes
255 heads, 63 sectors/track, 766 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/dm-1 doesn’t contain a valid partition table

Now to rescan the bus without restarting the machine run the below command

[root@db11gr2 oracle]# echo “- – -” > /sys/class/scsi_host/host2/scan

you can see it has detected a new hard drive as sdd in the last few lines of the output below

[root@db11gr2 oracle]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00067cb8

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM

Disk /dev/sdb: 11.8 GB, 11811160064 bytes
255 heads, 63 sectors/track, 1435 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: 0x0a0d039e

Device Boot Start End Blocks Id System

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xec4c5b96

Device Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 83 Linux

Disk /dev/dm-0: 46.9 GB, 46850375680 bytes
255 heads, 63 sectors/track, 5695 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/dm-0 doesn’t contain a valid partition table

Disk /dev/dm-1: 6308 MB, 6308233216 bytes
255 heads, 63 sectors/track, 766 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/dm-1 doesn’t contain a valid partition table

Disk /dev/sdd: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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/sdd doesn’t contain a valid partition table

Now lets create a partition using fdisk command

[root@db11gr2 oracle]# fdisk /dev/sdd

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x5f05b351.
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help):

Command (m for help): p

Disk /dev/sdd: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x5f05b351

Device Boot Start End Blocks Id System

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

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

Calling ioctl() to re-read partition table.
Syncing disks.

Now format the Partion as Ext4 File system using mkfs.ext4

[root@db11gr2 oracle]# mkfs.ext4 /dev/sdd4
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
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

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

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

Now since the partition is created lets make a directory and mount the disk on it.

[root@db11gr2 oracle]# mkdir /u02
[root@db11gr2 oracle]# mount /dev/sdd4 /u02

As I am using this newly created parition for testing Oracle Database i will change the ownership to user Oracle and group dba
[root@db11gr2 oracle]# chown oracle:dba /u02

Lets check if user Oracle can create files on this.

[root@db11gr2 oracle]# exit
exit
[oracle@db11gr2 ~]$ cd /u02
[oracle@db11gr2 u02]$ touch test
[oracle@db11gr2 u02]$ touch test2

[oracle@db11gr2 u02]$ ls -ltr
total 16
drwx—— 2 root root 16384 Mar 31 16:15 lost+found
-rw-r–r– 1 oracle oinstall 0 Mar 31 16:16 test
-rw-r–r– 1 oracle oinstall 0 Mar 31 16:16 test2

[oracle@db11gr2 u02]$ su
Password:
[root@db11gr2 u02]#

ok finally user oracle can create files on this new mount point.

The partition /dev/sdd4 will not be mounted automaticall to /u02 directory so we have to put an entry to fstab file under etc directory

[root@db11gr2 oracle]# vi /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Mar 5 00:30:49 2011
#
# 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
#
/dev/mapper/vg_db11gr2-lv_root / ext4 defaults 1 1
UUID=dfcfe7c4-1a4c-4983-a578-b610ffd9150a /boot ext4 defaults 1 2
/dev/mapper/vg_db11gr2-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
shmfs /dev/shm tmpfs size=4g 0 0
/dev/sdd4 /u02 ext4 defaults 1 1 [Add this line so that when the system is started everytime the new partition is mounted to /u02 directory]

2 thoughts on “How to add additional hard drive on Linux Guest in Vmware”

Leave a Reply to Sunil Nair Cancel reply

Your email address will not be published. Required fields are marked *