Join Scott Simpson for an in-depth discussion in this video Explore and identify block devices, part of Linux Foundation Cert Prep: Storage Management (Ubuntu).
- One of the ways that we can explore storage on a system is by using the blkid command. This shows us attributes of block devices attached to the system. Blkid shows the mount point, the universally unique identifier, or UUID, the volume or file system type, a label, if it's relevant, and the partition UUID for a device. What you see for your system will be a little different but the parts are all the same.
These pieces of information can help us to identify a device and see if it is as we expect it to be. The UUID of a volume is really helpful for allowing us to address it in an unambiguous way. If, for example, we added another disk, my external disk might change descriptors. It might become sdb or sdd, so only talking to it by calling it dev sdc1 isn't reliable, especially in a script or something across reboots. Instead, when the volume was created, it was given an identifier that's, for all intents and purposes, unique.
So wherever this disk gets detected, on this system or a different one, it'll always have the same UUID for the volume, and in fact, the partition has one too, if you need to use that. But usually the volume UUID is more useful, as we'll see when we mount disks. The type value here shows what kind of file system is being used on the volume and that will vary based on how the volume was created and what it's for. This one here is swap, for example, which is designed to act as system swap, and this one here is ext2 The internal disk here is ext4.
We'll dig into what these types are really about later on, but both of these are common file system types for general data storage on Linux systems. You may also see vfat or lvm member depending on how your system is set up. There are a few options that can show us more interesting information including the dash i option or a blkid -i and this takes an argument of a device. I'll use /dev/sdc1. This shows us some information about the input and output parameters of the disk, like the sector sizes.
Blkid dash p and the device reads information directly rather than from blkid's cache. Check out the man pages for more information. Another helpful command line utility for taking a look at block devices is lsblk which lists volumes in tree format so we can more easily see how they relate to each other and it shows us some different information than the blkid command, too. On the left, we see the name of each volume and there's a tree diagram that shows how they're related.
The next column shows what are called the major and minor numbers for the devices. These are classifications of the type of device that the system knows about. Here, a major number of eight represents a serial device, the hard disk. A major number is a way of communicating to the kernel what driver will be used to communicate with that device. Minor numbers of one, two, five, and so on here represent partitions on these devices. But it's up to the driver to determine what those numbers actually mean. On other devices, the minor number can represent specific models, or modes, or any information the driver creator wants to use them for.
If you're curious, you can take a look at what the major numbers correspond to in the block devices section of the /proc/devices file. These numbers are also shown on the long listing format if you take a look in the dev directory. The RM column shows whether a volume is removable. And we also have a column showing the human readable size of the volume or device. RO represents whether a device is read only.
And the type shows what kind of thing each line is. Part is partition and disk is the storage device itself. And then at the end we have the mount point in the system where the volume is mounted. If you need more information in the output, you can reformat the display to show what you need specifically, and you can find out more about the options for lsblk in the man pages, and find out which columns of information are available with the dash dash help option. All of this information that we see comes from the sys files system, or sfs.
The pseudo-files in that folder represent aspects of the devices attached to the system and our storage devices are no exception. Our block devices are represented in sys block. I can take a look at that with ls -l /sys/block, or at least there are symlinks to the actual device entries deep in the device history. You can see the same information in a different way by major and minor numbers in the /sys/dev/block folder. We can see that with ls -l /sys/dev/block.
And here are the major and minor numbers, symlink to the actual devices. And within the sys/fs folder there's entries for each file system and type that the system knows about. And within each of these are some parameters you can read about devices of that type. We can also take a look at what volumes and devices the system knows about in the /dev/disk folder. Within here they're organized in various ways such as by path and by UUID.
And of you want to take a look at all kinds of information about your disk or volume, here in Ubuntu you can use the udevadm command with the info argument along with a path to a disk. This shows the device path, the various ways that it can be accessed, and other information the system can read from the device. That's a few ways to get information about block devices on your system so you can get an idea about what they are and how to explore them if you need to in the future.
Join instructor Scott Simpson, as he shows how to manage and optimize file storage on Ubuntu Linux. First, learn how to create, modify, and mount partitions and filesystems, and manage swap space. Scott then combines these basics into more sophisticated solutions using volume management, and shows how to secure Linux storage and configure disk quotas and backup policies.
- Creating and modifying partitions
- Creating, modifying, and mounting filesystems
- Mounting encrypted partitions
- Creating redundant storage with RAID
- Working with physical volumes, volume groups, and logical volumes
- Securing filesystems with ACLs
- Backing up data