Assigning mountpoints per USB port - raspberry-pi

I'm using a Raspberry Pi Zero W running Raspbian Jessie Lite. I have a Zero4U 4 port USB hub (it's permanently attached) I'm looking to assign a mountpoint to each USB port, so that any drive plugged into port 1 will always use the mountpoint /media/backup for example. Is this possible?
Thanks

Found the solution!
First, plug in a drive to the port you want to map a mountpoint to. Use sudo blkid to get the /dev/sd** path to the drive & note this down/remember it. I'll be using '/dev/sda1'
Second, use udevadm info --name=/dev/sda1 | grep disk/by-path, which should give you a readout something like:
S: disk/by-path/platform-20980000.usb-usb-0:1.3:1.0-scsi-0:0:0:0-part1
E: DEVLINKS=/dev/disk/by-id/usb-SanDisk_Cruzer_Switch_4C530001110415101044-0:0-part1 /dev/disk/by-label/BACKUP_1 /dev/disk/by-path/platform-20980000.usb-usb-0:1.3:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/5936-F7EA
It's the platform-20980000.usb-usb-0:1.3:1.0-scsi-0:0:0:0-part1 that we want. It might look fairly different depending on your device & hub. Copy it/note it down then open up fstab config sudo nano /etc/fstab and on a new line:
/dev/disk/by-path/platform-20980000.usb-usb-0:1.4:1.0-scsi-0:0:0:0-part1 /media/card exfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0
replace /media/card with the mountpoint you desire, and make sure the bit following /dev/disk/by-path/ matches what you copied earlier. The other options are variable depending on what you want.
Ctrl-X, Y, enter, to save fstab, then reboot and you should now have an auto-mounting usb port! You can repeat the previous steps for each port :)
Hope this helps anyone looking to do the same.

Related

Raspberry Pi Zero W not interacting with GSM HAT

I have Raspberry Pi Zero W and this hat.
I did the following things:
disabled login shell through serial in rasp-config
enabled serial port hardware in rasp-config
removed console=serial0 in /boot/cmdline.txt
added lines to /boot/config.txt:
enable_uart=1
dtoverlay=pi-miniuart-bt
Then I restart the RPI.
Problem...
But when I do sudo minicom -D /dev/serial0 (serial1, ttyS0, and ttyAMA0 doesnt work either), it says its offline...
Am I missing something?
Here are all the files that might be interesting:
cmdline.txt
config.txt
To switch the bluetooth controller to the mini-UART so you can use the PL011 UART to communicate with your HAT, you should specify
dtoverlay=miniuart-bt
Alternatively you can use
dtoverlay=pi3-miniuart-bt
which was kept around for backwards compatibility.

Raspberry Pi Losing Mounted Drive After Reboot

Brand new to the world of Pi - like so new that I had never even touched one until three days ago, and know very little about Linux... I have a Western Digital MyBook plugged directly into my router, and I've found I'm able to mount this as a drive with the following command:
sudo mount -t cifs -o user=yourusername,passwd=yourpasswd,rw,file_mode=0777,dir_mode=0777 //mybookIP/public /mnt/mybook
Unfortunately, it seems to drop this mount whenever I reboot. Anyone have a suggestion on how to make this permanent?
Based on the comments here, this is what I did:
First, in Terminal I ran:
sudo nano /etc/fstab
Once that was opened, I added the line:
//mbookIP/public /mnt/mybook cifs _netdev,username=yourusername,password=yourpasswd 0 0
Once I saved this I was able to reboot and the mounted drive was visible when it all loaded back up again.

LIRC irsend: could not connect to socket irsend: No such file or directory

