Skip to content

Mount a Hard Drive

Jason Charney edited this page Apr 5, 2017 · 3 revisions

🚧 NEW PAGE!

This page is a guide for mounting and unmounting an external drive be it a hard drive or a thumb drive on your Raspberry Pi Hacktop.

Where to plug it in

Mechanical harddrive do not fair well being plugged into the Raspberry Pi. Fortunately, the Motorola Atrix Lapdock has USB ports on it and can communicate with the Raspberry Pi.

From experience, when I plugged a Mechanical lapdrive in using a SATA-USB adapter, the drive would rapidly click and beep. It did this because the the Pi did not provide enough power. But when I plugged it into the lapdock, I didn't have that problem.

Mounting

For any instance, let's create a directory in the /mnt directory. I think it would be wise to set the ownership and group of that directory to pi so that when we do mount the device, we can use it.

$ sudo mkdir /mnt/disk
$ sudo chown pi:pi /mnt/disk

The next thing you want to do is see what devices you have available.

Without plugging aything in type sudo fdisk -l

$ sudo fdisk -l
...
Device         Boot  Start       End   Sectors  Size Id Type
/dev/mmcblk0p1        8192    131071    122880   60M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      131072 122142719 122011648 58.2G 83 Linux

Now plug in the device

$ sudo fdisk -l
...
Device         Boot  Start       End   Sectors  Size Id Type
/dev/mmcblk0p1        8192    131071    122880   60M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      131072 122142719 122011648 58.2G 83 Linux

Disk /dev/sda: 465.8 GiB 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minium/optimal): 512 bytes / 512 bytes
Dislable type: dos
Disk identifier: 0x42852f1e

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1          63 976768064 976768002 465.8G 83 Linux

So we know that the device we want to mount is located at /dev/sda1, but what type of system is it? It's not neceesary as mount can take a guess (-t auto), but if it picks wrong or if it doesn't recongize the file system, you should check the repo for the supported file system.

Basically, the mount command is this

$ sudo mount /dev/sda1 /mnt/disk

To unmount

That is just as easy.

$ sudo umount /dev/sda1 /mnt/disk

Note: there is only ONE n in umount, not two.

Some file systems need work

To use a LVM2 system, try to install these packages.

lvm2 dmeventd liblvm2cmd2.02 libreadline5

Then run these commands

$ sudo modprobe dm-mod				# load the module
$ sudo vgscan					# scan for LVM volumes. See note 1.
$ sudo vgchange -ay ubuntu			# Activate the volume. It will find the logical volumes.
$ sudo lvs					# Find the logical volume that has your root system.  See note 2.
$ sudo mkdir /mnt/disk				# Do this step and the next step if you haven't done so.
$ sudo chown pi:pi /mnt/disk
$ sudo fdisk -l					# do this to find the path to mount.
$ sudo mount /dev/mapper/ubuntu-root /mnt/disk

Notes

  1. An Ubuntu system would return it found a volume group called "ubuntu". A Fedora system would have something like "VolGroup00".
  2. On Ubuntu it would be "root" most likely. On Fedora it would be somethjng like "LogVol00".

Unmout should be the same as usual

$ sudo uname /dev/mapper/ubuntu-root /mnt/disk

Browse around with ls -l --color=always $PATH | less -eFMXR. You could also use ranger inside of xterm.

exFAT

Probably not related to this page, but probably is, let's say you have a thumbdrive you borrowed from windows and want to plug it in a new windows system. You get a message saying it can't read exFAT file format. Linux has got your back. Unplug that thumbdrive if it is still plugged in and run this command to install exFAT support.

sudo apt-get install exfat-fuse exfat-utils

Once done, you can plug your thumbdrive back in with out restarting and use the File Manger or the the console to access the exFAT file system.

Links

Setup

  1. [Assemble the Hardware](Assemble the Hardware)
  2. [Install the Software](Install the Software)
  3. 🆙 [Setup your Raspberry Pi](Setup your Raspberry Pi)
  4. [Download the Missing Parts](Download the Missing Parts)

Typical Utilities

  • [Downloading and extracting with curl and tar](curl and tar)
  • [Browsing with ls and cat](ls and cat)
  • [Searching with grep and find](grep and find)
  • [Filtering with sed and awk](sed and awk)
  • [Piping with less, pv, and tee](less, pv, and tee)
  • Monitor your system with htop
  • Multiplex with tmux

Clone this wiki locally