Linux::Disks -- find all blockdevices in a Linux System
Version 0.01
use Linux::Disks; my $disks=Linux::Disks->new(); for my $dev ($disks->drives()) { print " NAME : ".$dev->name()."\n"; print " DEVICE : ".$dev->device()."\n"; print " VENDOR/MODEL: ".$dev->vendor().'/'.$dev->model()."\n"; print " MAJOR ID : ".$dev->major()."\n"; print " MINOR ID : ".$dev->minor()."\n"; print " BUS TYPE : ".$dev->bus_type()."\n"; print " UUID : ".$dev->uuid()."\n"; print " SERIAL : ".$dev->serial()."\n"; if($dev->mountable()) { print " MOUNTED : ".($dev->mounted()?'YES':'NO')."\n"; print " IN FSTAB : ".($dev->in_fstab()?'YES':'NO')."\n"; print " FS TYPE : ".$dev->fs_type()."\n"; print " SPECIAL FS : ".($dev->special_fs()?'YES':'NO')."\n"; print " SIZE : ".$dev->size()."\n"; print " FREE : ".$dev->free()."\n"; print " MOUNT POINT : ".$dev->mount_point()."\n"; } else { print " PARTITIONS :\n"; for my $part ($dev->partitions()) { print " NAME : ".$part->name()."\n"; print " MAJOR ID : ".$part->major()."\n"; print " MINOR ID : ".$part->minor()."\n"; print " LABEL : ".$part->label()."\n"; print " DEVICE : ".$part->device()."\n"; print " IN FSTAB : ".($part->in_fstab()?'YES':'NO')."\n"; print " MOUNTED : ".($part->mounted()?'YES':'NO')."\n"; print " FS TYPE : ".$part->fs_type()."\n"; print " SPECIAL FS : ".($part->special_fs()?'YES':'NO')."\n"; print " SIZE : ".$part->size()."\n"; print " FREE : ".$part->free()."\n"; print " MOUNT POINT : ".$part->mount_point()."\n"; print " ---------------\n"; } } print " -------------------\n"; }
This Modul uses System Tools (blkid,fdisk,df,udevadm) and parse "/etc/fstab" and search in "/dev" to find all aviable Informations about Blockdevices.
ToPeG
Directory of the device filesystem
predefined: /dev
Command to find all Blockdevice IDs
predefined: /sbin/blkid
Command for fdisk
predefined: LC_ALL=C /sbin/fdisk -l 2>/dev/null
command for df
predefined: LC_ALL=C /bin/df -PTx tmpfs 2>/dev/null
command for udevadm
predefined: /sbin/udevadm info --query=all --name="%s" 2>/dev/null
path to the fstab
predefined: /etc/fstab
path to the default mount directory
predefined: /media/
path to the mountpoint of sysfs
predefined: /sys/
create a new Object
Options
fake : a hashtree of deviceinformations. See result and code of __parse for more. Only for testpurpes
search for new Disks and Partitions. Remove old Disk-Informations
actualisize the partition information
it will not serach for new Disks or Partitions
Retuns a list of Linux::Disks::Drive Objects
Returns a list of Linux::Disks::Partition Objects
returs 1 if an Error occured
return a list of all Errors.
Resets the internel Errorlist.
returns the size of the partition in bytes
if aviable it's returns the bytes used 0 otherwise
returns the free Partitionspace if aviable or 0
returns the percent usage of the Partition if aviable or 0
return 1 if the partition have the bootflag
returns a path to the mountpoint.
A mountpoint will be generated if not set
returns the Startposition of the Partition
the endposition of the Partition
the Filesystem Type
1 if it's an special fs.
Detects: raid, swap, usbfs, proc, rootfs, tmpfs
the UUID of the Partition
1 if the Partition is mounted
1 if the Partition is mountable.
A Partition is mountable if the Bockdevice is avaiable, the mountpoints exists and is and Directory and the fstype is aviable
1 if the Partition is mentiond in the fstab.
name of the Partition
device of the Partition
alternative devicenames
sys-path of the Partition
Label of the Partition
Major Device Name
Minor Device Name
Vendor Device Name
Device Model
short serial number of the device
serial number of the Device
revision of the Devide
bustype of the Device
Aviable: scsi, usb, ide, net, raid
returns the size of the Device in bytes
if aviable it's returns the bytes used 0 otherwise
returns the free Diskspace if aviable or 0
returns the percent usage of the Partition if aviable or 0
return 0
returns a path to the mountpoint.
A mountpoint will be generated if not set
returns the Startposition of the Disk
the endposition of the Disk
the Filesystem Type
1 if it's an special fs.
Detects: raid, swap, usbfs, proc, rootfs, tmpfs
the UUID of the Partition
1 if the Partition is mounted
1 if the Device is mountable.
A Partition is mountable if the Bockdevice is avaiable, the mountpoints exists and is and Directory and the fstype is aviable
1 if the Partition is mentiond in the fstab.
name of the Partition
device of the Partition
alternative devicenames
sys-path of the Partition
Label of the Partition
Major Device Name
Minor Device Name
Vendor Device Name
Device Model
short serial number of the device
serial number of the Device
revision of the Devide
bustype of the Device
Aviable: scsi, usb, ide, net, raid
returns a list of all Partitions on this Device
Tobias Grönhagen <linux_disks@topeg.de>
Please report any bugs or feature requests to bug-linux-disks at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Linux-Disks. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
Copyright 2012 Tobias Grönhagen.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.