Determining which partition is which

From openSUSE

Warning
This article describes advanced techniques using the rescue system to access your Linux file systems. If you are not comfortable using the command line interface (CLI) or if you don't understand disk partitions, you should not be using these procedures as you could damage or destroy your data.


Contents

Situation

If you find yourself in a place where you are trying to reconstruct the hard drive mounts (or worse yet, partition table) you may not know which partitions contains which file system.

To determine which partition or file system is which, you can temporarily mount each partition in turn, determine what directories and files are in each file system, and from this you can document which partition belongs to which mount point.

Procedure

You may utilize a LiveCD or rescue system to attempt mounting each partition to determine what is contained within it. The steps to mount are basically the following.

Listing the file systems

First, we need to a list of storage devices with filesystems to mount. We can usually just ask the kernel what partitions it is aware of:

cat /proc/partitions

To ask the hard drive for a list of partitions, which helps because the partition table also may include useful partition type information, perform the following. The device /dev/sda is most typical for modern computers as the primary hard drive. On older non-SATA systems, it is usually /dev/hda. If there are multiple drives, it is harmless to query a device using this method when you don't know for sure if it is the correct device. Just don't forget the lowercase L option which only lists and doesn't put you into partition edit mode.

fdisk -l /dev/sda

Mounting a file system

  • Get to a root (superuser/su) command prompt.
  • Mount the partition by using the following command. The displayed option mounts it as read-only, which is desired unless you plan to modify the file system. The most popular <mountpoint> is /mnt or a subdirectory created under it.
mount -o ro <device> <mountpoint>
  • Review the contents of the file system by using the following command:
ls <mountpoint>
  • Dismount the file system by using the following command:
umount <mountpoint>
  • Try the next file system by repeating the steps. Warning: be sure to dismount after each mount, or your mounted file systems might not dismount properly on shutdown and cause data corruption.

Mounting an encrypted file system

The modern method of file system encryption is with LUKS. To decrypt the file system to mount, you must know the partition password. Use the following command:

cryptsetup luksOpen <device> <devmapper-name>

Where <device> is the encrypted partition and <devmapper-name> is any name without spaces which will create an unencrypted device which can be used for mounting at /dev/<devmapper-name>. For example, using cryptsetup luksOpen /dev/sda3 home, means you can mount the now unencrypted device with mount /dev/mapper/home /mnt/home.

Determining which file system is mounted

Once you have mounted the unknown file system, for this article we'll say we mounted it to /mnt, you can view the contents to determine what is contained in it. The following table shows some examples of how to recognize each partition and where it is typically mounted in openSUSE.

Items on file system Typical mount point
boot/ boot.readme grub/ vmlinuz /boot
boot/ etc/ dev/ home/ proc/ sys/ / (root)
(a list of user accounts) /home
cache/ log/ run/ spool/ tmp/ /var
bin/ include/ local/ sbin/ share/ src/ /usr


Using /etc/fstab to associate mount points and partitions

Once you have found the root partition, you can usually match up the other mount points and partitions by reading the /etc/fstab file.

See Also