lsblkList disks, partitions and where they are mounted
lsblk prints every block device as a tree: disks, their partitions, LVM volumes and loop devices, with size and mount point. It is how you find a volume you just attached, check whether it has a filesystem, and see why df didn't grow after you resized a disk.
lsblk [OPTION]... [DEVICE]...You've logged in to an EC2 instance and want to see its disks, partitions and mount points.
lsblkList block devices from sysfs as a tree. No root needed.
lsblk doesn't open the disks. It reads /sys/block and /sys/dev/block: every block device the kernel knows has a directory there with its size (in 512-byte sectors), major:minor numbers, removable and read-only flags, and holders/slaves links that let lsblk draw partitions, LVM and RAID as a tree. Filesystem type, label and UUID come from the udev database in /run/udev/data, which udev fills by probing each device with libblkid when it appears. Mount points come from /proc/self/mountinfo. On AWS Nitro instances every EBS volume is an NVMe device (nvme0n1, nvme1n1...), whatever name you chose in the console (/dev/sdf); the volume ID is in the SERIAL column. A partition's size is fixed in the partition table, so after you grow a cloud disk lsblk shows a bigger disk but the same partition until you run growpart.
-fFilesystem view: FSTYPE, FSVER, LABEL, UUID, FSAVAIL, FSUSE%, MOUNTPOINTS-o COLSChoose columns: NAME,SIZE,TYPE,FSTYPE,UUID,MOUNTPOINTS,MODEL,SERIAL...-dDisks only, no partitions-e 7Exclude a major number; 7 = loop devices-pPrint full paths (/dev/nvme1n1) instead of bare names-bSizes in bytes (for scripts)-JJSON output, e.g. for jq-nNo header line-r / -lRaw or list output without tree characters, easier to parse-SShow SCSI devices (sd*) with vendor, model and transportFormatting /dev/nvme1n1 because the console said 'attached as /dev/sdf'On Nitro instances NVMe names follow discovery order, not the console name. You might format the wrong volume.
lsblk -d -o NAME,SIZE,SERIAL and match the serial to the volume IDRunning resize2fs right after growing the EBS volumeThe partition still has its old size, so resize2fs finds nothing to grow ('The filesystem is already ... blocks long. Nothing to do!').
sudo growpart /dev/nvme0n1 1 && sudo resize2fs /dev/nvme0n1p1Parsing the default lsblk tree output with awk in a scriptTree characters and empty columns shift fields around.
lsblk -rno NAME,SIZE,MOUNTPOINT or lsblk -J | jqTry these on a Linux machine of your own. Each task has a hint and a solution.
Write the commands that list all block devices on a server, then list them again without the loop devices. (The practice sandbox has no block devices, so lsblk prints nothing there: write the commands.)
Write the command that shows each device's filesystem type, label and UUID. (The practice sandbox has no block devices, so lsblk prints nothing there: write the commands.)
Write the command that prints only disk names and sizes in bytes, with no header and no partitions. (The practice sandbox has no block devices, so lsblk prints nothing there: write the commands.)
Write the commands to grow partition 1 of /dev/nvme0n1 and its ext4 filesystem after the cloud volume was enlarged (the sandbox disk can't be resized).
lsblkList disks, partitions and where they are mounted
lsblk prints every block device as a tree: disks, their partitions, LVM volumes and loop devices, with size and mount point. It is how you find a volume you just attached, check whether it has a filesystem, and see why df didn't grow after you resized a disk.
lsblk [OPTION]... [DEVICE]...You've logged in to an EC2 instance and want to see its disks, partitions and mount points.
lsblkList block devices from sysfs as a tree. No root needed.
lsblk doesn't open the disks. It reads /sys/block and /sys/dev/block: every block device the kernel knows has a directory there with its size (in 512-byte sectors), major:minor numbers, removable and read-only flags, and holders/slaves links that let lsblk draw partitions, LVM and RAID as a tree. Filesystem type, label and UUID come from the udev database in /run/udev/data, which udev fills by probing each device with libblkid when it appears. Mount points come from /proc/self/mountinfo. On AWS Nitro instances every EBS volume is an NVMe device (nvme0n1, nvme1n1...), whatever name you chose in the console (/dev/sdf); the volume ID is in the SERIAL column. A partition's size is fixed in the partition table, so after you grow a cloud disk lsblk shows a bigger disk but the same partition until you run growpart.
-fFilesystem view: FSTYPE, FSVER, LABEL, UUID, FSAVAIL, FSUSE%, MOUNTPOINTS-o COLSChoose columns: NAME,SIZE,TYPE,FSTYPE,UUID,MOUNTPOINTS,MODEL,SERIAL...-dDisks only, no partitions-e 7Exclude a major number; 7 = loop devices-pPrint full paths (/dev/nvme1n1) instead of bare names-bSizes in bytes (for scripts)-JJSON output, e.g. for jq-nNo header line-r / -lRaw or list output without tree characters, easier to parse-SShow SCSI devices (sd*) with vendor, model and transportFormatting /dev/nvme1n1 because the console said 'attached as /dev/sdf'On Nitro instances NVMe names follow discovery order, not the console name. You might format the wrong volume.
lsblk -d -o NAME,SIZE,SERIAL and match the serial to the volume IDRunning resize2fs right after growing the EBS volumeThe partition still has its old size, so resize2fs finds nothing to grow ('The filesystem is already ... blocks long. Nothing to do!').
sudo growpart /dev/nvme0n1 1 && sudo resize2fs /dev/nvme0n1p1Parsing the default lsblk tree output with awk in a scriptTree characters and empty columns shift fields around.
lsblk -rno NAME,SIZE,MOUNTPOINT or lsblk -J | jqTry these on a Linux machine of your own. Each task has a hint and a solution.
Write the commands that list all block devices on a server, then list them again without the loop devices. (The practice sandbox has no block devices, so lsblk prints nothing there: write the commands.)
Write the command that shows each device's filesystem type, label and UUID. (The practice sandbox has no block devices, so lsblk prints nothing there: write the commands.)
Write the command that prints only disk names and sizes in bytes, with no header and no partitions. (The practice sandbox has no block devices, so lsblk prints nothing there: write the commands.)
Write the commands to grow partition 1 of /dev/nvme0n1 and its ext4 filesystem after the cloud volume was enlarged (the sandbox disk can't be resized).