How to access harddrive partition

Hello,
I know how to navigate the file system, see pictures and documents. However, I do not know how to access other HDD partitions where are my other data stored. Also I would like to access USB flash stick files. When I enter ls command I do not see a path to the USB files.

Hi,

To access your hard drive partitions we first need to obtain a block device name for the particular partition that we are trying to get access to. Open up your terminal and use fdisk command to list all disks and partitions available on your system:

$ sudo fdisk -l

Example fdisk command output is shown below:

Next, step is to mount the partition to any target directory which will allow us to access all files of any previously selected partition. In this case we will concentrate on accessing /dev/sdb2 partition.

To do that we first need to create a target directory. The good choice for this purpose is the /mnt/ directory which already exists. We have also a choice to mount the system partition directly into /mnt/ or we create a new directory anywhere on the filesystem. For example let’s mount the /dev/sdb2 partition to /mnt/my-data mount point.

First, we use mkdir command to create a new directory /mnt/my-data:

$ sudo mkdir /mnt/my-data

Next, we use mount command to mount /dev/sdb2 partition into /mnt/my-data target directory:

$ sudo mount /dev/sdb2 /mnt/my-data

At this stage our data on /dev/sdb2 partition are now accessible via /mnt/my-data directory. Using cd command we can navigate to /mnt/my-data directory. Once in the directory executing the ls command will list all files and directories.

Once we are finished working we may want to unmount the partition by executing the umount command:

$ sudo umount /mnt/my-data

We need to make sure that we are not inside your /mnt/my-data directory as this will trigger an umount: target busy error message .

Please note mounting partition manually as shown above will not make our partition persistently accessible after system reboot.

To make our partition available after system reboot we need to edit /etc/fstab file and add the following line:

/dev/sdb2 /mnt/my-data aut none 0 0

The above line inside the /etc/fstab will automatically detect your partition file-system and mount /dev/sdb2 partition into /mnt/my-data target directory after the system reboot.

In regards to your second question on how to access USB stick data, know that the procedure of mounting USB stick into a GNU/Linux file system is exactly the same as it is with hard drive partitions. See the following article for detailed instructions on how to access USB data on Linux system.

Hope this helps…

Lubos