Create Virtual File System for ASM Disks
Automatic Storage Management (ASM) employs provisioned disks for creating disk groups. The following steps instantiate the virtual disks used to create a virtual file system, without creating disks partitioning.
Create zero-filled flat files
Run the ‘dd’ command to create the zero-filled flat files. Optionally, in between each ‘dd’ command, the Operating System ‘sync’ command is executed to write buffered data to the disk, releasing memory for the next ‘dd’ command. The size of the file is specified using the ‘count’ attribute. The following example creates a zero-filled file of size 20GB.
1 |
#dd if=/dev/zero of=/u01/asmdsks/_asm_file_vdisk_01 bs=1k count=20971520 |
Attach a loopback device for each file
Use the Operating System utility ‘losetup’ to attach the first Linux loopback device with the flat file created. Ensure the loopback devices /dev/loop1 to /dev/loop7 are available. Test each loopback device availability; to test the first loopback device, type the following the command:
1 |
# /sbin/losetup /dev/loop1 |
Link the virtual loopback device
Use the command ‘ln’ to alias the loopback devices to be presented as virtual block devices.
Create the ASM Disk
The last step is to use Oracle ASM command ‘oracleasm createdisk’ to provision the files as virtual ASM disk.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
<i> </i>#----------------------------------------------------------------- #-- DISCLAIMER: #-- #-- This script is provided for educational purposes only. #-- The script has been tested on an Oracle Database 11g instance #-- and run as intended. However; prior to using the script on #-- production systems, a dynamic test should be conducted prior #-- to deployment. #-- #-- Copyright (c) Rampant TechPress. 2014. All Rights Reserved. #------------------------------------------------------------------ # #!/bin/bash echo `date` echo "Enter non-existing ASM directory or press ENTER to exit, " echo "Example: /u01/ASMDSKS: "; read vdir if [ -d $vdir ]; then echo "Directory exit"; exit -1 elif [[ $vdir != /* ]]; then echo "Invalid directory, example /u01/ASMDSKS"; exit -1 else echo "Enter number of virtual disks followed by size, " echo "Example: 4 4194304: "; read vdsk vsize if [[ "$vdsk" = *[!2-7]* ]]; then echo "Invalid argument value, Example: 2 4096"; exit -1 else mkdir -p $vdir for i in $(eval echo "{1..$vdsk}") do sync; echo 3 > /proc/sys/vm/drop_caches echo "Creating $vdir/_asm_file_vdisk_0$i" dd if=/dev/zero of=$vdir/_asm_file_vdisk_0$i bs=1024 obs=1024 count=$vsize status=noxfer echo "De-attaching /dev/loop$i" /sbin/losetup -d /dev/loop$i /sbin/losetup /dev/loop$i $vdir/_asm_file_vdisk_0$i case "$i" in 2) echo "Creating ASM_DISK0$i"; ln -s /dev/loop$i /dev/xvdd; /usr/sbin/oracleasm createdisk ASM_DISK0$i /dev/xvdd;; 3) echo "Creating ASM_DISK0$i"; ln -s /dev/loop$i /dev/xvde; /usr/sbin/oracleasm createdisk ASM_DISK0$i /dev/xvde;; 4) echo "Creating ASM_DISK0$i"; ln -s /dev/loop$i /dev/xvdf; /usr/sbin/oracleasm createdisk ASM_DISK0$i /dev/xvdf;; 5) echo "Creating ASM_DISK0$i"; ln -s /dev/loop$i /dev/xvdg; /usr/sbin/oracleasm createdisk ASM_DISK0$i /dev/xvdg;; 6) echo "Creating ASM_DISK0$i"; ln -s /dev/loop$i /dev/xvdh; /usr/sbin/oracleasm createdisk ASM_DISK0$i /dev/xvdh;; 7) echo "Creating ASM_DISK0$i"; ln -s /dev/loop$i /dev/xvdi; /usr/sbin/oracleasm createdisk ASM_DISK0$i /dev/xvdi;; esac done echo "Scanning ASM disk..." echo "" /usr/sbin/oracleasm listdisks fi fi |
Please let me know if this manual ‘Create Virtueel File System ASM disken’ was usefull to you. If there are errors or you have suggestions regarding this manual, please let me know.
No rights can be derived from this manual
Regards,
Maarten