On Sun, 16 Sep 2001, Charles Curley wrote:

> Is there any way in a perl script to translate a disk label
> (e.g. "LABEL=/boot") from the label to a device (e.g. /dev/hda1)? I do
> bare metal restore using tomsrtbt, which apparently does not
> understand labels.

"any way"? Sure... no particularly easy way though.

You need something like this (this isn't perl, but it isn't entirely different
either):

    PARTS = open("</proc/partitions");
    <PARTS>;
    while (<PARTS>) {
        $name = split($_)[3];
        LABEL = open("|e2label /dev/" . $name);
        $this = <LABEL>;
        close LABEL;
        if ($this eq $target_label) {
            print "device " . $name . " has target label\n";
        }
    }
    close(PARTS);

Hopefully that will get you going.
            
Erik

-------------------------------------------------------------------------------
|            "Who is John Galt?" - Atlas Shrugged by Ayn Rand                 |
|                                                                             |
|  Linux Application Development  --  http://people.redhat.com/johnsonm/lad   |



_______________________________________________
Seawolf-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/seawolf-list

Reply via email to