* Detecting array parameters @ 2010-06-09 21:13 Piergiorgio Sartor 2010-06-09 22:31 ` Neil Brown 2010-06-10 23:04 ` Leslie Rhorer 0 siblings, 2 replies; 6+ messages in thread From: Piergiorgio Sartor @ 2010-06-09 21:13 UTC (permalink / raw) To: linux-raid Hi, if I understood it correctly, in order to detect the several array parameters (number of disks, for example), it is possible to use "mdadm -D /dev/mdX" or to check the files in the corresponding /sys/block/... /mdX/... files. Now, assuming something needs to be done in scripts, what would be the best way? Using "mdadm -D ... | grep" (or "mdadm ... | gawk ...."), or to read the proper files in /sys/block/md...? Assuming the wanted information is available on both sides, which does not seem always the case. Thanks, bye, -- piergiorgio ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Detecting array parameters 2010-06-09 21:13 Detecting array parameters Piergiorgio Sartor @ 2010-06-09 22:31 ` Neil Brown 2010-06-12 9:58 ` Piergiorgio Sartor 2010-06-10 23:04 ` Leslie Rhorer 1 sibling, 1 reply; 6+ messages in thread From: Neil Brown @ 2010-06-09 22:31 UTC (permalink / raw) To: Piergiorgio Sartor; +Cc: linux-raid On Wed, 9 Jun 2010 23:13:40 +0200 Piergiorgio Sartor <piergiorgio.sartor@nexgo.de> wrote: > Hi, > > if I understood it correctly, in order to detect > the several array parameters (number of disks, for > example), it is possible to use "mdadm -D /dev/mdX" > or to check the files in the corresponding /sys/block/... > /mdX/... files. > > Now, assuming something needs to be done in scripts, > what would be the best way? Using "mdadm -D ... | grep" > (or "mdadm ... | gawk ...."), or to read the proper > files in /sys/block/md...? > > Assuming the wanted information is available on both > sides, which does not seem always the case. If it is available in mdadm --detail --export I would use that. Otherwise probably go for /sys/class/block/mdX/md/... I say /sys/class/block rather than /sys/block as there are rumours of deprecating /sys/block. Don't know if that will ever happen though. NeilBrown ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Detecting array parameters 2010-06-09 22:31 ` Neil Brown @ 2010-06-12 9:58 ` Piergiorgio Sartor 2010-06-17 5:52 ` Neil Brown 0 siblings, 1 reply; 6+ messages in thread From: Piergiorgio Sartor @ 2010-06-12 9:58 UTC (permalink / raw) To: Neil Brown; +Cc: Piergiorgio Sartor, linux-raid Hi, thanks for the answer. The "--export" option is a good advice, unfortunately it seems to be quite "conservative" in the amount of information, probably it is following some "udev" requirements, I guess. I'll try to explain what I'm trying to do, so, maybe, there will be some other good advices. I've a bunch (10) of different (in size too) HDDs. These HDDs are partitioned in a way so that equal partitions can compose several RAID-6 arrays. So, for example, there are 5x 120GB and 5x 80GB HDDs. The firsts are partitioned in 80+40, and there are 2 RAID-6, one made of 10 80GB "segments" and another made of 5 40GB "segments". So far, so good. What I would like to do is a script, which, given an HDD as parameter will *properly* add it to the array. Where *properly* means, it will partition it properly, add the partitions to the respectively arrays, and perform, if necessary (non-degraded case) a grow. My idea would be to go over the several arrays, check the partition size, create a partition on the new HDD, if possible, then add it and grow the array (if required). The first step would be to find out the partition size, which does seem to be avaialable in: /sys/class/block/mdX/md/rdX/block/size I was wondering if this would be the best option to get this information, or there are better solutions. Trying "mdadm -E /dev/sdX" returns also similar information, namely the available device size and the offset, which sum up to the partition size. In /sys/class/block/mdX/md/rdX there are also two files, carrying similar information: "size" and "offset". In this case, strangely, the size is in KiB while the offset in sectors (seems a bug to me). Any suggestions on how to do this in a *correct* way? Thanks a lot in advance for any advice and, please, feel free to ask if you need more information. bye, pg On Thu, Jun 10, 2010 at 08:31:12AM +1000, Neil Brown wrote: > On Wed, 9 Jun 2010 23:13:40 +0200 > Piergiorgio Sartor <piergiorgio.sartor@nexgo.de> wrote: > > > Hi, > > > > if I understood it correctly, in order to detect > > the several array parameters (number of disks, for > > example), it is possible to use "mdadm -D /dev/mdX" > > or to check the files in the corresponding /sys/block/... > > /mdX/... files. > > > > Now, assuming something needs to be done in scripts, > > what would be the best way? Using "mdadm -D ... | grep" > > (or "mdadm ... | gawk ...."), or to read the proper > > files in /sys/block/md...? > > > > Assuming the wanted information is available on both > > sides, which does not seem always the case. > > If it is available in > mdadm --detail --export > > I would use that. > Otherwise probably go for > /sys/class/block/mdX/md/... > > I say /sys/class/block rather than /sys/block as there are rumours of > deprecating /sys/block. Don't know if that will ever happen though. > > NeilBrown > -- > To unsubscribe from this list: send the line "unsubscribe linux-raid" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- piergiorgio ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Detecting array parameters 2010-06-12 9:58 ` Piergiorgio Sartor @ 2010-06-17 5:52 ` Neil Brown 0 siblings, 0 replies; 6+ messages in thread From: Neil Brown @ 2010-06-17 5:52 UTC (permalink / raw) To: Piergiorgio Sartor; +Cc: linux-raid On Sat, 12 Jun 2010 11:58:21 +0200 Piergiorgio Sartor <piergiorgio.sartor@nexgo.de> wrote: > Hi, > > thanks for the answer. > > The "--export" option is a good advice, unfortunately > it seems to be quite "conservative" in the amount of > information, probably it is following some "udev" > requirements, I guess. > > I'll try to explain what I'm trying to do, so, maybe, > there will be some other good advices. > > I've a bunch (10) of different (in size too) HDDs. > These HDDs are partitioned in a way so that equal > partitions can compose several RAID-6 arrays. > So, for example, there are 5x 120GB and 5x 80GB HDDs. > The firsts are partitioned in 80+40, and there are 2 > RAID-6, one made of 10 80GB "segments" and another > made of 5 40GB "segments". > So far, so good. > > What I would like to do is a script, which, given an > HDD as parameter will *properly* add it to the array. > Where *properly* means, it will partition it properly, > add the partitions to the respectively arrays, and > perform, if necessary (non-degraded case) a grow. > > My idea would be to go over the several arrays, check > the partition size, create a partition on the new HDD, > if possible, then add it and grow the array (if required). > > The first step would be to find out the partition size, > which does seem to be avaialable in: > > /sys/class/block/mdX/md/rdX/block/size > > I was wondering if this would be the best option to get > this information, or there are better solutions. > > Trying "mdadm -E /dev/sdX" returns also similar information, > namely the available device size and the offset, which sum > up to the partition size. > > In /sys/class/block/mdX/md/rdX there are also two files, > carrying similar information: "size" and "offset". > In this case, strangely, the size is in KiB while the > offset in sectors (seems a bug to me). > > Any suggestions on how to do this in a *correct* way? > > Thanks a lot in advance for any advice and, please, > feel free to ask if you need more information. I'm not sure there is a "correct" way. Your requirements seem fairly specific to your system and so you just need to code to match those. One thought: when deciding how to partition a new device it might make more sense to look at the partitioning of other devices and try to match that, rather than to look at md arrays and try to match them. Maybe. ?? NeilBrown ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Detecting array parameters 2010-06-09 21:13 Detecting array parameters Piergiorgio Sartor 2010-06-09 22:31 ` Neil Brown @ 2010-06-10 23:04 ` Leslie Rhorer 2010-06-12 9:59 ` Piergiorgio Sartor 1 sibling, 1 reply; 6+ messages in thread From: Leslie Rhorer @ 2010-06-10 23:04 UTC (permalink / raw) To: 'Piergiorgio Sartor', linux-raid > Hi, > > if I understood it correctly, in order to detect > the several array parameters (number of disks, for > example), it is possible to use "mdadm -D /dev/mdX" > or to check the files in the corresponding /sys/block/... > /mdX/... files. Yes, but only if the array is assembled. If not, it's "-E", not "-D", and the target is a member device, not the array. > Now, assuming something needs to be done in scripts, > what would be the best way? Using "mdadm -D ... | grep" > (or "mdadm ... | gawk ...."), or to read the proper > files in /sys/block/md...? That depends on what you need to do. If you need to obtain in depth information about the array and / or act only upon specific contents of a line in the output, then you need to use gawk. If your script merely takes action based upon the existence of some meta-content of the output, then grep or even grep -q may be the better choice. > Assuming the wanted information is available on both > sides, which does not seem always the case. I don't know what you mean by "both sides". ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Detecting array parameters 2010-06-10 23:04 ` Leslie Rhorer @ 2010-06-12 9:59 ` Piergiorgio Sartor 0 siblings, 0 replies; 6+ messages in thread From: Piergiorgio Sartor @ 2010-06-12 9:59 UTC (permalink / raw) To: Leslie Rhorer; +Cc: 'Piergiorgio Sartor', linux-raid Hi, thanks for the answer. By "both sides" I mean the "mdadm -D/-E" (one) and the /sys/class/block/mdX/md (the other). Some information is available with "mdadm -D", some other is available in the sysfs. bye, pg On Thu, Jun 10, 2010 at 06:04:48PM -0500, Leslie Rhorer wrote: > > Hi, > > > > if I understood it correctly, in order to detect > > the several array parameters (number of disks, for > > example), it is possible to use "mdadm -D /dev/mdX" > > or to check the files in the corresponding /sys/block/... > > /mdX/... files. > > Yes, but only if the array is assembled. If not, it's "-E", not > "-D", and the target is a member device, not the array. > > > Now, assuming something needs to be done in scripts, > > what would be the best way? Using "mdadm -D ... | grep" > > (or "mdadm ... | gawk ...."), or to read the proper > > files in /sys/block/md...? > > That depends on what you need to do. If you need to obtain in depth > information about the array and / or act only upon specific contents of a > line in the output, then you need to use gawk. If your script merely takes > action based upon the existence of some meta-content of the output, then > grep or even grep -q may be the better choice. > > > Assuming the wanted information is available on both > > sides, which does not seem always the case. > > I don't know what you mean by "both sides". > > -- > To unsubscribe from this list: send the line "unsubscribe linux-raid" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- piergiorgio ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-06-17 5:52 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-06-09 21:13 Detecting array parameters Piergiorgio Sartor 2010-06-09 22:31 ` Neil Brown 2010-06-12 9:58 ` Piergiorgio Sartor 2010-06-17 5:52 ` Neil Brown 2010-06-10 23:04 ` Leslie Rhorer 2010-06-12 9:59 ` Piergiorgio Sartor
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).