CentOS 7/RHEL7: 4 useful commands to check Block devices

How can I list all available block devices under linux system? How to view block devices in centos 7 or rhel 7 operating system? this post will show you how to check block devices using the following 4 commands:

#1 lsblk – used to list block devices and it will lists information about all available or the specified block devices. the lsblk command will read the sysfs filesystem to gather information.

#2 blkid – this command will locate/print block device attributes and it can determine the type of content that a block device holds and attributes from the content metadata.

#3 df – df command will display the amount of disk space available on the file system containing each file name argument.

#4 du – the du command will estimate file space usage, will display the amount of space that is being used by file in a directory.

CentOS 7 check block devices using “lsblk” command

To list all available block devices on your system, issue the following command:

lsblk

Outputs:

[root@osetc Desktop]# lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

fd0               2:0    1    4K  0 disk

sda               8:0    0   40G  0 disk

├─sda1            8:1    0  500M  0 part /boot

└─sda2            8:2    0 39.5G  0 part

├─centos-swap 253:0    0    2G  0 lvm  [SWAP]

└─centos-root 253:1    0 37.5G  0 lvm  /

sr0              11:0    1 1024M  0 rom

Form the above output of “lsblk” command, you will see the device name (NAME), major and minor device number(MAJ:MIN), removable device (RM), device Size(SIZE), read-only device (RO), and the mount point of device (MOUNTPOINT).

CentOS 7 check available block devices using “blkid” command

To display information about all available block devices, issue the following command:

blkid

Outputs:

[root@osetc Desktop]# blkid

/dev/sda1: UUID="54352552-3d25-4ee7-bd9c-b2355634fc82" TYPE="xfs"

/dev/sda2: UUID="EDwo5T-eGDd-gLO6-DM3z-6h74-g9I8-dcUqr1" TYPE="LVM2_member"

/dev/mapper/centos-swap: UUID="996389c2-680d-40c5-a25f-b3d9956df733" TYPE="swap"

/dev/dm-1: UUID="dbedd8fa-5d86-4ea0-8551-8444a48cd44f" TYPE="xfs"

If you just want to check one particular block device, just appending “device name” to “blkid” command:

blkid <device_name>

blkid /dev/sda1

Outputs:

[root@osetc Desktop]# blkid /dev/sda1

/dev/sda1: UUID="54352552-3d25-4ee7-bd9c-b2355634fc82" TYPE="xfs"

To get more detailed information of block devices, using “-po udev” option to blkid command, type:

blkid -po udev <device-name>

For example: check /dev/sda1 information for more detailed information:

blkid -po udev /dev/sda1

Outputs:

[root@osetc Desktop]# blkid -po udev /dev/sda1

ID_FS_UUID=54352552-3d25-4ee7-bd9c-b2355634fc82

ID_FS_UUID_ENC=54352552-3d25-4ee7-bd9c-b2355634fc82

ID_FS_TYPE=xfs

ID_FS_USAGE=filesystem

ID_PART_ENTRY_SCHEME=dos

ID_PART_ENTRY_TYPE=0x83

ID_PART_ENTRY_FLAGS=0x80

ID_PART_ENTRY_NUMBER=1

ID_PART_ENTRY_OFFSET=2048

ID_PART_ENTRY_SIZE=1024000

ID_PART_ENTRY_DISK=8:0

CentOS 7 check file system disk space usage

To display a detailed information of file system disk space usage, issue the following command:

df

Outputs:

[root@osetc Desktop]# df

Filesystem              1K-blocks    Used Available Use% Mounted on

/dev/mapper/centos-root  39277836 5308296  33969540  14% /

devtmpfs                   496332       0    496332   0% /dev

tmpfs                      505428     288    505140   1% /dev/shm

tmpfs                      505428   13548    491880   3% /run

tmpfs                      505428       0    505428   0% /sys/fs/cgroup

/dev/sda1                  508588  120936    387652  24% /boot

To display disk space usage information with a human readable format, passing with “-h” option, type:

df -h

Outputs:

[root@osetc Desktop]# df -h

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/centos-root   38G  5.1G   33G  14% /

devtmpfs                 485M     0  485M   0% /dev

tmpfs                    494M  288K  494M   1% /dev/shm

tmpfs                    494M   14M  481M   3% /run

tmpfs                    494M     0  494M   0% /sys/fs/cgroup

/dev/sda1                497M  119M  379M  24% /boot

The above output of “df -h” command will show the partition size in megabytes and gigabytes.

CentOS 7 check disk usage of each FILE

To display the disk usage for each file in the current directory, issue the following command, type:

du

Outputs:

[root@osetc~]# du

4 ./.cache/dconf

8 ./.cache/abrt

4 ./.cache/imsettings

0 ./.cache/evolution/addressbook/trash

0 ./.cache/evolution/addressbook

0 ./.cache/evolution/calendar/trash

0 ./.cache/evolution/calendar

0 ./.cache/evolution/mail/trash

0 ./.cache/evolution/mail

0 ./.cache/evolution/memos/trash

0 ./.cache/evolution/memos

0 ./.cache/evolution/sources/trash

Done.

You might also like:

Sidebar



back to top