What I'm Doing:
I'm developing a python script that scans for all storage devices and their respective sizes. Python does not have a command that returns the /dev paths of storage devices or the respective sizes. So, I need to pipe a shell command to python.
The Problem:
In root, I've used fdisk to get all storage device paths and their respective sizes and send that to a file that python can open to retrieve the path and size info. Here is what fdisk sends to a file:
Code:
Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x8941fb29
Device Boot Start End Blocks Id System
/dev/sda1 * 1 12748 102398278+ 83 Linux
/dev/sda2 37811 38913 8859847+ 5 Extended
/dev/sda3 12749 20397 61440592+ 83 Linux
/dev/sda4 25497 37810 98912205 83 Linux
/dev/sda5 37811 38913 8859816 82 Linux swap / Solaris
Partition table entries are not in disk order
Disk /dev/sdb: 126 MB, 126779392 bytes
4 heads, 61 sectors/track, 1014 cylinders
Units = cylinders of 244 * 512 = 124928 bytes
Disk identifier: 0x5b1b8282
Disk /dev/sdc: 2004 MB, 2004877312 bytes
255 heads, 63 sectors/track, 243 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000a8c94
Device Boot Start End Blocks Id System
/dev/sdc1 1 243 1951866 83 Linux
My Question
Is there a way to grep this info so that the paths and their respectives sizes are returned? Or, for anyone who understands what I'm trying to achieve here, could you offer some other solution besides an attempt to grep?
I need a way to reliably detect a USB storage device from a bash script. I know how to use 'lsusb' to list the USB devices - but then how can I match a device listed in 'lsusb' output to an actual disk device? Is there some way to map one to the other?
Any help appreciated. (3 Replies)
Hello,
I've been searching your forum for an answer to the following question and whilst I've seen several which may help I'm afraid my inexperience with UNIX systems has got the better of me and I'm incapable of piecing your considerable expertise together.
Problem:
I have a linux box which... (5 Replies)
Have connected a non-IBM storage device to AIX host via fibre channel. If the storage is rebooted or a raid controller fails over whilst connected to the host, the paths that drop do not come back online when the ports become active again.
I have tried enabling dynamic tracking and delayed_fail... (3 Replies)
Hello,
I have a sun blade 100 with solaris 10 and am perplexed by the instances of devices that I see when I attach a usb flash stick to one of the ports in the back of the chassis.
Here is what I see for USB storage in /etc/path_to_inst:
"/pci@1f,0/usb@c,3/storage@3" 0 "scsa2usb"... (0 Replies)
Dear linuxers,
I have a usb mess storage device.
My OS is rh as3 update2.
Each time I use the command
mount -t vfat /dev/sda1 /mnt/usb
I got the error "the device is not a valid block device".
I found from google that I should install the module sd_mod
I use the command
insmod sd_mod... (2 Replies)