Showing results for 
Search instead for 
Did you mean: 

losetup at boot using udev?

Frequent Advisor

losetup at boot using udev?


When I setup raw devices in udev for Oracle, I use something like this

ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw1 %N"
KERNEL="sdd1", OWNER="root", GROUP="oinstall", MODE="0640"
KERNEL=="raw[1-2]", OWNER="root", GROUP="oinstall", MODE="0640"

I'm now trying to do a similar thing with losetup and loopN devices (i.e. I made some fake raw disk by using dd and now I want to set these files up as "raw devices" at boot), so I (probably naively) imagined I could do this similar to the above commands, adding in at the beginning a udev command to associate the dd-created files with the loop device, then follow with the usual raw commands, i.e.

ACTION=="add", KERNEL=="loop1", RUN+="/sbin/losetup /u01/oradata/asmdisks/asmdisk1 %N"
ACTION=="add", KERNEL=="loop1", RUN+="/usr/bin/raw /dev/raw/raw1 %N"
KERNEL="loop1", OWNER="oracle", GROUP="oinstall", MODE="0660"

for the first command I also tried

ACTION=="add", KERNEL=="/u01/oradata/asmdisks/asmdisk1", RUN+="/sbin/losetup /dev/loop1 %N"

so as you can see not entirely sure I fully understand what needs to happen here. I read this:

but I still could not see where (or even if) losetup and loopN device can be handled in udev?

but it doesn't work the way I thought it might - no raw devices get setup upon boot.

How this could be accomplished at boot time?

I do it manually as follows:

losetup /dev/loop1 /u01/oradata/asmdisks/asmdisk1
raw /dev/raw/raw1 /dev/loop1
chown oracle:dba /dev/raw/raw1
chmod 660 /dev/raw/raw1

it "seems" like their ought to be a way to do this with udev - rather than using a script or rc.local, etc.

Thank You,

If I could take one thing with me into the next world it would be my valid login to HP ITRC Forums
Frequent Advisor

Re: losetup at boot using udev?

ok well update to my (probably idiotic) above post, but I think the second step in the manual steps above, i.e. "raw /dev/raw/raw1 /dev/loop1" is probably uneccessary?? The device /dev/loop1 is already a "raw" disk (i.e. can do fdisk /dev/loop1) and see that there are no partitions yet defined, i.e.

[root@rac1 rules.d]# fdisk /dev/loop1
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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)

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): p

Disk /dev/loop1: 512 MB, 512000000 bytes
255 heads, 63 sectors/track, 62 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help): q

[root@rac1 rules.d]#

So therefore I should be able to just reference /dev/loop1 directly from ASM - with no need to even bother with hooking things up to "/dev/raw" so maybe I do not even need that step - then if that is the case I just need to figure out how to code step 1,
losetup /dev/loop1 /u01/oradata/asmdisks/asmdisk1

into udev

things that make you go hmmmm.....
If I could take one thing with me into the next world it would be my valid login to HP ITRC Forums