First thing we want to do is to have a list of the devices in your linux box. This will save you searching for it once you add it later.
[oracle@localhost ~]$ cd /dev
[oracle@localhost dev]$ ls -al hd*
brw-r----- 1 root disk 3, 0 May 4 05:50 hda
brw-r----- 1 root disk 3, 1 May 4 05:51 hda1
brw-r----- 1 root disk 3, 2 May 4 05:50 hda2
brw-r----- 1 root disk 3, 64 May 4 05:50 hdb
brw-r----- 1 root disk 3, 65 May 4 05:51 hdb1
[oracle@localhost dev]$
You need to make sure your VM is powered down so we can make changes to the server.
Checking the storage frame of this VM, we can see that there is only two drives connected. Double clicking on the storage frame pops up the storage window where we can add the drive.
Clicking on add drive, asks us if we want to add an already built drive or add a new one. We want to add a new one.
We then choose a VMDK to use. There are other types, but we're using this one for now.
On the next page of the wizard, we choose dynamically allocated. which will size the disk to just the be the size of the data that is in it. So if there is no data on the drive, this file will be tiny.
Next we give it a name and size.
Clicking ok to finish the wizard show the new drive added. One las thing we do is to change the type of the hard drive to be a secondary slave.
And there we have it, one file added. This is useless to us though until we go in and format configure it in linux, then bring it online so its of use to us.
Ok, Now we have a drive attached to our virtual machine. All that remains is for us to configure it in in the machine so it is formatted and mounted.
Firing up the VM as normal, we want to SU as root for the next phase. The first thing we need to do is to format the disk.
[oracle@localhost ~]$ cd /dev
[oracle@localhost dev]$ ls -al hd*
brw-r----- 1 root disk 3, 0 May 4 05:50 hda
brw-r----- 1 root disk 3, 1 May 4 05:51 hda1
brw-r----- 1 root disk 3, 2 May 4 05:50 hda2
brw-r----- 1 root disk 3, 64 May 4 05:50 hdb
brw-r----- 1 root disk 3, 65 May 4 05:51 hdb1
brw-r----- 1 root disk 3, 65 May 4 05:53 hdd
[oracle@localhost dev]$
Now looking at the top device listing versus this one we can see that the new device that has been add is /dev/hdd
This disk that we've added is blank and raw so the first thing we need to do is to set up partitions and then format the disk.
[oracle@localhost dev]$ sudo fdisk /dev/sdd
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):
Choose 'n' to create a new partition and then choose 'e' and then pick the defaults through that option.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
Finally, when this comes back, choose the 'w' to write the partition table back to disk.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[oracle@localhost dev]$
Now we can build the file system on the disk we have partitioned with mkfs.
[oracle@localhost dev]$ sudo mkfs -t ext3 /dev/sdd
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6111232 inodes, 12211400 blocks
610570 blocks (5.00%) reserved for the super user
First data block=0
373 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
[oracle@localhost dev]$
Now you have a drive, but its not mounted anywhere so you still cant see it. You will now need to create a mount point for your drive in the root file system.
[oracle@localhost ~]$ sudo mkdir -p /newdrive
[sudo] password for oracle:
[oracle@localhost ~]$
And lastly you can issue the mount command to mount the drive to that mount point.
[oracle@localhost ~]$ sudo mount -t ext3 /dev/hdd /newdrive
[oracle@localhost ~]$
Now you can list your drive with 'ls -al /newdrive' and it is listed and usable. However, the next time, the machine is rebooted, you will not have this drive mounted. We need to add a line to the file /etc/fstab to allow it to be mounted automatically.
LABEL=/ / ext3 defaults 1 1
LABEL=/home /home ext3 defaults 1 2
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
LABEL=SWAP-hda2 swap swap defaults 0 0
http://localhost:80 /home/oracle/dav davfs noauto,users 0 0
/dev/hdd /newdrive ext3 defaults 1 2
Adding the line above to this file will allow the drive to be mounted each time the machine reboots.
Now you have a drive which you can use for data or install other Oracle software on, like Oracle Golden Gate to help synchronise data between databases. Find out more about the Oracle developer day VM on OTN
View comments