I am trying to configure LIRC to work with my Raspberry 2B and a circuit I build with a transistor and a IR transmitter as explained in this tutorial
After the installation of LIRC, I followed all the steps and I added these two lines in /etc/modules
lirc_dev
lirc_rpi gpio_out_pin=36
Then I typed this in /etc/lirc/hardware.conf
LIRCD_ARGS="--uinput"
LOAD_MODULES=true
DRIVER="default"
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
LIRCD_CONF=""
LIRCMD_CONF=""
After rebooting, I added the configuration of my Samsung remote (BN59-00516A) to /etc/lirc/lircd.conf
Then I restarted LIRC again but when I run a command to send a IR frequency
irsend SEND_ONCE Samsung_BN59-00865A KEY_POWER
it complains with the following error:
irsend: could not connect to socket
irsend: No such file or directory
I am guessing this is a problem with my device socket, because in the hardware.conf file I set
DEVICE = "/dev/lirc0"
(just because the tutorial states it), but lirc0 file isn't within the folder.
I couldn't find any other question related to this problem and google didn't help me much either. Does anyone have any hint on this?
After googling a lot, I found out an update is needed to have everything working properly. In my case I did:
apt-get update, apt-get upgrade, rpi-update
Also, as pointed out in this other tutorial, depending on the Raspberry firmware, you might need to add this to /boot/config.txt
dtoverlay=lirc-rpi,gpio_in_pin=XX,gpio_out_pin=YY
Substitute X and Y for whatever pins you're using!
I had a similar problem and I solved it with this command:
sudo lircd --device /dev/lirc0
If you set the value of LIRCD_ARGS in /etc/lirc/hardware.conf to "--device /dev/lirc0", it should start lircd appropriately, when /etc/init.d/lirc is started at boot.
you need to run lircd. It will create two files (lircd and lircd.pid) at /var/run/lirc/:
lircd
I got the same error messages. But had all configurations done. The restart of the lirc daemon solved this issue by typing
$ sudo /etc/init.d/lirc restart
I think is useful to say that the gpio_in_pin=XX,gpio_out_pin=YY part of the /etc/modules can be double checked with
dmesg | grep lirc
which results in something like
[ 3.437499] lirc_dev: IR Remote Control driver registered, major 244
[ 5.472916] lirc_rpi: module is from the staging directory, the quality is unknown, you have been warned.
[ 6.621156] lirc_rpi: auto-detected active high receiver on GPIO pin 22
[ 6.622515] lirc_rpi lirc_rpi: lirc_dev: driver lirc_rpi registered at minor = 0
[ 6.622528] lirc_rpi: driver registered!
for /etc/modules containing
lirc_dev
lirc_rpi gpio_in_pin=23 gpio_out_pin=22

kernel panic - not syncing: Attempted to kill init ! on centos running on my embedded board

I am currently working on centos running on intel atom board. I mistakenly renamed lic-2.17.so to _libc-2.17.so
library on my board, when I reboot the board it is giving me below error.
[ OK ] Reached target Initrd Default Target.
systemd-journald[136]: Received SIGTERM
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
Is there any possible way to get back to the original state.
I entered into grub prompt and able to see cat /lib64/_libc-2.17.so. Not Sure,
how to rename this to original name
Thanks in advance.
Can you enter run-level 3 from grub?
if so,
sudo mv /lib64/_libc-2.17.so /lib64/libc-2.17.so
if you can't enter run-level 3, you can try using a live DVD/USB to run the above command, you're just going to have to manually search for the right partition which the incorrectly named file is located.
Otherwise, I'm afraid you're going to need to reinstall the OS.

Run commands on Raspberry Pi when external HDD is connected

I am using a Raspberry Pi to provide network access to a Western Digital media player that has no network interface. The player if just an external HDD and automatically mounts when it is connected.
The problem is that it's HFS formatted, so to be able to read and write it I have to unmount and then remount it with these commands:
sudo umount /dev/sda2
sudo mount -o force -t hfsplus /dev/sda2 /media/wdhdd/
Which works fine, but I don't want to have to SSH in via terminal to run these manually every time I reconnect the HDD.
Is there anyway to auto run a script when an external USB device is mounted?
Because this has to be done every time this USB device is plugged in, you should edit the procedures done when it is plugged in. You can find out more about this by visiting this explanation