Search This Blog

Mounting a Drive With a Raspberry Pi



When you plug a USB hard drive or flash drive into a Raspberry Pi, you need to mount it to access the data on it. To do that, you need to know what name the OS has given the drive. So plug it in then run this command dmesg | tail. This will output something like this:

[ 1238.761341] sd 6:0:0:0: [sdb] 126058496 512-byte logical blocks: (64.5 GB/60.1 GiB)
[ 1238.762086] sd 6:0:0:0: [sdb] Write Protect is off
[ 1238.762091] sd 6:0:0:0: [sdb] Mode Sense: 43 00 00 00
[ 1238.763149] sd 6:0:0:0: [sdb] No Caching mode page found
[ 1238.763155] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[ 1238.766839] sd 6:0:0:0: [sdb] No Caching mode page found
[ 1238.766846] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[ 1238.767747]  sdb: sdb1 sdb2


You can see that the OS has referred to the drive as sdb, with two partitions sdb1 and sdb2. To mount sdb1, you can make a directory to mount it to:

mkdir ~/mydrive

Then mount it:

sudo mount /dev/sdb1 ~/mydrive

Now your drive is mounted at that location and all the files will be within the mydrive folder. Depending on the filesystem of the partition, you might need to change the ownership to write to the drive:

sudo chown -R your_username:your_username ~/mydrive


 

Quickly Set Up Your Raspberry Pi With This Easy Script


If you're wanting to quickly set up your Raspberry Pi for web projects, check out this script from GitHub user Xeoncross: lowendscript. It was created for use with low-resource VPS servers and removes a lot of the default programs that Debian comes with that you likely do not need.

This script is great for people that are looking to do web development and other web projects on their Raspberry Pi, but want their Pi running as efficiently as possible. However if you'd like to do your set up manually, I've talked about a few web project set ups here:

Setting up Apache on a Raspberry Pi
Setting up Nginx on a Raspberry Pi
Router Settings Going to a Raspberry Pi
Nginx and PHP on a Raspberry Pi

Changing the user password on a Raspberry Pi

To change your password on a Raspberry Pi, use the passwd command:

robert@rpi $ passwd
Changing password for robert.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 

passwd: password updated successfully

You will be asked for your current password, then to enter your new password twice to make sure you don't make a mistake.