Pi-Cloud

Pi-Cloud

Tags
Hardware
DIY
Repurposing
cover
2013-07-21_11-10-23-1020.1419979738.jpg.webp
Published
November 25, 2023

Mobile cloud with NextcloudPi

Inspiration for this project

Back in 2014 when I was in High-School I had this SanDisk Connect wireless usb flash, and I love it!
notion image
Now these are only useful when plugged in as the app that use to read the files is not supported anymore. I wanted to see if it would be possible to create something similar or better but with open-source software and somewhat open-hardware.
Raspberry pi Zero 2w with PiSugar
Raspberry pi Zero 2w with PiSugar
Raspberry Pi zero 2w
Raspberry Pi zero 2w
This is the device that I built. I cannot access all the files directly from the USB connection because Nextcloud store the files in www-data with a group named the same that has access to it. It would also be a security hole if I my pc or any pc has access to everything over usb, so for now it is separated.
 
🚨
DISCLAIMER! While I technically got Nextcloud to boot and serve the website to my phone like I wanted it to, it did not do any much more than that. The load speed are atrocious and the pi would crash pretty often because of lack of ram or compute. Even with workarounds like setting up everything on a Raspberry pi 4 and then using the zero 2w to serve it would hang up and not run at all. Indexing all the data was also complicated. I noticed that some of micro-sd cards - Sandisk Ultra 1TB, Sandisk Extreme 1TB & 256GB would get really warm to the touch a couple of minutes after inserting it while my - Teamgroup Pro 1TB, Lexar Nintendo 1TB, and PNY Elite 32GB did not. I never none of the SD cards to store more than 20GB of data because the raspberry pi would just not give me any responses over SSH or Browser… The only time that it sort of worked was with the PNY Elite 32GB but that is a low amount of storage for what I wanted and it still was too slow. For now I think a SBC with more ram and better chip might be a better fit for Nextcloudpi 😞 Now I will pivot from having Nextcloud to maybe something like Internet-in-a-box, or PWNAGOTCHI.

Parts list

  1. Raspberry pi zero 2w. The RPi Zero W is not 64 bits and it is really underpowered with its single core cpu.
  1. MicroSD Card.
  1. power bank with a short micro usb cable or a PiSugar.

Steps:

Install and update NextcloudPi
Install NextcloudPi on the MicroSD card using raspberry pi Imager or Balena Etcher.
Raspberry pi Imager makes setting up SSH, Wifi, and Localhost a breeze so I would go with that one to keep it simple.
After Installing the OS, inserting it on the raspberry pi and turning on the raspberry pi.
🚨
Using a more powerful raspberry pi to setup the nextcloud with all the data makes the process a lot easier.
Run these commands to update and upgrade the OS.
The Install command is going to install these tools:
  • bridge-utils; We use it to bridge the eth0 to wlan0 and get internet on hosted wifi if the raspberry pi is connected to ethernet.
  • dnsmasq; We needed to be able to have dns & dhcp services on our small network to find the website as nextcloudpi.local instead of 192.168.10.1 or something similar.
  • hostapd; We needed to activate and setup our hosted wifi connection.
  • libqmi-utils; This includes some utilities for setting up QMI connections ie. WAN / Cellular connections.
  • udhcpc, DHCP server utility pretty much.
  • htop; This is to monitor my system resources when I am connected over SSH.
sudo apt-get update sudo apt-get upgrade sudo apt install bridge-utils dnsmasq hostapd libqmi-utils udhcpc htop
Configure the WIFI access point (hostapd)
sudo systemctl unmask hostapd sudo systemctl enable hostapd sudo nano /etc/hostapd/hostapd.conf
→ /etc/hostapd/hostapd.conf
This file will be empty, so copy and paste this configuration file and change it to your needs.
interface=wlan0 country_code=US # hw_mode is dependant on the wifi specs of your raspberry pi. # Oldest pi have a b connection but raspberry pi zero 2w have a b/g/n # Only hw_mode=b is compatible with hostapd on the raspberry pi zero 2w hw_mode=b # Use a channel not in use in your network channel=6 ht_capab=[HT40+] wmm_enabled=0 macaddr_acl=0 auth_algs=1 # Keep the SSID name the same as the localhost for simplicity sake. ssid=nextpi wpa_passphrase=changethispassword wpa=2 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP # Disable this to insure the AP is visible: ignore_broadcast_ssid=0 # This allows for the WLAN to be connected through ethernet. bridge=br0
sudo nano /etc/network/interfaces
allow-hotplug br0 iface br0 inet static address 192.168.10.1 bridge_ports wlan0 eth0
DAEMON_CONF="/etc/hostapd/hostapd.conf"
 
Configure a static IP for the wlan0 interface
Go to this file
sudo nano /etc/dhcpcd.conf
After getting on this file, write this at the end of the file and save it.
interface wlan0 static ip_address=192.168.10.2/24 denyinterfaces eth0 denyinterfaces wlan0
Control + x → Control + y → Enter
Configure the DNS & DHCP server (dnsmasq)
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo nano /etc/dnsmasq.conf
interface=wlan0 dhcp-range=192.168.10.10,192.168.10.30,255.255.255.0,24h
Add a new iptables rule
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
iptables-restore < /etc/iptables.ipv4.nat
Script Automation
Every-time that the RPI boots up, it will looks for the iptable to restore it.
sudo crontab -e
@reboot sudo qmistart ; sudo iptables-restore < /etc/iptables
Setup is Done
sudo reboot
And we are done!
 
sudo apt update sudo apt upgrade sudo apt install samba samba-common-bin mkdir ~/shared sudo nano /etc/samba/smb.conf [0smbshare] path = /home/<USERNAME>/shared writeable = yes browseable = yes public=no sudo smbpasswd -a 0smb sudo systemctl restart smbd hostname -I sudo nmcli device wifi hotspot ssid <example-network-name> password <example-password> https://www.raspberrypi.com/documentation/computers/configuration.html#enable-hotspot

Conclusion

After 2 weeks trying to figure out the issues with my setup, I feel somewhat defeated… But I think this was for the better and my idea of a mobile cloud is just best serve with a better SBC such as my Raspberry pi 4 (I already have one running Internet in a box with a next-cloud instance).
Troubleshooting this thought a lot more things about the different Raspberry pi and maybe SBC’s in general. All of this commands on the post I will be using then on my Raspberry pi 4 Dev setup, My Zero 2w will be seeing this commands agains once I decide if I want IIAB or pwnagotchi.
Lastly, While nextcloudpi defeated me now on my goal of achieving this ultra portable device. I will be trying again with a Radxa zero or orange pi zero 2w which both has more ram and better cpu’s. While using my Raspberry pi Zero 2w for something else.
updated 12/12/2023