SLUG Mailing List Archives
Re: [SLUG] dynamically creating a loop device MINOR numbers?
- To: Zenaan Harkness <zenaan@xxxxxxxxx>
- Subject: Re: [SLUG] dynamically creating a loop device MINOR numbers?
- From: Adrian Chadd <adrian@xxxxxxxxxxxxxxx>
- Date: Sun, 10 Oct 2010 11:13:45 +0800
- Cc: SLUG <slug@xxxxxxxxxxx>
- User-agent: Mutt/1.5.13 (2006-08-11)
The horrible, O(n) way is to just to loop over 0 .. n, see if it doesn't
exist, if it doesn't then create and use it.
It's slow, it's racy (ie, don't run the script without locking :-) but
it's a traditional UNIX way of doing things.
PTYs were once allocated that way, fe. :-)
On Sun, Oct 10, 2010, Zenaan Harkness wrote:
> If I want to dynamically create loop devices, how would I dynamically
> create loop device minor numbers in some way, from a shell script,
> # setup:
> mknod $LOOP_DEV b 7 $MINOR_NUMBER
> chown root.disk $LOOP_DEV
> losetup $LOOP_DEV /home/$UNIQUE_NAME/source
> mount $LOOP_DEV /home/$UNIQUE_NAME/target
> # tear down:
> umount /home/$UNIQUE_NAME/target
> losetup -d $LOOP_DEV
> rm $LOOP_DEV
> Each dyn created loop device will have unique lifetime. So they will
> be losetup -d'ed at different times, so eventually, the minor numbers
> will need to be reused.
> Is there any easy way to do this, whilst creating loop devices with
> names which I assign, as in the example above?
> (I began a thread on this a few days ago (and no replies yet), which I
> will update if you just post here on slug, at
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
- Xenion - http://www.xenion.com.au/ - VPS Hosting - Commercial Squid Support -
- $24/pm+GST entry-level VPSes w/ capped bandwidth charges available in WA -