Link to home
Start Free TrialLog in
Avatar of Ogandos
OgandosFlag for Canada

asked on

Automatically take the output of my non-partitioned disks.

Hello Experts,

How can I automatically take the output of my non partitioned disks? (it will be part of a script).

Let's say that my system is currently with four installed disks:  /sda  /sdb  /sdc  /sdd, where only /sda is used. How can I take a command that identifies that b, c, and d are not partitioned, and give me an output as /sdb /sdb /sdc so that I can pipe it to another command.
Avatar of David Favor
David Favor
Flag of United States of America image

This may be useful, to show partitions...

net10 # sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL | egrep -v ^loop
NAME    FSTYPE               SIZE MOUNTPOINT      LABEL
sda                          1.8T                 
├─sda1                    1004.5K                 
├─sda2  linux_raid_member    999M                 
│ └─md2 ext4                 999M /boot           /boot
├─sda3  swap                29.3G [SWAP]          swap-sda3
└─sda4  linux_raid_member    1.8T                 
  └─md4 ext4                 1.8T /               /
sdb                          1.8T                 
├─sdb1                    1004.5K                 
├─sdb2  linux_raid_member    999M                 
│ └─md2 ext4                 999M /boot           /boot
├─sdb3  swap                29.3G [SWAP]          swap-sdb3
└─sdb4  linux_raid_member    1.8T                 
  └─md4 ext4                 1.8T /               /

Open in new window


Also this, to show any RAID configuration...

net10 # cat /proc/mdstat 
Personalities : [raid1] [raid0] [raid6] [raid5] [raid4] [linear] [multipath] [raid10] 
md4 : active raid1 sdb4[1] sda4[0]
      1921766336 blocks [2/2] [UU]
      [========>............]  check = 43.3% (833905280/1921766336) finish=17564.6min speed=1031K/sec
      bitmap: 13/15 pages [52KB], 65536KB chunk

md2 : active raid1 sda2[0] sdb2[1]
      1022912 blocks [2/2] [UU]
      
unused devices: <none>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ogandos

ASKER

Hey thanks,

I know these options, but none of them can be easily put in a script for detecting which ones are my unpartitioned disks.
I think I could cruft up a script that started cat /proc/partitions. But to be sure you would find it useful, could you please post the output from cat /proc/partitions on your system?
And indicate what exactly you would like the script to output (device per line, CSV, ...)