LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   show all unmounted disk labels? (https://www.linuxquestions.org/questions/linux-hardware-18/show-all-unmounted-disk-labels-722515/)

ninja master 04-29-2009 11:38 AM

show all unmounted disk labels?
 
how does one show all unmounted disk labels. say i have a disk, and im guessing that its /dev/sda2. how can i take away this guessing.

unSpawn 04-29-2009 04:48 PM

Looking at /dev/disk/by-label/ (or use 'disktype') will show you all disklabels, to see which ones are unmounted check against /proc:
Code:

for DISKLABEL in `find /dev/disk/by-label/ -type l`; do RES=`readlink -f $DISKLABEL`;
 grep -q "^$RES" /proc/mounts ||echo "$RES (${DISKLABEL//*\//})"
done


joeseph0404 04-29-2009 05:01 PM

unSpawn has a great solution. I am not very good with code however, so usually I run (as root):

Code:

fdisk -l
And I receive lots of cool info about the model numbers, partitions, and space on the drive. This usually helps identify them because sometimes I'll plug in a USB drive but it will get mounted as /dev/sda (which is usually sata or scsi).

Hope this simple command helps!

miriam-e 02-05-2014 05:04 AM

Code:

blkid -c /dev/null
will show all mounted and unmounted disk labels, along with UUID, filesystem, and device.

Some of the other suggestions are of no use to me unfortunately.
Some distros of Linux don't have the /dev/disk/by-label/ directory (mine doesn't) so that can't be used.
fdisk -l doesn't show labels (at least it doesn't on mine).
There are various tools that let you ask a drive what its label is (e2label, mlabel, ntfslabel, etc.) but they generally require that you know which device it is, which is often difficult in the case of USB drives. Also, they require you to know what format the drive is in.
gparted will display the label, but it is a slow and cumbersome solution and doesn't lend itself to automation.


All times are GMT -5. The time now is 07:02 AM.