On Thu, Mar 30, 2017 at 09:10:01AM -0400, Jiri B wrote: > > > > diff -u -p -r1.988 install.sub > > > > --- distrib/miniroot/install.sub 13 Mar 2017 17:08:31 -0000 > > > > 1.988 > > > > +++ distrib/miniroot/install.sub 30 Mar 2017 10:44:01 -0000 > > > > @@ -264,13 +264,7 @@ diskinfo() { > > > > local _d > > > > > > > > for _d; do > > > > - make_dev $_d > > > > - echo -n "$_d: " > > > > - disklabel -dpg $_d 2>/dev/null | > > > > - sed -e '/^label: /{s,,,;s/ *$//;s/^$/<no > > > > label>/;h;d;}' \ > > > > - -e '/.*# total bytes: \(.*\)/{s//(\1)/;H;}' \ > > > > - -e '$!d;x;s/\n/ /' > > > > - rm -f /dev/{r,}$_d? > > > > + sed -n "/^$_d/p" /var/run/dmesg.boot > > > > done > > > > } > > > > > > > > > > Your proposition is good for the installer? I doubt it. > > > > > > j. > > > > AFAICT the function diskinfo() is only called once in the installer: if > > you press ? a the prompt for the root disk. So my diff just changes the > > output in this case, no other functionality is affected. > > > > What causes your doubt? > > Robert, > > could we use something like this? From dmesg we can get current > vendor, model, size plus serial if it does exist, 'sd0' could be grepped > before sed or we could put variable inside sed itself: > > sed -e '/^sd0 at.*: <[A-Z]*, \([^,]*\).*fixed *\(.*\)/{s//\1 <\2>/;s/< > *>$/<no serial>/;h;d;}' -e '/sd0: \([^,]*\).*/{s//(\1)/;H;}' -e '$!d;x;s/\n/ > /' /var/run/dmesg.boot > SAMSUNG MZ7TE256 <naa.5002538844584d30> (244198MB) > > If there's no serial it maybe could print this? > > cat /var/run/dmesg.boot | sed 's/fixed.*/fixed/;' | sed -e '/^sd0 at.*: > <[A-Z]*, \([^,]*\).*fixed *\(.*\)/{s//\1 <\2>/;s/< *>$/<no serial>/;h;d;}' -e > '/sd0: \([^,]*\).*/{s//(\1)/;H;}' -e '$!d;x;s/\n/ /' > SAMSUNG MZ7TE256 <no serial> (244198MB) > > What do you think? > > PS: sed is really hardcore :) > > j.
Parsing dmesg output always tends to be fragile, but what about this? Use whatever is enclosed in <> in the dmesg output for a disk and get the size from disklabel. VMware ESXi: sd0 at scsibus1 targ 0 lun 0: <ATA, VMware Virtual S, 0000> SCSI3 0/direct fixed naa.5000c2994057dedf QEMU using virtio: sd0 at scsibus1 targ 0 lun 0: <VirtIO, Block Device, > SCSI3 0/direct fixed My notebook: sd0 at scsibus1 targ 0 lun 0: <ATA, MTFDDAK512MBF, LN01> SCSI3 0/direct fixed naa.500a07511210a1b8 >From an ppc imac: wd0 at pciide0 channel 0 drive 0: <Samsung SSD 840 EVO 120GB> sd0: VirtIO, Block Device, (10.0G) sd0: ATA, VMware Virtual S, 0000 naa.5000c2994057dedf (51.2G) sd0: ATA, MTFDDAK512MBF, LN01 naa.500a07511210a1b8 (512.0G) wd0: Samsung SSD 840 EVO 120GB (120.0G) Index: install.sub =================================================================== RCS file: /cvs/src/distrib/miniroot/install.sub,v retrieving revision 1.989 diff -u -p -p -u -r1.989 install.sub --- install.sub 31 Mar 2017 18:36:49 -0000 1.989 +++ install.sub 2 Apr 2017 20:13:04 -0000 @@ -266,10 +266,11 @@ diskinfo() { for _d; do make_dev $_d echo -n "$_d: " - disklabel -dpg $_d 2>/dev/null | - sed -e '/^label: /{s,,,;s/ *$//;s/^$/<no label>/;h;d;}' \ - -e '/.*# total bytes: \(.*\)/{s//(\1)/;H;}' \ - -e '$!d;x;s/\n/ /' + set -- $(sed -n "/^$_d at /{s/^.* <//;s/>.* \(naa\..*\)$/ \1/;s/> .*$//;p;}" \ + /var/run/dmesg.boot 2>/dev/null) \ + $(disklabel -dpg $_d 2>/dev/null | + sed -n '/.*# total bytes: \(.*\)/s//(\1)/p') + echo "$*" rm -f /dev/{r,}$_d? done } =================================================================== Stats: --- 4 lines 166 chars Stats: +++ 5 lines 220 chars Stats: 1 lines Stats: 54 chars -- -=[rpe]=-