Page 1 of 1
partition informations - running some tests
Posted: Thu 24 Jan 2008, 02:02
by MU
can you help me?
I need some people (5 should be enough at moment) who do this:
please type:
cat /proc/diskstats >/root/mark-help.txt
probepart >> /root/mark-help.txt
gzip /root/mark-help.txt
Then please attach /root/mark-help.txt.gz here.
I'm doing some tests to find out a fast way to get drive-infos.
probepart is a bit slow, if you have many partitions.
I wrote a testcript, that gives me this result:
# ./finddisks
hda1 not mounted
hda2 not mounted
hda5 not mounted
hda6 not mounted
hdb mounted maybe a cdrom
sda1 not mounted
sda2 mounted
sda3 not mounted
sda4 not mounted
sda5 not mounted
sda6 not mounted
sda7 mounted
sda8 not mounted
sda9 not mounted
sda10 not mounted
sda11 not mounted
sda12 not mounted
sda13 not mounted
sda14 not mounted
sda15 mounted
swap: /dev/sda15 partition 522072 6132 -1
I'd like to find out more info, but don't know yet, how.
Must study the other utilities like MUT.
Mark
finddisks
Code: Select all
#!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"
//thelist=xwin_system("cat /proc/diskstats")
// 3 64 hdb 0 0 0 0 0 0 0 0 0 0 0
thelist=readfiletolist("/proc/diskstats")
//print thelist
partitions = {}
counter = 0
for each theline in thelist
theline=trim(theline)
for n=0 to 5
theline=replace(theline , " " , " ")
next
partinfo=explode(theline , " ")
entries=count(partinfo)
//print partinfo[2] & " " & entries
if entries = 7 then
mounted = "mounted"
if partinfo[5] = "0" then
mounted = "not mounted"
end if
print partinfo[2] & " " & mounted
end if
if val(partinfo[1])>63 then
mounted = "mounted"
if partinfo[5] = "0" then
mounted = "not mounted"
end if
print partinfo[2] & " " & mounted & " " & "maybe a cdrom"
end if
next
swaps=readfiletolist("/proc/swaps")
for n=1 to count( swaps )-1
print "swap: " & swaps[n]
next
lob help
Posted: Thu 24 Jan 2008, 02:23
by Lobster
lobhelp attached
Posted: Thu 24 Jan 2008, 02:27
by NathanO
I have two computers. Here is the first, an HP Pavilion zv6000 with a CD/DVD, 80Gig HD, two 8Gig USB sticks.
Posted: Thu 24 Jan 2008, 02:30
by NathanO
Here is the other, home made, 3-1/2" floppy, ~40 Gig HD, TWO CD/DVD player / burners, 2 PCMCIA Flash Cards, 4 Gig USB stick
Posted: Thu 24 Jan 2008, 02:49
by John Doe
Here you go Mark. Machine has two CD Drives, a Floppy Drive and two usb flash drives plugged in. No internal IDE in this one.
Posted: Thu 24 Jan 2008, 03:44
by oldbox
I had a sony tiny microvault plugged into an external usb hub at the time of the commands.
Hope this helps you.
Posted: Thu 24 Jan 2008, 04:00
by craftybytes
.
Here we go Mark -
ASROCK VIA M/B; AMD Duron 1.8GHz CPU; 1.0GB DDR RAM; 20 GB HDD; 80GB HDD; 1 x 1.0GB USB Flash drive; 1 x 2.0GB USB Flash drive; DVD/CD Burner/Reader; Floppy drive..
HTH..
crafty.
.
Posted: Thu 24 Jan 2008, 07:26
by Pizzasgood
hda = dvd-rw
sda = 80-gig SATA drive
sdb = 128 mb usb flash drive
Code: Select all
sh-3.00# ./finddisks
sda1 not mounted
sda2 not mounted
sda3 not mounted
sda4 mounted
sda5 mounted
sda6 mounted
sda7 mounted
sdb1 mounted
swap: /initrd/dev/sda2 partition 498004 0 -1
sh-3.00#
Except sdb1 is not mounted anymore. It was not very long ago. Otherwise all looks correct.
Running Puppy 2.14 if it matters.
Posted: Thu 24 Jan 2008, 09:00
by MU
Many thanks, I'll have a look at your files this weekend.
Today I must travel to northern germany.
Here is another code-example.
Using fdisk -l is the fastest you can have.
It does does not show the difference ext2/ext3, it just says "Linux".
So we might need blkid.
Also fdisk does not show CDRoms.
As blkid is slower, I will try to find other ways.
Maybe using /proc again for infos about CDROMS.
For this your files will be helpfull, to see what special identifier those CDROM-drives use.
See you, Mark
Code: Select all
#!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"
//thelist=xwin_system("cat /proc/diskstats")
// 3 64 hdb 0 0 0 0 0 0 0 0 0 0 0
names={}
types={}
ismounted={}
try1()
sub try1()
counter=0
blockids=xwin_system("blkid -s TYPE")
thelist=readfiletolist("/proc/diskstats")
for each theline in thelist
theline=trim(theline)
for n=0 to 5
theline=replace(theline , " " , " ")
next
partinfo=explode(theline , " ")
entries=count(partinfo)
use = 0
if entries = 7 then
use = 1
end if
if val(partinfo[1])>63 then
use = 1
end if
if use = 1 then
mounted = "mounted"
if partinfo[5] = "0" then
mounted = "unmounted"
end if
filesystem = "unknown"
for each block in blockids
type=cutleft(block , "TYPE=")
block=cutright(block , ":")
block=cutleft(block , "/dev/")
if block = partinfo[2] then
filesystem=replace(type , "\"" , "")
filesystem=trim(filesystem)
break
end if
next
if filesystem != "unknown" then
names[counter] = partinfo[2]
types[counter] = filesystem
ismounted[counter] = mounted
counter += 1
print partinfo[2] & " " & filesystem & " " & mounted
end if
end if
next
'swaps=readfiletolist("/proc/swaps")
'for n=1 to count( swaps )-1
' print "swap: " & swaps[n]
'next
end sub
thelist=xwin_system("fdisk -l")
for each theline in thelist
if left(theline , 5) = "/dev/" then
if ! instr(theline , "Extended") then
theline = trim(theline)
name=cutrightfromleft(theline , " ")
name=right(name, len(name)-5)
for n = 0 to count(names)-1
if name=names[n] then
size=cutleft(theline , " ")
size=trim(size)
size=cutleft(size , " ")
size=trim(size)
size=cutleft(size , " ")
size=trim(size)
size=cutrightfromleft(size , " ")
size=replace(size , "+" , "")
print name & " " & types[n] & " " & size & " " & ismounted[n]
break
end if
next
//print theline
end if
end if
next
Posted: Thu 24 Jan 2008, 15:21
by Leachim
From one of our school computers. Running from usb-flash-drive. Windows XP on the builtin hdd.
Posted: Fri 25 Jan 2008, 00:27
by JustGreg
Here is the information from my system running a 80 Gigabyte drive,
1 Gigabyte USB external hard drive, 1 Gigabyte compact flash device and 2 Gigabyte SD card in the USB mult-card reader.
Posted: Sat 26 Jan 2008, 10:03
by Billwho?
Here is the information for 3 machines I have here. One is incomplete but I hope it helps anyway.
Posted: Mon 28 Jan 2008, 00:05
by r__hughes
This from an IBM T22 Thinkpad
Posted: Fri 27 Jun 2008, 16:52
by MU
I updated my script.
It gave wrong values on one computer:
Code: Select all
/dev/sda1 * 1 1216 9765625 b W95 FAT32
the "*" bootflag now is filtered out.
It also no longer uses /proc/ to find out, if a drive was mounted, but /etc/mtab.
The code got shorter now.
Another issue was, that Extended partitions were no detected (excluded) correctly.
Only the second line in this "fdisk -l" output was detected:
Code: Select all
/dev/hda2 679 1559 6660360 f W95 Ext'd (LBA)
/dev/sda4 3648 24316 166015625 5 Extended
This is corrected now.
Mark
finddisks
Code: Select all
#!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"
'shell("sync")
blockids=xwin_system("blkid -s TYPE")
'swaps=readfiletolist("/proc/swaps")
'for n=1 to count( swaps )-1
' print "swap: " & swaps[n]
'next
thelist=xwin_system("fdisk -l")
mtab=readfiletolist("/etc/mtab")
for each theline in thelist
if left(theline , 5) = "/dev/" then
if ! instr(theline , "Ext") then
theline = replace(theline , "*" , "")
theline = trim(theline)
name=cutrightfromleft(theline , " ")
device = name
name=right(name, len(name)-5)
size=cutleft(theline , " ")
size=trim(size)
size=cutleft(size , " ")
size=trim(size)
size=cutleft(size , " ")
size=trim(size)
size=cutrightfromleft(size , " ")
size=replace(size , "+" , "")
mountedmtab = "unmounted"
for m=0 to count(mtab)-1
if instr(mtab[m] , " ") then
thedev = cutrightfromleft(mtab[m] , " ")
if thedev = device then
mountedmtab = "mounted"
break
end if
end if
next
filesystem = "unknown"
for each block in blockids
type=cutleft(block , "TYPE=")
block=cutright(block , ":")
if block = device then
filesystem=replace(type , "\"" , "")
filesystem=trim(filesystem)
break
end if
next
'-- too slow...
'result = xwin_system("disktype " & device )
'dsize = "unknown"
'for d=0 to count(result)
' if instr(result[d] , "size " ) then
' dsize = cutleft(result[d] , "(")
' dsize = cutright(dsize , ")")
' end if
'next
if command(3) = "-m" then
size = int(size/1000)
end if
print name & " " & filesystem & " " & size & " " & mountedmtab
end if
end if
next
Here is an example output:
Code: Select all
# ./finddisks -m
hda1 vfat 5125 unmounted
hda5 ext3 5738 mounted
hda6 swap 839 unmounted
sda1 vfat 9765 unmounted
sda2 ext2 9765 mounted
sda3 ext2 9765 mounted
sda5 ext2 97 unmounted
sda6 ext2 48730 unmounted
sda7 vfat 48828 unmounted
sda8 ext2 9765 unmounted
sda9 ext2 9765 mounted
sda10 ext2 9765 unmounted
sda11 ext2 9765 unmounted
sda12 ext2 9765 unmounted
sda13 ext2 9765 unmounted
sda14 vfat 9237 unmounted
sda15 swap 522 unmounted
The swappartitions are shown as "unmounted", what is wrong.
I must add a fix for that.
Posted: Mon 30 Jun 2008, 19:56
by MU
updated code.
run with option "-all" to show cdroms (they start with "-").
DVDs not yet added.
This was just tested on 1 machine, so might not work reliable.
It is optional, because cdrom-detection is slow.
Also swap now is displayed as on or off.
And or mounted drives, the mountpoint is displayed.
Code: Select all
#!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"
'shell("sync")
' cdrom:
'probedisk
args = argvtostring()
args = " " & args & " "
blockids=xwin_system("blkid -s TYPE")
'swaps=readfiletolist("/proc/swaps")
'for n=1 to count( swaps )-1
' print "swap: " & swaps[n]
'next
thelist=xwin_system("fdisk -l")
mtab = readfiletolist("/etc/mtab")
swaps = readfiletolist("/proc/swaps")
for each theline in thelist
if left(theline , 5) = "/dev/" then
if ! instr(theline , "Ext") then
theline = replace(theline , "*" , "")
theline = trim(theline)
name=cutrightfromleft(theline , " ")
device = name
name=right(name, len(name)-5)
size=cutleft(theline , " ")
size=trim(size)
size=cutleft(size , " ")
size=trim(size)
size=cutleft(size , " ")
size=trim(size)
size=cutrightfromleft(size , " ")
size=replace(size , "+" , "")
mountedmtab = "unmounted"
for m=0 to count(mtab)-1
if instr(mtab[m] , " ") then
thedev = cutrightfromleft(mtab[m] , " ")
if thedev = device then
mountpoint = cutleft(mtab[m] , " ")
mountpoint = cutrightfromleft(mountpoint , " ")
'mountedmtab = "mounted"
mountedmtab = mountpoint
break
end if
end if
next
filesystem = "unknown"
for each block in blockids
type=cutleft(block , "TYPE=")
block=cutright(block , ":")
if block = device then
filesystem=replace(type , "\"" , "")
filesystem=trim(filesystem)
break
end if
next
if filesystem = "swap" then
mountedmtab = "off"
for each swap in swaps
if instr(swap , " ") then
theswap = cutrightfromleft(swap , " ")
if theswap = device then
mountedmtab = "on"
break
end if
end if
next
end if
'-- too slow...
'result = xwin_system("disktype " & device )
'dsize = "unknown"
'for d=0 to count(result)
' if instr(result[d] , "size " ) then
' dsize = cutleft(result[d] , "(")
' dsize = cutright(dsize , ")")
' end if
'next
if instr(args, " -m ") then
size = int(size/1000)
end if
print name & " " & filesystem & " " & size & " " & mountedmtab
end if
end if
next
'print
'print
if instr(args, " -all ") then
drives = xwin_system("probedisk")
for each drive in drives
if instr(drive , "|") then
device = cutrightfromleft(drive , "|")
drive = trim(replace(drive , "/dev/" , ""))
typ = cutleft(drive , "|")
drive = replace(drive , "|" , " ")
if instr(typ , "|") then
typ = cutright(typ , "|")
select case typ
case "cdrom"
m = ismounted(device)
print "-" & drive & " " & m
end select
end if
end if
'print drive
next
end if
function ismounted(device)
mounted = "unmounted"
for m=0 to count(mtab)-1
if instr(mtab[m] , " ") then
thedev = cutrightfromleft(mtab[m] , " ")
if thedev = device then
mountpoint = cutleft(mtab[m] , " ")
mountpoint = cutrightfromleft(mountpoint , " ")
'mountedmtab = "mounted"
mountedmtab = mountpoint
end if
end if
next
return mounted
end function
Example-Output:
# ./finddisks -m -all
hda1 vfat 5125 unmounted
hda5 ext3 5738 /initrd/mnt/dev_save
hda6 swap 839 on
sda1 vfat 9765 unmounted
sda2 ext2 9765 /mnt/sda2
sda3 ext2 9765 /mnt/sda3
sda5 ext2 97 unmounted
sda6 ext2 48730 unmounted
sda7 vfat 48828 unmounted
sda8 ext2 9765 unmounted
sda9 ext2 9765 /mnt/sda9
sda10 ext2 9765 unmounted
sda11 ext2 9765 unmounted
sda12 ext2 9765 unmounted
sda13 ext2 9765 unmounted
sda14 vfat 9237 unmounted
sda15 swap 522 off
-hdc cdrom MATSHITADVD-ROM SR-8174 unmounted
Mark
Posted: Wed 02 Jul 2008, 10:06
by Billwho?
Here you are Mark.
This is the main machine I have been using these days.