Friday, 23 August 2013

How to Find the Path of a Hard Drive or a Partition

Windows, partitions (drives) are automatically assigned a drive letter and almost always the C: drive contains the Windows installation and all of the user’s files.  Linux, however, is radically different.  In Linux “everything is a file” and storage devices such as hard drives and pen drives are not exceptions. In other words, you are not looking for a C: drive, you are looking for a file, for example /dev/sda or /dev/sda2.
sudo fdisk -l explained
  • sudo - sudo stand for super user do, basically you are running this command in Administrator mode. This gives the program permission to access important files.
  • fdisk -l - fdisk is the program, -l tells fdisk to list the storage devices and the partitions on them.
This tutorial will help you find the path to your hard drive or other storage device, as well as help you find the partitions on it.  (What is the difference between a drive and a partition?)
We will be using the fdisk command to generate a list of storage devices connected to your computer.  Fdisk is a utility for managing partitions, but it is also for useful for displaying information about storage devices.
Finding the path to a hard drive, or other storage device
Open a terminal window and type this command, then hit enter: (you should find a shortcut to terminal on the BootMed desktop)
sudo fdisk -l
(note the last character is l as in lollipop)
Now let’s examine the output:
In my results you will see two storage devices, my 42 gigabyte hard drive and my 8 gigabyte pen drive.  You will notice that the first line of each paragraph of information about a disk starts with Disk /dev/…
Lets examine the first line of information for the first disk:
Disk /dev/sda: 42.9 GB, 42949672960 bytes

After Disk we see /dev/sda, this is the path to that disk.
Next we see 42.9 GB, this is the size of the disk in human readable format, next is the size again, formatted for computers.
Below this is some miscellaneous information about the disk, then there is a blank line and then some information about the partitions.
Finding the path to a partition
Fdisk also shows us information about the partitions found on each disk.  You will find this information at the indented line starting with Device  Boot:
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400    7  HPFS/NTFS
/dev/sda2              13        5222    41838592    7  HPFS/NTFS
Here we can see the partitions that are on the /dev/sda storage device and their paths. There are two, /dev/sda1 and /dev/sda2, some computers will only have one. You can use the block size of each partition to determine which is larger. For example, we can tell that /dev/sda2 is many times larger than the other partition.
On important thing to note, you cannot simply go to /dev/sda2 and expect to find the files on that drive.  In Linux you have to first mount (connect to) a partition before you can access its files.  You will never find any files in the /dev/sda2/ directory, but instead you will find the files at /dev/sda2′s mount point.

0 comments:

Post a Comment