Determining the filesystem for storage media

Slashdot it! Delicious Share on Facebook Tweet! Digg!

blkid

The blkid ("Block ID") tool reads the information to the filesystems, relying on the libblkid library previously mentioned. Listing 2 shows the call for the first partition of the first hard drive.

Listing 2

Using blkid

# blkid -ps TYPE /dev/sda1
/dev/sda1: TYPE="ext2"

The -p option makes sure that the tool ignores the information from the drive cache and instead accesses the data storage device directly. Since the output from blkid is typically very large, you should restrict it with the -s TYPE option for information about the filesystem. In Listing 3, you can see the information that blkid has found digging into the ISO image used in Figure 2. The TYPE option also contains the correct parameters that the mount program can use for attaching the filesystem to your directory tree.

Listing 3

Probing a Fedora ISO image

# blkid -s TYPE Fedora-Xfce-Live-x86_64-24-1.2.iso
Fedora-Xfce-Live-x86_64-24-1.2.iso: TYPE="iso9660"

blkid possesses additional useful capabilities. For example, it can check for the existence of particular filesystems and also display numerous pieces of detailed information. The option corresponding to this functionality is described on the program man page.

lsblk

The lsblk command outputs a list of block devices in a tree-like form. This makes mapping easier. The -f , long form --fs , option delivers the same information as:

-o NAME,FSTYPE,LABEL,MOUNTPOINT

In this way, you can see the details of how the individual storage media have been mounted.

The second column of the output contains information about the filesystem. Figure 3 shows sda1 (ext2), as well as sda5 (CryptoFS). Underneath you can see an LVM2 with logical volumes that have been set up and formatted as ext4 or swap. All of the filesystems have already been mounted.

Figure 3: lsblk offers easy to understand output in a tree-like form on all of the block devices.

Figure 4, on the other hand, shows an example with an ISO image that has been identified but not yet mounted. An ISO 9660 filesystem has already been allocated to the /dev/sr0 device. If needed, this can be mounted with the command:

# mount -t iso9660 /dev/sr0 /tmp/iso

In order for this to work, the /tmp/iso/ directory should already exist. If it doesn't, then you should first quickly set it up with:

mkdir /tmp/iso
Figure 4: Underlying the filesystem that has been recognized by lsblk, there is also an ISO image that has not yet been mounted.

Buy this article as PDF

Express-Checkout as PDF

Pages: 5

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content