1

My device is Raspberry Pi 3B with Raspbian stretch lite OS installed. I was followed this tutorial to mount USB drive with my Raspberry Pi. But today my Raspberry Pi crashed for trying to uninstall transmission-daemon using sudo apt purge transmission-daemon. I'm not sure if it's the causes of the problem but after using this command I'm no longer able to connect my Raspberry Pi server with SSH or SFTP. To unmount the USB drive I need to use below commands:

$ sudo umount /mnt/pidrive1 
$ sudo fsck /dev/sda1

But I'm not even able to access with my Raspberry Pi with SSH. If I just unplug it from my Raspberry Pi and plug it on my PC, Windows asks me to format the USB drive. So how can I backup the USB drive?

Update: It seems like, my USB drive is corrupted or something after using transmission-daemon . I tried to format it but didn't work.

Edit: One more thing, after successfully installing transmission-daemon, I downloaded a 6gb torrent file with it. But it was stuck at 30%. Then I opened my Raspberry Pi with SFTP, it worked fine but the USB drive folder wasn't opening. Then I tried to restart my RPI with the command sudo reboot but reboot didn't work. Then I power off my RPI and power on again. Then I tried to open USB drive folder but still didn't work. Then I tried to uninstall transmission-daemon and the command stuck there. After half an hour later I power off my RPI and power on again then I wasn't able to access my RPI.

  • 2
    Not sure how to approach your question as it seems you've got a lot going on (i.e. potentially multiple issues). Let's try to clarify some things first: 1. What type of USB drive are you using? 2. What did fsck report after you ran it last? 3. Have you ever mounted an ext4 drive on your WIndows machine? – Seamus Aug 6 '18 at 12:30
  • @Seamus 1. My USB drive is TwinMOS X3 USB 30 and it's 32GB. 2. I don't remember the fsck report. 3. I don't know what is that. – Bangladesh 71 Aug 6 '18 at 13:41
  • 1. OK, so it's what some call a "thumb drive". 2. OK then, I'll assume there were no issues. 3. ext4 is the name of the file system that Raspberry Pi uses, and the one you set up when you followed the tutorial you referenced. So here's the thing: There's not enough info in your question to pinpoint the issue (no fault of yours - it's just the way it is), and I rather doubt that we could suss it all out here in the Comments section. So I'm going to post an "answer" that's more a series of things to try. Look for that later in the day or tomorrow. – Seamus Aug 6 '18 at 17:12
  • In the meantime, there is what appears to be a verified set of installation instructions for transmission-daemon on the RPi here. I don't know if you still want to use the transmission-daemon, but I do think you'll benefit from reading through this, and the follow-on questions. – Seamus Aug 6 '18 at 17:47
  • 1
    OK then, I'll post an answer soon. It won't be a complete answer because you'll need to make decisions that can't be made at this point. So we'll work out a way to do this without resorting to "extended discussions in comments", which are against the rules, and we're near the limit already :) – Seamus Aug 6 '18 at 18:19
2

It is very likely that your USB drive is formated with the ext4 filesystem. This is the default filesystem from Raspbian but Windows can't read it. There are some options to get access to your drive. The simplest solution is to use a pc with linux operating system of course, e.g. with Debian or Ubuntu. If not available or doable you can use a live system to boot from CD or USB stick. Most linux distributions can run as live system (Debian, Ubuntu, ...). There are also second party drivers available for Windows with that you can read ext4 with Windows. I have less experience with Windows so I can't tell you what drivers available. But there are many Windows guys here on the site. They can tell you what drivers best to use with Windows.

1

To amplify @Ingo's answer, if you followed the tutorial you referenced in your question, then your USB drive is formatted with the ext4 file system. Note that the ext4 file system is foreign to your Windows PC, and it won't read any device formatted with ext4 without installing some specialized software on Windows.

But let's take some steps to try to tackle your problem. Please be aware that due to your current situation (unable to access RPi), and the lack of details, I will have to make assumptions/guesses, and not all of them will be correct. I don't think I will make things worse, but that is a possibility. If you're OK with that, we'll proceed in an iterative fashion.

My best guess is that the tutorial you followed has led you into this situation. I don't understand what, if anything, purging the transmission-daemon had to do with this, but I feel there are two issues with that tutorial:
1. use of \dev\sda in lieu of a more specific label, and
2.failure to add the nofail option to your /etc/fstab configuration

This leads me to suspect that you can't login because the boot process has halted (due to lack of nofail in /etc/fstab), and this because it doesn't recognize your USB thumb drive for reasons we don't understand now.

Assuming that the red LED on your RPi is still illuminated when you apply power, I think you should first establish that your RPi can be restored to a functional state. There are two ways to do this:
1. Re-install stretch lite on your SD card, and start from the beginning
2. Edit the /etc/fstab file to remove the line you added to mount your USB drive.

Option 1. is likely to be quicker, easier and more certain, but if you have data on your SD card that you need to recover, then Option 2. will be our course of action. Just as a preview of Option 2, if you are considering that option, I will suggest that you create a bootable USB stick iaw this procedure. NOTE: You will need another USB stick for this unless you want to overwrite everything on the USB stick you've been using. This procedure will result in you running Ubuntu live on your Windows machine, but you won't install Ubuntu on your Windows PC (unless you elect to do so later). Running Ubuntu will allow you to mount your SD card (ext4 file system), and edit your /etc/fstab file.

