List all partition labels

Is there a command to list all partition labels?

I can list the partitions with

sudo fdisk -l

but it doesn't show the labels of unmounted partitions.


Solution 1:

sudo blkid -o list

lists all devices with labels:

device          fs_type  label     mount point         UUID
----------------------------------------------------------------------------------
/dev/sda1       ntfs     WINRE_DRV (not mounted)       604C3A6A4C3A3B5C
/dev/sda2       vfat     SYSTEM_DRV (not mounted)      6C3C-72E3
/dev/sda3       vfat     LRS_ESP   (not mounted)       5240-1BEE
/dev/sda5       ntfs     Windows8_OS /media/Win8       A47A42FF7A42CDAC
/dev/sda6       ntfs     Daten     /media/Daten        72860971860936DF

Solution 2:

Simply labels?

$ ls /dev/disk/by-label/              
Download  MuruHome  Ubuntu  Windows8  arch

Or better:

$ tree /dev/disk/by-label/  # or use ls -l
/dev/disk/by-label/
├── Download -> ../../sda6
├── MuruHome -> ../../sdc2
├── Ubuntu -> ../../sdc1
├── Windows8 -> ../../sda2
└── arch -> ../../sda1

If you're willing to use sudo (which blkid requires), then you could also use the lsblk command:

$ sudo lsblk -o NAME,LABEL
NAME                    LABEL
sda                     
├─sda1                  System Reserved
├─sda2                  windows
├─sda3                  ubuntu
├─sda4                  
├─sda5                  arch
├─sda6                  
│ └─lvmg-homelvm (dm-0) homelb
└─sda7                  
sdb                     
└─sdb1                  
  └─lvmg-homelvm (dm-0) homelb

Solution 3:

Use the command

lsblk -nPo  MOUNTPOINT,UUID,LABEL    

You will get a list of fields that are most useful for your requirement.