General Raspberry Pi stuff

Subjects that don't have their own home
Neal
Shed dweller
Posts: 2107
Joined: Fri Aug 03, 2007 10:57 am
Location: From the land of the Bodgers

#181 Re: General Raspberry Pi stuff

Post by Neal »

Posted for reference.

Finally getting around to using my Sunbow SSD for the RPi4.

Just in the process of copying files over using the USB-Boot Script here: https://www.raspberrypi.org/forums/view ... c25e158914

Stopped, pinhole, LMS, Portainer and Docker service first then updated the pi in the usual manner and went for the full upgrade to include the new firmware:
sudo apt-get update
sudo apt full-upgrade
sudo reboot

Then sudo bash boot-usb

To get boot-usb onto the Pi I downloaded on to the Mac first and used SCP to copy it over:
sudo scp ~/Downloads/usb-boot/usb-boot pi@192.168.1.3:/home/pi/usb-boot

Its currently copying and taking its time! And I'm getting hate because DNS is down and I can't be bothered to set DNS manually for each phone, iPad etc :D
Only the Sith deal in absolutes.
User avatar
jack
Eternally single
Posts: 4436
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#182 Re: General Raspberry Pi stuff

Post by jack »

Neal wrote: Mon Mar 29, 2021 11:49 am ...
Its currently copying and taking its time! And I'm getting hate because DNS is down and I can't be bothered to set DNS manually for each phone, iPad etc
8) I know the feeling...

Scheduled downtime is important for engineering upgrades and maintaining quality of service! Sell the positives!
Vivitur ingenio, caetera mortis erunt
Neal
Shed dweller
Posts: 2107
Joined: Fri Aug 03, 2007 10:57 am
Location: From the land of the Bodgers

#183 Re: General Raspberry Pi stuff

Post by Neal »

Well it started to a get a bit desperate, 2.5hrs in and it was still going......hmmmm, can't be right so aborted the usb-boot script and started digging, after a lot of disappearing down blind rabbit holes on the internet I decided to manually rsync the SD to the SSD with:

sudo rsync -aAXHv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt

This kicked off fine and as I watched the files scroll by I noticed it was copying my NAS drive and all my other mounts to the SSD Doh! :roll:

Abort again, format the SSD, unmount everything and re-run usb-boot...it finished in 5 mins and I was up and running on the SSD.

The USB-BOOT script is good but it doesn't show you progress during the copy so I had no-idea the mounts where being copied....live 'n' learn!
Only the Sith deal in absolutes.
User avatar
jack
Eternally single
Posts: 4436
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#184 Re: General Raspberry Pi stuff

Post by jack »

Really good article about SD cards; problems, solutions, what to look for etc.

https://picockpit.com/raspberry-pi/moni ... pberry-pi/

I had problems with my Unifi RPi, so I checked the SD card using:

Code: Select all

sudo fsck -fvn /dev/mmcblk0p2 | tee ~/fsck_p2
Also did the same for p1. P2 showed a bunch of errors, like a lot. You can't run fsck on a mounted filesystem, e.g. the system partition, and that can't be unmounted, so fsck has to be set to run after a reboot.

This is done by adding a command to the bootloader command line which when seen will cause fsck to repair the disk prior to it being mounted:

Code: Select all

sudo nano /boot/cmdline.txt
...and add the string "fsck.mode=force" into the SINGLE LINE command line. Do not include a line break and make very sure you get this right! Note that "fsck.repair=yes" is there by default and basically answers "yes" to any question during the process.
The old method of adding a file called /forcefsck at the root is deprecated and should not be used.

Code: Select all

Sep  4 11:49:06 UniFiController systemd-fsck[136]: Please pass 'fsck.mode=force' on the kernel command line rather than creating /forcefsck on the root file system.
After a reboot, a read-only fsck shows no errors! Phew.

However, the Unifi DB may still have issues, so I repaired the MongoDB by:

Code: Select all

sudo service unifi stop
sudo mongod --dbpath /usr/lib/unifi/data/db --smallfiles --logpath /usr/lib/unifi/logs/server.log --repair
sudo chown -R unifi:unifi /usr/lib/unifi/logs/server.log
sudo chown -R unifi:unifi /usr/lib/unifi/data/db
sudo service unifi start
Note that just doing a reboot without first orderly shutting down stuff writing to the SD card, e.g. Unifi (as it uses MongoDB), can damage the filesystem.

You can check when fsck was last used on a filesystem by using tune2fs, e.g.

Code: Select all

sudo tune2fs -l /dev/mmcblk0p2 | grep checked
and you can check the systemd log to confirm it ran during boot by using:

Code: Select all

sudo cat /var/log/syslog | grep fsck
...
Sep  4 15:05:07 UniFiController kernel: [    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1080 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  console=ttyS0,115200 console=tty1 root=PARTUUID=74bf6075-02 rootfstype=ext4 elevator=deadline fsck.repair=yes fsck.mode=force rootwait quiet splash plymouth.ignore-serial-consoles
Sep  4 15:05:07 UniFiController systemd-fsck[125]: e2fsck 1.44.5 (15-Dec-2018)
Sep  4 15:05:07 UniFiController systemd-fsck[125]: Pass 1: Checking inodes, blocks, and sizes
Sep  4 15:05:07 UniFiController systemd-fsck[125]: Pass 2: Checking directory structure
Sep  4 15:05:07 UniFiController systemd-fsck[125]: Pass 3: Checking directory connectivity
Sep  4 15:05:07 UniFiController systemd-fsck[125]: Pass 4: Checking reference counts
Sep  4 15:05:07 UniFiController systemd-fsck[125]: Pass 5: Checking group summary information
Sep  4 15:05:07 UniFiController systemd-fsck[125]: rootfs: 121152/943488 files (0.2% non-contiguous), 3089183/3822976 blocks
Sep  4 15:05:07 UniFiController systemd-fsck[254]: fsck.fat 4.1 (2017-01-24)
Sep  4 15:05:07 UniFiController systemd-fsck[254]: /dev/mmcblk0p1: 282 files, 98419/516190 clusters
Sep  4 15:05:36 UniFiController systemd[1]: systemd-fsckd.service: Succeeded.
...
Vivitur ingenio, caetera mortis erunt
User avatar
jack
Eternally single
Posts: 4436
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#185 Re: General Raspberry Pi stuff

Post by jack »

Environmental monitoring!!!

I want to use one of my older spare pi cards as an office environment monitor and thought of getting one of these hats:

https://thepihut.com/products/enviro-fo ... 6689887294

...and feeding the output to IFTTT or similar.


Anyone had any experience with these?
Vivitur ingenio, caetera mortis erunt
Post Reply