Thursday, August 30, 2007

Simple way to Fake Disks for ASM

#########################
SIMPLE WAY TO FAKE DISKS
#########################

Create Files using "dd"
# mkdir /asmdisks
# chown oracle:dba /asmdisks
# su - oracle
$ dd if=/dev/zero of=/asmdisks/_file_disk1 bs=1k count=100000
$ dd if=/dev/zero of=/asmdisks/_file_disk2 bs=1k count=100000
$ dd if=/dev/zero of=/asmdisks/_file_disk3 bs=1k count=100000
$ dd if=/dev/zero of=/asmdisks/_file_disk4 bs=1k count=100000

We now have four files to be used as virtual disks of 100MB each:

$ ls -l /asmdisks
total
400432
-rw-r--r-- 1 oracle dba 102400000 Jun 8 15:30 _file_disk1
-rw-r--r-- 1 oracle dba 102400000 Jun 8 15:31 _file_disk2
-rw-r--r-- 1 oracle dba 102400000 Jun 8 15:31 _file_disk3
-rw-r--r-- 1 oracle dba 102400000 Jun 8 15:31 _file_disk4

Associate Loop Device with the New Files

This needs to be performed as the root user account:

# losetup /dev/loop1 /asmdisks/_file_disk1
# losetup /dev/loop2 /asmdisks/_file_disk2
# losetup /dev/loop3 /asmdisks/_file_disk3
# losetup /dev/loop4 /asmdisks/_file_disk4

Bind RAW Devices to Existing Block Devices
As the root user account:
# raw /dev/raw/raw1 /dev/loop1/dev/raw/raw1: bound to major 7, minor 1
# raw /dev/raw/raw2 /dev/loop2/dev/raw/raw2: bound to major 7, minor 2
# raw /dev/raw/raw3 /dev/loop3/dev/raw/raw3: bound to major 7, minor 3
# raw /dev/raw/raw4 /dev/loop4/dev/raw/raw4: bound to major 7, minor 4

Change Ownership of RAW Devices

change the ownership of all four RAW devices:
# chown oracle:dba /dev/raw/raw1
# chown oracle:dba /dev/raw/raw2
# chown oracle:dba /dev/raw/raw3
# chown oracle:dba /dev/raw/raw4

# chmod 660 /dev/raw/raw1
# chmod 660 /dev/raw/raw2
# chmod 660 /dev/raw/raw3
# chmod 660 /dev/raw/raw4

This completes creating the ASM disks on Linux. When we create database using dbca with ASM option, these disks would be visible.

No comments: