尧图网络 高端网站定制 · 原创设计
免费咨询热线
400-888-6620
免费获取方案
lsblk Command in Linux: Syntax, Options  Practical Examples (Block Devices)
lsblk — quick referenceDefault listingShow the block-device tree with name, size, type, and mount points — no root required.When to useCommandDefault tree of all block deviceslsblkLimit output to one disk and its childrenlsblk /dev/sdaList format (one line per device, no tree branches)lsblk -lShow disks only — skip partition childrenlsblk -dHide empty devices with no holderslsblk -AFilesystems and identifiersSee filesystem type, UUID, and usage alongside block layout.When to useCommandAdd filesystem type, label, UUID, and use% columnslsblk -fPrint full/dev/...paths in the NAME columnlsblk -pPrint sizes in bytes instead of human unitslsblk -b /dev/sdaShow owner, group, and device node permissionslsblk -m /dev/sdaColumns, filters, and layoutPick columns, sort, and hide device classes you do not care about.When to useCommandChoose explicit columnslsblk -o NAME,SIZE,TYPE,MOUNTPOINTSExclude devices by major number (hide loop devices: major 7)lsblk -e7ASCII tree characters only (safe for logs)lsblk -iTree layout with the-Tformatterlsblk -TSort by a column (for example size)lsblk -x SIZESkip the header rowlsblk -nDependencies, topology, and scriptingTrace holders, inspect queue settings, or emit JSON for scripts.When to useCommandShow inverse dependencies (which disk holds this partition)lsblk -s /dev/sda1Print topology columns (alignment, scheduler, rotational)lsblk -tJSON output for parserslsblk -JList available output column nameslsblk --list-columnsHelp and versionWhen to useCommandShow brief usagelsblk --helpShow util-linux versionlsblk --versionlsblk — command syntaxSynopsis fromlsblk --helpon Ubuntu 25.04 (util-linux 2.40.2):textCopylsblk [options] [device ...]lsblkreads the kernel block layer and udev; it does not change partitions or filesystems. Pair it with parted orfdiskwhen you need to create or resize partitions.lsblk — command examplesExpand or collapse all examples below to scan titles quickly or open every step at once.Expand allCollapse allRunlsblkwith no arguments when you want a quick map of disks, partitions, LVM volumes, and loop devices on the host.Run the command:bashCopylsblkSample output:outputNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 4K 1 loop /snap/bare/5 sda 8:0 0 25G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 2G 0 part /boot └─sda3 8:3 0 23G 0 part └─ubuntu--vg-ubuntu--lv 252:0 0 58.4G 0 lvm / sdb 8:16 0 35.4G 0 disk └─ubuntu--vg-ubuntu--lv 252:0 0 58.4G 0 lvm /Tree branches show parent/child relationships:sda3is a partition; the LVM logical volume underneath is where/is mounted.TYPEtells you disk, part, lvm, or loop.Before mounting or editing/etc/fstab,-fadds filesystem columns so you can match UUIDs without a separateblkidcall.Run the command:bashCopylsblk -f /dev/sdaSample output:outputNAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS sda ├─sda1 ├─sda2 ext4 1.0 c254a326-948a-4ae2-993b-1659f4ddcf03 1.5G 17% /boot └─sda3 LVM2_member LVM2 001 xLar7A-0CSb-mAmp-Y2sy-s6KG-FtEP-kIBAUL └─ubuntu--vg-ubuntu--lv ext4 1.0 72457fae-1731-4c94-b5c1-ac4564f4311c 35.5G 34% /FSTYPEon the partition showsLVM2_memberwhen that partition is a physical volume; the filesystem type appears on the logical volume row.Pass a device path to limit the tree to that disk — handy on servers with many SAN LUNs.Run the command:bashCopylsblk /dev/sdaSample output:outputNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 25G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 2G 0 part /boot └─sda3 8:3 0 23G 0 part └─ubuntu--vg-ubuntu--lv 252:0 0 58.4G 0 lvm /MAJ:MINis the kernel major:minor number.ROset to1means the device is read-only (common for squashfs loops).Desktop Ubuntu hosts often have dozens of snap loop devices. Major number7is the loop driver — exclude it to see only real disks.Run the command:bashCopylsblk -e7Sample output:outputNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 25G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 2G 0 part /boot └─sda3 8:3 0 23G 0 part └─ubuntu--vg-ubuntu--lv 252:0 0 58.4G 0 lvm / sdb 8:16 0 35.4G 0 disk └─ubuntu--vg-ubuntu--lv 252:0 0 58.4G 0 lvm / sr0 11:0 1 50.7M 0 rom /media/golinuxcloud/VBox_GAs_7.2.0Add more major numbers to the exclude list separated by commas if needed (-e7,11also hides the CD-ROM).-opicks exactly the fields you want.MOUNTPOINTSsupports multiple mount points per device on newer util-linux.Run the command:bashCopylsblk -o NAME,SIZE,TYPE,MOUNTPOINTSSample output:outputNAME SIZE TYPE MOUNTPOINTS loop0 4K loop /snap/bare/5 sda 25G disk ├─sda1 1M part ├─sda2 2G part /boot └─sda3 23G part └─ubuntu--vg-ubuntu--lv 58.4G lvm /Runlsblk --list-columnsto see every available column name on your build.When you are about to runmount,fsck, ordd,-pprints complete/dev/...paths so you do not guess the node name.Run the command:bashCopylsblk -p /dev/sdaSample output:outputNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS /dev/sda 8:0 0 25G 0 disk ├─/dev/sda1 8:1 0 1M 0 part ├─/dev/sda2 8:2 0 2G 0 part /boot └─/dev/sda3 8:3 0 23G 0 part └─/dev/mapper/ubuntu--vg-ubuntu--lv 252:0 0 58.4G 0 lvm /Copy paths directly into commands — still double-check before destructive operations.Scripts and configuration management tools often parse JSON more reliably than ASCII trees.Run the command:bashCopylsblk -J /dev/sdaSample output:output{ blockdevices: [ { name: sda, maj:min: 8:0, rm: false, size: 25G, ro: false, type: disk, mountpoints: [ null ], children: [ { name: sda1, maj:min: 8:1, rm: false, size: 1M, ro: false, type: part, mountpoints: [ null ] },{Pipe throughjqfor field extraction, for examplelsblk -J | jq .blockdevices[].name.If you have a partition device and need the parent disk (for example beforeddor cloning),-swalks upward.Run the command:bashCopylsblk -s /dev/sda1Sample output:outputNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda1 8:1 0 1M 0 part └─sda 8:0 0 25G 0 diskThe child appears first; parents stack below with tree markers.lsblk — when to use / when notUse lsblk whenUse something else whenYou want a readable tree of disks, partitions, LVM volumes, and mount pointsYou need filesystem type, UUID, or usage% next to device names (-f)You are scripting with JSON (-J) or custom columns (-o)You must confirm which disk holds a partition before resize or wipe (-s)You are troubleshooting missing mounts or unexpected loop devicesYou need to create or resize partitions → parted orfdiskYou need inode-level detail or bad blocks → filesystem tools (dumpe2fs,xfs_info)You are creating LVM physical volumes → pvcreate andvgdisplayYou only need UUID for fstab and already know the device →blkidYou want to mount a filesystem → mountlsblk vs fdisk / blkidlsblkfdisk -l / blkidLayoutIndented tree with holdersFlat list or one line per FSMount pointsBuilt inNot infdisk; partial inblkidLVM mappingShows LV under PV/partitionNeeds extra toolsChanges disksRead-onlyfdiskis for editing tablesUselsblkfirst for orientation; switch topartedorfdiskwhen you are ready to change partition tables.lsblk — interview cornerlsblklistsblock devices— kernel-level disk nodes under/dev— in a hierarchy. Disks sit at the top; partitions, LVM logical volumes, and device-mapper nodes appear as children. Columns usually include size, read-only flag, device type, and where the filesystem is mounted.It is read-only and fast. Admins run it beforefdisk,resize2fs, or LVM extend work to confirm they are targeting the correct device.A strong answer is:lsblk prints a tree of block devices — disks, partitions, LVM volumes, loops — with sizes and mount points. I use it as a read-only map before any disk-changing command.fdisk -lreads partition tables and prints geometry and partition types — it is the tool you use beforewritinga new table.lsblkshows how therunning systemsees devices, including LVM and mount points, in a tree. It does not display every partition-table fieldfdiskshows.Use both:lsblkfor layout and mounts;fdisk -lor parted when you need sector-level partition detail or plan changes.A strong answer is:lsblk is a live tree with mounts and LVM; fdisk -l is partition-table detail for editing. I start with lsblk for orientation, fdisk or parted when Im changing partitions.Snap and container tooling creates manyloopdevices (major number 7). Exclude them:bashCopylsblk -e7You can pass multiple majors:lsblk -e7,11drops loops and CD-ROM (sr0, major 11). On busy desktops this keeps the tree focused on real disks.A strong answer is:Loop devices are major 7 — I run lsblk -e7 to hide them when snap loops clutter the output.-faddsfilesystemcolumns:FSTYPE,UUID,LABEL, and usage percentages where available. That is exactly what you need when:Writing or checking/etc/fstabby UUIDConfirming which partition is ext4 versus LVM2_memberSeeing if/bootstill has free spaceIt replaces a separateblkidcall for a quick overview.A strong answer is:lsblk -f shows filesystem type, UUID, label, and use% beside the device tree — I use it before fstab edits or when tracing which partition holds which FS.Pass-Jfor JSON or-owith a fixed column list for grep-friendly lines. Add-nto drop headers in pipelines.bashCopylsblk -J -o NAME,SIZE,TYPE,MOUNTPOINTSParse withjqin shell or feed into Ansible facts. JSON includes nestedchildrenarrays that mirror the tree.A strong answer is:For scripts I use lsblk -J or lsblk -n -o with explicit columns, then parse with jq — it is more stable than scraping the ASCII tree.TroubleshootingSymptomLikely causeFixExpected disk missingDriver not loaded or multipath aliasdmesg, check/dev/disk/by-id/; install HBA driverPartition not listedTable not written or whole-disk FSsudo parted /dev/sdX print;fdisk -lMOUNTPOINTSempty but disk in useUnmounted or LVM not activatedmount;sudo vgchange -ayHuge loop device listSnap / flatpak loopslsblk -e7Wrong size shownRecent resize, kernel cachesudo partprobe; re-runlsblklsblk: command not foundutil-linux not installedsudo apt install util-linux
RELATED

相关推荐

前端:常见字符编码全方位解析(ASCII/GB系列/UTF系列/多国编码)

前端:常见字符编码全方位解析(ASCII/GB系列/UTF系列/多国编码)

在前端开发中,字符编码是中文乱码、接口异常、文件解析错误、页面显示异常的核心根源之一。很多开发者仅会简单配置 UTF-8,却不懂各类编码的底层差异、适用边界与兼容问题。本文在原有编码对照表基础上全面迭代升级,补充编码底层原理、核心区…

📅 2026/10/13 16:24:14
思源宋体TTF字体安装与网页配置教程:7个字重,免费商用

思源宋体TTF字体安装与网页配置教程:7个字重,免费商用

思源宋体TTF字体安装与网页配置教程:7个字重,免费商用 【免费下载链接】source-han-serif-ttf Source Han Serif TTF 项目地址: https://gitcode.com/gh_mirrors/so/source-han-serif-ttf 思源宋体TTF是 Adobe 与 Google 开源思源宋体的 TTF 子集…

📅 2026/10/8 8:52:14
具身智能行业资讯周报(260810-260816)

具身智能行业资讯周报(260810-260816)

写在前面: 社区共建项目:AIGC算法工程师/开发工程师面试面经秘籍分享,Interview-for-Algorithm-Engineer,欢迎大家Star⭐收藏~ AIGC时代的 《三年面试五年模拟》AI算法工程师求职面试秘籍独家资源: 【三年面试五年模拟】AI算法工程…

📅 2026/10/1 8:15:54
MORE NEWS

更多资讯

📰

STC12C5A60S2驱动0.96寸OLED:I2C例程与避坑指南

简介:一套可直接运行的0.96寸OLED显示例程,面向使用STC12C5A60S2单片机的电子爱好者与嵌入式学习者,演示通过IIC总线完成屏幕控制。例程基于C51编写,包含主程序与底层驱动函数,可实现OLED初始化、清屏、坐标定位、文本…

📰

数据预处理全流程详解:从数据清洗到特征工程的实践指南

干这行久了,你会发现自己拿到一批数据的第一反应根本不是模型选型,而是先问一句:这批数到底能不能信。数据预处理,就是在回答这个问题。很多人觉得它只是清洗、去重、补缺失值那些杂活,但真正上过生产项目的人都明白&a…

📰

校园二手交易系统数据库课程设计:从ER图到SQL优化的完整实践

简介:这份文档基于校园二手交易场景,系统完成数据库课程设计,内容涵盖需求分析、数据流程分析、概念结构设计、逻辑结构设计以及数据库实施与安全设计,适合计算机相关专业学生用于课程设计参考或数据库入门学习。资源包内仅含一份…

📰

Agent技能系统设计指南:从工具调用到技能编排的落地实践

“agent-skills”,我第一次看到这个名字的时候,正在为某个内部Agent平台的能力边界发愁。模型推理很聪明,可到了真干活的时候——查订单、算数据、调接口、生成图表——它什么都做不了,因为它没有“手”。后来我们把注意力全部放在…

📰

RAG系统知识检索增强设计:从架构原理到落地实操与避坑指南

做了一段时间大模型应用开发后,我越来越确信一件事:在很多生产场景里,真正决定结果质量的不是模型本身,而是你有没有给它足够对的上下文。RAG(Retrieval-Augmented Generation,检索增强生成)系统…

📰

逆时偏移RTM的MATLAB实现:波动方程有限差分与成像参数详解

简介:逆时偏移(RTM)Matlab代码包,面向地震勘探与成像算法学习者,实现叠后/叠前逆时偏移的基本流程,采用波场正传和反传互相关成像,并支持对简单高角度速度模型进行测试。压缩包共7个文件&#x…

TODAY

今日更新

THIS WEEK

本周精选

THIS MONTH

本月热门

读完文章,想聊聊您的网站?

告诉我们您的行业与需求,资深顾问一对一梳理方案与报价,全程免费。

📞 💬