lsblk
Overview
The lsblk
command lists information about all available block devices. It shows the block devices in a tree-like format.
Syntax
lsblk [options] [device...]
Common Options
Option | Description |
---|---|
-a |
Show all devices |
-b |
Print sizes in bytes |
-d |
Don’t show slaves |
-f |
Show filesystems |
-m |
Show permissions |
-n |
Don’t show headings |
-o columns |
Output columns |
-p |
Show full paths |
-r |
Raw output |
-t |
Show topology |
-x column |
Sort by column |
Output Columns
Column | Description |
---|---|
NAME |
Device name |
MAJ:MIN |
Major:minor device numbers |
RM |
Removable device |
SIZE |
Device size |
RO |
Read-only device |
TYPE |
Device type |
MOUNTPOINT |
Mount point |
FSTYPE |
Filesystem type |
LABEL |
Filesystem label |
UUID |
Filesystem UUID |
Key Use Cases
- Device enumeration
- Storage management
- System configuration
- Troubleshooting
- Documentation
Examples with Explanations
Example 1: Basic Usage
lsblk
Show block devices
Example 2: Show Filesystems
lsblk -f
Include filesystem information
Example 3: Custom Output
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
Select specific columns
Common Usage Patterns
All information:
lsblk -a
Raw output:
lsblk -r
Tree topology:
lsblk -t
Security Considerations
- Device access
- Root privileges
- Sensitive info
- Network devices
- Removable media
Additional Resources
Best Practices
- Regular checks
- Documentation
- Verification
- Monitoring
- Change tracking
Device Types
- disk
- part
- lvm
- crypt
- loop
Troubleshooting
- Missing devices
- Access errors
- Display issues
- Format problems
- Device naming