5 Display all block devices on system
7 hdparm -t `block-devices`
9 sfdisk -l `block-devices with-partitions`
17 my $with_partitions = { true => 1 } if grep { m/with.?partitions/ } @ARGV;
19 open(my $proc, '<', '/proc/partitions');
26 my ( $name, $line ) = @_;
28 $name2col->{ $header[$_] } = $_ foreach 0 .. $#header;
30 $line =~ s/^\s+// || die "expected line to start with space: $_\n";
31 my @c = split(/\s+/, $line, $#header + 1 );
32 return $c[ $name2col->{ $name } ];
38 @header = split(/\s+/, $_);
43 my $device = col 'name', $_;
44 my $device_like_last = substr( $device, 0, length($last_device) );
45 if ( $last_device && $device_like_last eq $last_device ) {
46 if ( $with_partitions ) {
47 print "/dev/$device_like_last\n" if ! $with_partitions->{ $device_like_last }++;
49 warn "# partition $device\n";
52 print "/dev/$device\n" unless $with_partitions;
53 $last_device = $device;