partition informations - running some tests

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

partition informations - running some tests

#1 Post 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


User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

lob help

#2 Post by Lobster »

lobhelp attached
Attachments
lobhelp.tar.gz
(459 Bytes) Downloaded 454 times
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

NathanO
Posts: 210
Joined: Fri 23 Feb 2007, 00:03
Location: San Antonio, TX

#3 Post by NathanO »

I have two computers. Here is the first, an HP Pavilion zv6000 with a CD/DVD, 80Gig HD, two 8Gig USB sticks.
Attachments
mark-help.txt.gz
(390 Bytes) Downloaded 411 times

NathanO
Posts: 210
Joined: Fri 23 Feb 2007, 00:03
Location: San Antonio, TX

#4 Post 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

John Doe
Posts: 1681
Joined: Mon 01 Aug 2005, 04:46
Location: Michigan, US

#5 Post 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.

oldbox
Posts: 10
Joined: Tue 18 Dec 2007, 16:52

#6 Post by oldbox »

I had a sony tiny microvault plugged into an external usb hub at the time of the commands.

Hope this helps you.
Attachments
oldbox-help.txt.gz
(405 Bytes) Downloaded 412 times

User avatar
craftybytes
Posts: 298
Joined: Fri 17 Nov 2006, 10:32
Location: QLD AUSTRALIA

#7 Post 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.
.
3 x boot:- ASROCK VIA 'all-in-one' m/b; AMD Duron 1.8Ghz+; 1.0GB RAM; 20GB hdd (WinXP Pro); 80GB hdd (MEPIS 3.4-3/Puppy v2.15CE Frugal); 1GB USB pendrive (Puppy 2.15CE Frugal); CD/DVDRW; 17" LCD monitor; HSF 56k modem... MEPIS is great.. Puppy ROCKS..

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#8 Post 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.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#9 Post 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


Leachim
Posts: 229
Joined: Sun 27 May 2007, 23:04

#10 Post by Leachim »

From one of our school computers. Running from usb-flash-drive. Windows XP on the builtin hdd.

JustGreg
Posts: 782
Joined: Tue 24 May 2005, 10:55
Location: Connecticut USA

#11 Post 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.
Attachments
mark_tst.txt.gz
(601 Bytes) Downloaded 384 times
Enjoy life, Just Greg
Live Well, Laugh Often, Love Much

User avatar
Billwho?
Posts: 559
Joined: Tue 06 Dec 2005, 09:28
Location: still "In The Dog House" East Coast Oz
Trialing 4.20

#12 Post by Billwho? »

Here is the information for 3 machines I have here. One is incomplete but I hope it helps anyway.
Attachments
finddisks.tar.gz
(3.16 KiB) Downloaded 378 times
Linux = Learning through doing :shock: :? :D
The learning curve may be steep but there is a light at the end of the tunnel.
You just have to pass the occasional oncoming train to get there.

r__hughes
Posts: 359
Joined: Thu 13 Apr 2006, 04:14
Location: Montreal, Canada

#13 Post by r__hughes »

This from an IBM T22 Thinkpad
Attachments
mark-help.txt.gz
(344 Bytes) Downloaded 413 times
--- quad booting Slacko57NPAE, Slacko56NPAE, Slacko55PAE (with OO4, devx, Gimp) & WXP on DELL Dimension 2400 PC & DELL Latitude 630 Laptop using grub.
---USB-Flash booting same on Samsung N110 WXP Netbook and Lenovo q100 WXP netPC.

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#14 Post 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.
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#15 Post 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
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
Billwho?
Posts: 559
Joined: Tue 06 Dec 2005, 09:28
Location: still "In The Dog House" East Coast Oz
Trialing 4.20

#16 Post by Billwho? »

Here you are Mark.
This is the main machine I have been using these days.
Attachments
updated-1-7-09_output.tar.gz
(460 Bytes) Downloaded 179 times
Linux = Learning through doing :shock: :? :D
The learning curve may be steep but there is a light at the end of the tunnel.
You just have to pass the occasional oncoming train to get there.

Post Reply