Guessing Games
Linux has some compact tools for quickly finding out the filesystem of a given storage medium. We show you how to use these effectively.
|
Linux has some compact tools for quickly finding out the filesystem of a given storage medium. We show you how to use these effectively.
Linux can handle a wide variety of filesystems. However, in order to achieve problem-free use of a data storage device, it is a good idea to at least know what type of filesystem is on the device. Attempts to restore data on storage medium that have an unknown filesystem can be very difficult. Similar difficulties occur in situations in which you want to read a downloaded image of a DVD or an unknown data storage device and therefore have to incorporate it in the system. This can also be the case for new media, like recently purchased memory cards.
We take a closer look at the relevant out-of-the-box tools available for determining the correct type of filesystem. After that, we look at the partition and then the integration of the directory, which is made available via the network and the storage medium, into the system.
Mounting a filesystem is accomplished by a user with administrative rights on the mount command. Usually, this means as a root user. As part of the mount procedure, you should enter a mount point that tells the system where it should incorporate the filesystem in the local filesystem tree. If you do not enter a mount point, then the command pulls the prepared partitions or storage media into the filesystems table (/etc/fstab ) in order to find a directory that should serve as the mounting point.
There is a list of the filesystems that have already been incorporated in the /proc/mounts file. This file mirrors the kernel's information. The mounted filesystems table, /etc/mtab , was previously responsible for this task. Today, this table usually is a symbolic link to /proc/mounts .
The -t option in the mount command specifies the interpretation that the operating system applies to the type of the filesystem it will incorporate. Below, you can see an example of a call that mounts a partition in the /opt/usb-drive/ directory. This is the first partition of the second hard drive, and it has been formatted with ext3.
# mount -t ext3 /dev/sdb1 /opt/usb-drive
The types of filesystem that your system supports depends on the type of kernel components statically integrated or what has been loaded as a kernel module. In order to determine the correct type of filesystem, you can take the following approaches:
The first approach is frustrating and can take a long time. The second approach is reliable and works well. The third approach is appropriate when you don't want to bother with the first approach, and the second approach hasn't worked for reasons you don't know but would like to uncover.
Automatic identification of the filesystem type is accomplished in mount by calling the program either without the -t or explicitly with -t auto . mount will try to identify the filesystem with the help of the libblkid [1] library. If the filesystem is successfully identified, the program will mount the media without acknowledging this directly by using so-called silent mode.
Otherwise, mount evaluates the entries in the /proc/filesystems file. Figure 1 shows the file as it appears on an Ubuntu system. The entries marked with the nodev keyword indicate that no corresponding filesystem is currently allocated to a block device [2].
In most cases, mounting works like this, at least for common filesystems. These would include ext2/3/4, VFAT, and MS-DOS. Btrfs, XFS, and ZFS, on the other hand, are more difficult candidates for mounting. They need additional modules and potentially also more software packages. Once these needs are met, the corresponding versions of commands from fsck , mount , and mkfs also work with these systems.
The -v option causes mount to produce an additional status message once the process has been successfully completed. Listing 1 demonstrates this for a Fedora image, which mount recognizes as a CD/DVD (ISO 9660).
Listing 1
Mounting a Fedora disk image
# mount -v Fedora-Xfce-Live-x86_64-24-1.2.iso /tmp/usb-platte/ mount: /dev/loop0 is write-protected, mounting read-only mount: /dev/loop0 mounted on /tmp/usb-drive.
If the automatic detection function fails to identify the filesystem that is to be mounted, then you will be forced to switch over to the third approach described above and find out for yourself what type of filesystem you are dealing with. Fortunately, there are some on-board tools that work smoothly with this approach.
You can use fdisk and its convenient ncurse version, cfdisk, to arrange the partitions on the storage medium including setting up new partitions, deleting old ones, and setting a bootable flag to make a partition boot-ready. Use
fdisk /dev/sda -l
in the terminal to output the first hard drive's entire partition table. In a similar fashion,
cfdisk /dev/sda
puts the information you have searched for up on the screen for you to see.
fdisk and cfdisk usually only display the type of partition, meaning you only see filesystems that are potentially supported. This is common with Linux, Solaris, BSD, Mac OS X and Windows. We are a bit luckier with the mounted ISO image in Figure 2, and we have learned some useful details. The second entry contains a FAT filesystem.
Pages: 5
ZFS is one of the most advanced filesystems, and now it can be used natively on Linux. One drawback is that native ZFS encryption is not available, but this article shows how use Linux's disk encryption to install Ubuntu onto an encrypted disk with ZFS.
USB sticks and external hard drives can easily be lost or stolen. You should therefore protect these storage media against loss and misuse. UsbCryptFormat lets you do this without much effort.
The Obnam command-line tool allows backups and restores, even when the X server is on strike. Its many options will easily meet the needs of a SOHO environment.
GRUB 2 is more than just a system for booting from a disk. In this article, we'll provide an overview of the capabilities of the newest version of GRUB, GRUB 2.
© 2024 Linux New Media USA, LLC – Legal Notice