I'll stop here, while you consider your options. Post a Comment to this answer when you've decided how you wish to proceed, or if you have questions. We'll pick up after I hear from you.

Status: stretch lite has been re-installed, and your RPi is pristine again :).

On the chance that your original USB drive (TwinMOS X3) has not been corrupted, we'll try to mount it first. Make an SSH connection to your RPi, then plug in the TwinMOS X3 USB drive. From your SSH terminal window enter the following:

lsblk --fs  

Hopefully, you will get something that looks similar to this, but it won't be an exact match:

NAME FSTYPE LABEL UUID MOUNTPOINT
sda
└─sda1 ext4 TWINMOSX3 5AFA-59C4

The important parts are that you have at least one partition (sda1 in this case, but it could be sdb1, etc), and the FSTYPE is ext4. The value in the LABEL column could be almost anything; it's a text string that can be changed. The UUID value is meaningless for our purposes because this is a USB drive (as opposed to a "real" drive).

Next, if your lsblk --fs output was similar to that above, check the USB drive with fsck. NOTE: Use the partition from the result above; sda1 in this case, but it could also be sdb1, etc.

sudo fsck /dev/sda1  

You should get something that looks like this:

fsck from util-linux 2.29.2
exfatfsck 1.2.5
Checking file system on /dev/sda1.
File system version 1.0
Sector size 512 bytes
Cluster size 32 KB
Volume size 15 GB
Used space 26 MB
Available space 15 GB
Totally 1 directories and 13 files.
File system checking finished. No errors found.

If you see the magic words No errors found, things are looking bright, and we should be able to mount the drive!

mkdir /home/pi/mntThumbDrv 
sudo mount /dev/sda1 /home/pi/mntThumbDrv  

Assuming no errors, check the contents:

ls -l /home/pi/mntThumbDrv  

Hopefully, you'll find all of the files here you expected to find.

If you do find there are errors on your drive, it likely means that it is corrupted, and should be re-formatted.

NOTE: Reformatting will overwrite any data on your drive, so if your drive is corrupted, but has data that you wish to try and recover, STOP HERE. Data recovery tools are available, but beyond the scope of this answer. Once you've committed to the re-format and overwrite, here's how to proceed:

sudo mkfs.ext4 /dev/sda1 -L TWINMOSX3-32GB  

Note that this command will format the partition sda1 using the ext4 file system and write a "label" -L (TWINMOSX3-32GB in this case) to the drive. The label should be descriptive, but most importantly make sure this label is a unique name; i.e. DO NOT apply this same label to any other USB/removable drive. I'll explain why in a moment.

With all of that successfully behind us, it's time to mount the drive. Following is the sequence I use, and it reflects my preferences, so feel free to alter it. There are a couple of steps you should not alter unless you have a reason for doing so; I've annotated those:

mkdir /home/pi/mntThumbDrv  
sudo mount /dev/sda1 /home/pi/mntThumbDrv  
touch testfile.txt  
echo "this is a test" > testfile.txt  
mv testfile.txt ~/mntThumbDrv  
cat ~/mntThumbDrv/testfile.txt  

Which should yield:

this is a test

If so, our drive is mounted properly, and working (pending any niggling permissions issues that can be addressed with chmod).

If this drive will find recurring use on this RPi, we'll want to automate the mount process. Unmount the drive first, and then edit /etc/fstab as follows:

sudo umount ~/mntThumbDrv  
sudo nano /etc/fstab  

This will open /etc/fstab in the nano text editor. Once open, add one line to /etc/fstab as follows:

LABEL=TWINMOSX3-32GB /home/pi/mntThumbDrv ext4 rw,user,nofail 0 0 

You should read man fstab and/or man mount to understand what this string means, and you may change these options as you choose. However:
1. Use the same LABEL string you assigned during the mkfs operation above
2. To avoid losing control of your system during reboot, you must include nofail as a mount option.

Save the edited file /etc/fstab, and exit the editor.

You should test your configuration to ensure it's working properly. With the USB drive still plugged into your RPi:

sudo mount -av  

Which should yield:

/proc : already mounted
/boot : already mounted
/ : ignored
/home/pi/mntThumbDrv : successfully mounted

Next, unmount and remove the USB drive from the RPi :

sudo umount ~/mntThumbDrv   

After physically unplugging the drive from the USB slot in the RPi, let's run mount as follows:

sudo mount -av  

Which should yield:

/proc : already mounted
/boot : already mounted
/ : ignored

Indicating that mount completed successfully. Note that the documentation suggests that nofail simply suppresses the error message, but in practice (at least on currently-configured RPi) absence of the nofail option for a missing drive seems to derail the boot process as well. Hopefully, this will be resolved in the future.

Hope this has helped. Much of this process is available at my GitHub site, which is updated from time to time.

  • @Bangladesh71: Once you've considered the two options I offered, please let me know how you'd like to proceed: 1. re-install Raspbian from scratch, or 2. attempt repair of your existing installation. – Seamus Aug 6 '18 at 23:53
  • Done and I want to re-install raspbian from scratch. – Bangladesh 71 Aug 6 '18 at 23:56
  • I successfully installed Raspbian and got access with SSH and SFTP but still I'm not able to use that USB drive with my Raspberry Pi. – Bangladesh 71 Aug 7 '18 at 0:40
  • Yes. That is what I have just mounted now. It's working fine but 16 GB. – Bangladesh 71 Aug 7 '18 at 1:20
  • Just done. So how to fix the USB drive? – Bangladesh 71 Aug 7 '18 at 1:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.