Retrieve Wi-Fi Password on iPhone

I needed to share a Wi-Fi password for a network my iPhone regularly connects to, but I was not near at the time. This is with iOS 16.5, I’m not sure what versions this will work with. On the iPhone go into settings, then select Wi-Fi.

Settings

The default view shows what you are connected to and the nearby networks. Hit the Edit button at the top right of the screen to see stored networks instead of what’s nearby.

Wi-Fi

Select the network you want to examine.

Wi-Fi after hitting Edit

Hit the hidden password item. (the dots)

Network selected

It should prompt you for access. My phone used facial recognition. Then it will show you the password and let you copy it.

Password exposed

SNMP on Raspberry Pi and missing information

Last year I’d documented monitoring the drive usage on my raspberry. This week after configuring my pi to boot from an external USB drive and mount three partitions with different filesystems in each, vfat, ext4fs, and exFat, I realized that the exFat volume isn’t showing up in the results of snmpwalk.

wim@WimPi4-Backup:~ $ snmpwalk -Os -c public -v 2c localhost iso.3.6.1.2.1.25.2
iso.3.6.1.2.1.25.2.2.0 = INTEGER: 7998784
iso.3.6.1.2.1.25.2.3.1.1.1 = INTEGER: 1
iso.3.6.1.2.1.25.2.3.1.1.3 = INTEGER: 3
iso.3.6.1.2.1.25.2.3.1.1.6 = INTEGER: 6
iso.3.6.1.2.1.25.2.3.1.1.7 = INTEGER: 7
iso.3.6.1.2.1.25.2.3.1.1.8 = INTEGER: 8
iso.3.6.1.2.1.25.2.3.1.1.10 = INTEGER: 10
iso.3.6.1.2.1.25.2.3.1.1.31 = INTEGER: 31
iso.3.6.1.2.1.25.2.3.1.1.36 = INTEGER: 36
iso.3.6.1.2.1.25.2.3.1.1.38 = INTEGER: 38
iso.3.6.1.2.1.25.2.3.1.1.39 = INTEGER: 39
iso.3.6.1.2.1.25.2.3.1.1.50 = INTEGER: 50
iso.3.6.1.2.1.25.2.3.1.1.52 = INTEGER: 52
iso.3.6.1.2.1.25.2.3.1.2.1 = OID: iso.3.6.1.2.1.25.2.1.2
iso.3.6.1.2.1.25.2.3.1.2.3 = OID: iso.3.6.1.2.1.25.2.1.3
iso.3.6.1.2.1.25.2.3.1.2.6 = OID: iso.3.6.1.2.1.25.2.1.1
iso.3.6.1.2.1.25.2.3.1.2.7 = OID: iso.3.6.1.2.1.25.2.1.1
iso.3.6.1.2.1.25.2.3.1.2.8 = OID: iso.3.6.1.2.1.25.2.1.1
iso.3.6.1.2.1.25.2.3.1.2.10 = OID: iso.3.6.1.2.1.25.2.1.3
iso.3.6.1.2.1.25.2.3.1.2.31 = OID: iso.3.6.1.2.1.25.2.1.4
iso.3.6.1.2.1.25.2.3.1.2.36 = OID: iso.3.6.1.2.1.25.2.1.4
iso.3.6.1.2.1.25.2.3.1.2.38 = OID: iso.3.6.1.2.1.25.2.1.4
iso.3.6.1.2.1.25.2.3.1.2.39 = OID: iso.3.6.1.2.1.25.2.1.4
iso.3.6.1.2.1.25.2.3.1.2.50 = OID: iso.3.6.1.2.1.25.2.1.4
iso.3.6.1.2.1.25.2.3.1.2.52 = OID: iso.3.6.1.2.1.25.2.1.4
iso.3.6.1.2.1.25.2.3.1.3.1 = STRING: "Physical memory"
iso.3.6.1.2.1.25.2.3.1.3.3 = STRING: "Virtual memory"
iso.3.6.1.2.1.25.2.3.1.3.6 = STRING: "Memory buffers"
iso.3.6.1.2.1.25.2.3.1.3.7 = STRING: "Cached memory"
iso.3.6.1.2.1.25.2.3.1.3.8 = STRING: "Shared memory"
iso.3.6.1.2.1.25.2.3.1.3.10 = STRING: "Swap space"
iso.3.6.1.2.1.25.2.3.1.3.31 = STRING: "/"
iso.3.6.1.2.1.25.2.3.1.3.36 = STRING: "/dev/shm"
iso.3.6.1.2.1.25.2.3.1.3.38 = STRING: "/run"
iso.3.6.1.2.1.25.2.3.1.3.39 = STRING: "/run/lock"
iso.3.6.1.2.1.25.2.3.1.3.50 = STRING: "/boot"
iso.3.6.1.2.1.25.2.3.1.3.52 = STRING: "/run/user/1000"
iso.3.6.1.2.1.25.2.3.1.4.1 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.3 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.6 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.7 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.8 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.10 = INTEGER: 1024
iso.3.6.1.2.1.25.2.3.1.4.31 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.4.36 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.4.38 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.4.39 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.4.50 = INTEGER: 2048
iso.3.6.1.2.1.25.2.3.1.4.52 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.5.1 = INTEGER: 7998784
iso.3.6.1.2.1.25.2.3.1.5.3 = INTEGER: 8101180
iso.3.6.1.2.1.25.2.3.1.5.6 = INTEGER: 7998784
iso.3.6.1.2.1.25.2.3.1.5.7 = INTEGER: 4050768
iso.3.6.1.2.1.25.2.3.1.5.8 = INTEGER: 1200
iso.3.6.1.2.1.25.2.3.1.5.10 = INTEGER: 102396
iso.3.6.1.2.1.25.2.3.1.5.31 = INTEGER: 129057828
iso.3.6.1.2.1.25.2.3.1.5.36 = INTEGER: 999848
iso.3.6.1.2.1.25.2.3.1.5.38 = INTEGER: 399940
iso.3.6.1.2.1.25.2.3.1.5.39 = INTEGER: 1280
iso.3.6.1.2.1.25.2.3.1.5.50 = INTEGER: 130554
iso.3.6.1.2.1.25.2.3.1.5.52 = INTEGER: 199969
iso.3.6.1.2.1.25.2.3.1.6.1 = INTEGER: 6165176
iso.3.6.1.2.1.25.2.3.1.6.3 = INTEGER: 6165176
iso.3.6.1.2.1.25.2.3.1.6.6 = INTEGER: 1999616
iso.3.6.1.2.1.25.2.3.1.6.7 = INTEGER: 4050768
iso.3.6.1.2.1.25.2.3.1.6.8 = INTEGER: 1200
iso.3.6.1.2.1.25.2.3.1.6.10 = INTEGER: 0
iso.3.6.1.2.1.25.2.3.1.6.31 = INTEGER: 2051665
iso.3.6.1.2.1.25.2.3.1.6.36 = INTEGER: 0
iso.3.6.1.2.1.25.2.3.1.6.38 = INTEGER: 299
iso.3.6.1.2.1.25.2.3.1.6.39 = INTEGER: 1
iso.3.6.1.2.1.25.2.3.1.6.50 = INTEGER: 15690
iso.3.6.1.2.1.25.2.3.1.6.52 = INTEGER: 0
wim@WimPi4-Backup:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       493G  7.9G  465G   2% /
devtmpfs        3.6G     0  3.6G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           1.6G  1.2M  1.6G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/sda1       255M   31M  225M  13% /boot
/dev/sda3       6.8T  3.2T  3.7T  46% /media/WimPi4-Backup
tmpfs           782M     0  782M   0% /run/user/1000

You can see the last digit of the OID jumps from 50 to 52, with 50 being “/boot” and 52 “/run/user/1000”. It would make sense that 51 would be “/media/WimPi4-Backup”. I don’t know if the problem is due to the size being 6.8T or the filesystem being exFat.

Looking into this made me want to document some of the other snmp tricks I find interesting.

Looking at just a single drive with grep, in this case the root partition.

wim@WimPi4-Backup:~ $ snmpwalk -Os -c public -v 2c localhost iso.3.6.1.2.1.25.2 | grep "\.31 ="
iso.3.6.1.2.1.25.2.3.1.1.31 = INTEGER: 31
iso.3.6.1.2.1.25.2.3.1.2.31 = OID: iso.3.6.1.2.1.25.2.1.4
iso.3.6.1.2.1.25.2.3.1.3.31 = STRING: "/"
iso.3.6.1.2.1.25.2.3.1.4.31 = INTEGER: 4096
iso.3.6.1.2.1.25.2.3.1.5.31 = INTEGER: 129057828
iso.3.6.1.2.1.25.2.3.1.6.31 = INTEGER: 2051665

Translating between text and numeric versions of the snmp OIDs. I have seen demonstrations of this that go deeper than my system, and haven’t yet figured out how to get it to include the MIB details beyond the first level.

wim@WimPi4-Backup:~ $ snmptranslate 1.3.6.1.2.1.25.2
iso.3.6.1.2.1.25.2

This page gave me some hints on CPU and memory monitoring.

wim@WimPi4-Backup:~ $ snmpwalk -Os -c public -v 2c localhost iso.3.6.1.4.1.2021.10
iso.3.6.1.4.1.2021.10.1.1.1 = INTEGER: 1
iso.3.6.1.4.1.2021.10.1.1.2 = INTEGER: 2
iso.3.6.1.4.1.2021.10.1.1.3 = INTEGER: 3
iso.3.6.1.4.1.2021.10.1.2.1 = STRING: "Load-1"
iso.3.6.1.4.1.2021.10.1.2.2 = STRING: "Load-5"
iso.3.6.1.4.1.2021.10.1.2.3 = STRING: "Load-15"
iso.3.6.1.4.1.2021.10.1.3.1 = STRING: "0.59"
iso.3.6.1.4.1.2021.10.1.3.2 = STRING: "0.32"
iso.3.6.1.4.1.2021.10.1.3.3 = STRING: "0.20"
iso.3.6.1.4.1.2021.10.1.4.1 = STRING: "12.00"
iso.3.6.1.4.1.2021.10.1.4.2 = STRING: "12.00"
iso.3.6.1.4.1.2021.10.1.4.3 = STRING: "12.00"
iso.3.6.1.4.1.2021.10.1.5.1 = INTEGER: 59
iso.3.6.1.4.1.2021.10.1.5.2 = INTEGER: 32
iso.3.6.1.4.1.2021.10.1.5.3 = INTEGER: 20
iso.3.6.1.4.1.2021.10.1.6.1 = Opaque: Float: 0.590000
iso.3.6.1.4.1.2021.10.1.6.2 = Opaque: Float: 0.320000
iso.3.6.1.4.1.2021.10.1.6.3 = Opaque: Float: 0.200000
iso.3.6.1.4.1.2021.10.1.100.1 = INTEGER: 0
iso.3.6.1.4.1.2021.10.1.100.2 = INTEGER: 0
iso.3.6.1.4.1.2021.10.1.100.3 = INTEGER: 0
iso.3.6.1.4.1.2021.10.1.101.1 = ""
iso.3.6.1.4.1.2021.10.1.101.2 = ""
iso.3.6.1.4.1.2021.10.1.101.3 = ""
wim@WimPi4-Backup:~ $ snmpwalk -Os -c public -v 2c localhost iso.3.6.1.4.1.2021.4
iso.3.6.1.4.1.2021.4.1.0 = INTEGER: 0
iso.3.6.1.4.1.2021.4.2.0 = STRING: "swap"
iso.3.6.1.4.1.2021.4.3.0 = INTEGER: 102396
iso.3.6.1.4.1.2021.4.4.0 = INTEGER: 102396
iso.3.6.1.4.1.2021.4.5.0 = INTEGER: 7998784
iso.3.6.1.4.1.2021.4.6.0 = INTEGER: 1856952
iso.3.6.1.4.1.2021.4.11.0 = INTEGER: 1959348
iso.3.6.1.4.1.2021.4.12.0 = INTEGER: 16000
iso.3.6.1.4.1.2021.4.13.0 = INTEGER: 1200
iso.3.6.1.4.1.2021.4.14.0 = INTEGER: 1999656
iso.3.6.1.4.1.2021.4.15.0 = INTEGER: 4033748
iso.3.6.1.4.1.2021.4.18.0 = Counter64: 102396
iso.3.6.1.4.1.2021.4.19.0 = Counter64: 102396
iso.3.6.1.4.1.2021.4.20.0 = Counter64: 7998784
iso.3.6.1.4.1.2021.4.21.0 = Counter64: 1856952
iso.3.6.1.4.1.2021.4.22.0 = Counter64: 1959348
iso.3.6.1.4.1.2021.4.23.0 = Counter64: 16000
iso.3.6.1.4.1.2021.4.24.0 = Counter64: 1200
iso.3.6.1.4.1.2021.4.25.0 = Counter64: 1999656
iso.3.6.1.4.1.2021.4.26.0 = Counter64: 4033748
iso.3.6.1.4.1.2021.4.100.0 = INTEGER: 0
iso.3.6.1.4.1.2021.4.101.0 = ""
wim@WimPi4-Backup:~ $ snmpwalk -Os -c public -v 2c localhost iso.3.6.1.4.1.2021.11
iso.3.6.1.4.1.2021.11.1.0 = INTEGER: 1
iso.3.6.1.4.1.2021.11.2.0 = STRING: "systemStats"
iso.3.6.1.4.1.2021.11.3.0 = INTEGER: 0
iso.3.6.1.4.1.2021.11.4.0 = INTEGER: 0
iso.3.6.1.4.1.2021.11.5.0 = INTEGER: 23
iso.3.6.1.4.1.2021.11.6.0 = INTEGER: 0
iso.3.6.1.4.1.2021.11.7.0 = INTEGER: 145
iso.3.6.1.4.1.2021.11.8.0 = INTEGER: 211
iso.3.6.1.4.1.2021.11.9.0 = INTEGER: 0
iso.3.6.1.4.1.2021.11.10.0 = INTEGER: 0
iso.3.6.1.4.1.2021.11.11.0 = INTEGER: 98
iso.3.6.1.4.1.2021.11.50.0 = Counter32: 9645
iso.3.6.1.4.1.2021.11.51.0 = Counter32: 0
iso.3.6.1.4.1.2021.11.52.0 = Counter32: 35652
iso.3.6.1.4.1.2021.11.53.0 = Counter32: 2081635
iso.3.6.1.4.1.2021.11.54.0 = Counter32: 52147
iso.3.6.1.4.1.2021.11.55.0 = Counter32: 0
iso.3.6.1.4.1.2021.11.56.0 = Counter32: 0
iso.3.6.1.4.1.2021.11.57.0 = Counter32: 9693796
iso.3.6.1.4.1.2021.11.58.0 = Counter32: 9290848
iso.3.6.1.4.1.2021.11.59.0 = Counter32: 2942581
iso.3.6.1.4.1.2021.11.60.0 = Counter32: 2871454
iso.3.6.1.4.1.2021.11.61.0 = Counter32: 964
iso.3.6.1.4.1.2021.11.62.0 = Counter32: 0
iso.3.6.1.4.1.2021.11.63.0 = Counter32: 0
iso.3.6.1.4.1.2021.11.64.0 = Counter32: 0
iso.3.6.1.4.1.2021.11.65.0 = Counter32: 0
iso.3.6.1.4.1.2021.11.66.0 = Counter32: 0
iso.3.6.1.4.1.2021.11.67.0 = INTEGER: 4

The load section should be self-explanatory since it has string descriptions included in the data.

The swap section was explained as:
Total Swap Size: iso.3.6.1.4.1.2021.4.3.0
Available Swap Space: iso.3.6.1.4.1.2021.4.4.0
Total RAM in machine: iso.3.6.1.4.1.2021.4.5.0
Total RAM used: iso.3.6.1.4.1.2021.4.6.0
Total RAM Free: iso.3.6.1.4.1.2021.4.11.0
Total RAM Shared: iso.3.6.1.4.1.2021.4.13.0
Total RAM Buffered: iso.3.6.1.4.1.2021.4.14.0
Total Cached Memory: iso.3.6.1.4.1.2021.4.15.0

The systemStats section details some CPU information:
percentage of user CPU time: iso.3.6.1.4.1.2021.11.9.0
raw user cpu time: iso.3.6.1.4.1.2021.11.50.0
percentages of system CPU time: iso.3.6.1.4.1.2021.11.10.0
raw system cpu time: iso.3.6.1.4.1.2021.11.52.0
percentages of idle CPU time: iso.3.6.1.4.1.2021.11.11.0
raw idle cpu time: iso.3.6.1.4.1.2021.11.53.0
raw nice cpu time: iso.3.6.1.4.1.2021.11.51.0

wim@WimPi4-Backup:~ $ snmpwalk -Os -c public -v 2c localhost iso.3.6.1.4.1.2021.100
iso.3.6.1.4.1.2021.100.1.0 = INTEGER: 1
iso.3.6.1.4.1.2021.100.2.0 = STRING: "5.9"
iso.3.6.1.4.1.2021.100.3.0 = STRING: "$Date$"
iso.3.6.1.4.1.2021.100.4.0 = STRING: "Wed May 10 10:58:41 2023"
iso.3.6.1.4.1.2021.100.5.0 = STRING: "$Id$"
iso.3.6.1.4.1.2021.100.6.0 = STRING: " '--build=aarch64-linux-gnu' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=${prefix}/lib/aarch64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--prefix=/usr' '--sysconfdir=/etc' '--mandir=/usr/share/man' '--with-persistent-directory=/var/lib/snmp' '--enable-ucd-snmp-compatibility' '--with-cflags=-g -O2 -ffile-prefix-map=/build/net-snmp-9s20VA/net-snmp-5.9+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNETSNMP_USE_INLINE' '--with-ldflags=-Wl,-z,relro -Wl,-z,now' '--with-perl-modules=INSTALLDIRS=vendor' '--enable-as-needed' '--with-logfile=none' '--without-rpm' '--with-libwrap' '--with-openssl' '--without-dmalloc' '--without-efence' '--without-rsaref' '--with-sys-contact=root' '--with-sys-location=Unknown' '--with-mib-modules=smux ucd-snmp/dlmod mibII/mta_sendmail disman/event-mib ucd-snmp/diskio ucd-snmp/lmsen"
iso.3.6.1.4.1.2021.100.10.0 = INTEGER: 0
iso.3.6.1.4.1.2021.100.11.0 = INTEGER: 0
iso.3.6.1.4.1.2021.100.12.0 = INTEGER: 0
iso.3.6.1.4.1.2021.100.13.0 = INTEGER: 0
iso.3.6.1.4.1.2021.100.20.0 = INTEGER: 0

The most interesting detail in that section is the current system date.

wim@WimPi4-Backup:~ $ snmpwalk -Os -c public -v 2c localhost iso.3.6.1.4.1.2021.13.16
iso.3.6.1.4.1.2021.13.16.2.1.1.1 = INTEGER: 1
iso.3.6.1.4.1.2021.13.16.2.1.2.1 = STRING: "temp1"
iso.3.6.1.4.1.2021.13.16.2.1.3.1 = Gauge32: 46738

I thought I might have found the system temperature, but it varies from the commands I’ve been using to monitor the temperature.

wim@WimPi4-Backup:~ $ /usr/bin/vcgencmd measure_temp
temp=43.3'C
wim@WimPi4-Backup:~ $ cat /sys/class/thermal/thermal_zone0/temp
42842

If you have any suggestions if interesting things to monitor on the Pi with SNMP, please leave them in comments.

ORICO 2.5 inch USB C Hard Drive Enclosure

I had a couple of SSDs sitting around and wanted to use them over USB instead of leaving them sit on the shelf so I looked at inexpensive enclosures on Amazon and came up with ORICO 2.5 inch USB C Hard Drive Enclosure USB 3.1 Gen 1 to SATA III External Hard Drive Case for SSD HDD 9.5 7mm Tool-Free with UASP for under $10.

I’d definitely wanted a USB C interface on the device for the ease of connecting the cable. This version is supplied with a USB-C to USB-A cable which was good for connecting directly to a Raspberry Pi. They also sell a version that appears exactly the same but is supplied with a USB-C to USB-C cable.

This works as promised but I noticed the strange thing that it hides information about the disk that’s installed. The powered dock I used in my recent installation, the Vantec Nexstar, reports the actual drive name in linux, which leaves me a little more comfortable. Here’s the relevant dmesg output, followed by fdisk and usb details for the drive in the Vantec dock.

[75735.042244] usb 2-2.2: new SuperSpeed USB device number 6 using xhci_hcd
[75735.064039] usb 2-2.2: New USB device found, idVendor=174c, idProduct=5516, bcdDevice= 1.00
[75735.064079] usb 2-2.2: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[75735.064085] usb 2-2.2: Product: USB Mass Storage Device
[75735.064090] usb 2-2.2: Manufacturer: VANTEC
[75735.064095] usb 2-2.2: SerialNumber: AD41314000038
[75735.068759] usb-storage 2-2.2:1.0: USB Mass Storage device detected
[75735.072590] scsi host1: usb-storage 2-2.2:1.0
[75736.074134] scsi 1:0:0:0: Direct-Access     Samsung  SSD 850 EVO 1TB  EMT0 PQ: 0 ANSI: 5
[75736.074465] sd 1:0:0:0: Attached scsi generic sg1 type 0
[75736.080433] sd 1:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[75736.081152] sd 1:0:0:0: [sdb] Write Protect is off
[75736.081165] sd 1:0:0:0: [sdb] Mode Sense: 23 00 00 00
[75736.081818] sd 1:0:0:0: [sdb] No Caching mode page found
[75736.081832] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[75736.085623]  sdb: sdb1 sdb2
[75736.086411] sd 1:0:0:0: [sdb] Attached SCSI disk

wim@WimPi4-Backup:~ $ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: SSD 850 EVO 1TB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x928e5154

Device     Boot  Start        End    Sectors   Size Id Type
/dev/sdb1         8192     532479     524288   256M  c W95 FAT32 (LBA)
/dev/sdb2       532480 1953525167 1952992688 931.3G 83 Linux

wim@WimPi4-Backup:~ $ lsusb
Bus 002 Device 006: ID 174c:5516 ASMedia Technology Inc. USB Mass Storage Device
Bus 002 Device 003: ID 0bc2:ab38 Seagate RSS LLC Backup Plus Hub (Mass Storage)
Bus 002 Device 002: ID 0bc2:ab45 Seagate RSS LLC Backup+ Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0bc2:ab44 Seagate RSS LLC Backup Plus Hub
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
wim@WimPi4-Backup:~ $ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/3p, 5000M
        |__ Port 1: Dev 3, If 0, Class=Mass Storage, Driver=uas, 5000M
        |__ Port 2: Dev 6, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/3p, 480M

The Orico details:

[75201.010963] usb 2-2.2: new SuperSpeed USB device number 5 using xhci_hcd
[75201.032436] usb 2-2.2: New USB device found, idVendor=152d, idProduct=0576, bcdDevice=12.01
[75201.032455] usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[75201.032461] usb 2-2.2: Product: External Disk 3.0
[75201.032466] usb 2-2.2: Manufacturer: JMicron
[75201.032470] usb 2-2.2: SerialNumber: 000000778899
[75201.041093] scsi host1: uas
[75201.042342] scsi 1:0:0:0: Direct-Access     JMicron  Tech             1201 PQ: 0 ANSI: 6
[75201.045191] sd 1:0:0:0: Attached scsi generic sg1 type 0
[75201.045564] sd 1:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[75201.045572] sd 1:0:0:0: [sdb] 4096-byte physical blocks
[75201.045779] sd 1:0:0:0: [sdb] Write Protect is off
[75201.045785] sd 1:0:0:0: [sdb] Mode Sense: 53 00 00 08
[75201.046159] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[75201.050811] sd 1:0:0:0: [sdb] Preferred minimum I/O size 4096 bytes
[75201.050827] sd 1:0:0:0: [sdb] Optimal transfer size 33553920 bytes not a multiple of preferred minimum block size (4096 bytes)
[75201.053405]  sdb: sdb1 sdb2
[75201.053747] sd 1:0:0:0: [sdb] Attached SCSI disk

wim@WimPi4-Backup:~ $ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Tech
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x928e5154

Device     Boot  Start        End    Sectors   Size Id Type
/dev/sdb1         8192     532479     524288   256M  c W95 FAT32 (LBA)
/dev/sdb2       532480 1953525167 1952992688 931.3G 83 Linux

wim@WimPi4-Backup:~ $ lsusb
Bus 002 Device 005: ID 152d:0576 JMicron Technology Corp. / JMicron USA Technology Corp. Gen1 SATA 6Gb/s Bridge
Bus 002 Device 003: ID 0bc2:ab38 Seagate RSS LLC Backup Plus Hub (Mass Storage)
Bus 002 Device 002: ID 0bc2:ab45 Seagate RSS LLC Backup+ Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0bc2:ab44 Seagate RSS LLC Backup Plus Hub
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

wim@WimPi4-Backup:~ $ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/3p, 5000M
        |__ Port 1: Dev 3, If 0, Class=Mass Storage, Driver=uas, 5000M
        |__ Port 2: Dev 5, If 0, Class=Mass Storage, Driver=uas, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/3p, 480M

The Vantec device is designed to support one or two disks, while the Orico is a single disk device. I find the differences interesting. I’m left wondering if either device hides any important details of the SSD itself that might improve the performance or longevity.

Pi4 and USB Drive over 2TB

With my recent experience setting up a Pi400 with an external drive and network installation, I decided I wanted to try setting up a Pi4 to boot from a Seagate Backup+ Hub 8TB drive. What I found was that the default Raspbian installation can’t expand the root filesystem on a drive larger than 2TB because it configures the disk to use MBR partitioning scheme. What follows is how I worked around that to get the system working the way I wanted.

After going through the network installation process, I logged in and looked at the current state of the filesystem:

Linux WimPi4-Backup 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon May  8 09:47:19 2023 from 192.168.0.57
wim@WimPi4-Backup:~ $ cat /boot/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=aeb14624-02 rootfstype=ext4 fsck.repair=yes rootwait
wim@WimPi4-Backup:~ $ cat /etc/fstab
proc            /proc           proc    defaults          0       0
PARTUUID=aeb14624-01  /boot           vfat    defaults          0       2
PARTUUID=aeb14624-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
wim@WimPi4-Backup:~ $ ls -alF /dev/disk/by-partuuid/
total 0
drwxr-xr-x 2 root root  80 May  8 09:48 ./
drwxr-xr-x 7 root root 140 May  8 09:48 ../
lrwxrwxrwx 1 root root  10 May  8 09:48 aeb14624-01 -> ../../sda1
lrwxrwxrwx 1 root root  10 May  8 09:48 aeb14624-02 -> ../../sda2
wim@WimPi4-Backup:~ $ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  7.3T  0 disk
├─sda1   8:1    0  256M  0 part /boot
└─sda2   8:2    0  1.7G  0 part /
wim@WimPi4-Backup:~ $ lsusb
Bus 002 Device 003: ID 0bc2:ab38 Seagate RSS LLC Backup Plus Hub (Mass Storage)
Bus 002 Device 002: ID 0bc2:ab45 Seagate RSS LLC Backup+ Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 045e:0768 Microsoft Corp. Sidewinder X4
Bus 001 Device 004: ID 045e:0025 Microsoft Corp. IntelliEye Mouse
Bus 001 Device 003: ID 0bc2:ab44 Seagate RSS LLC Backup Plus Hub
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
wim@WimPi4-Backup:~ $ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/3p, 5000M
        |__ Port 1: Dev 3, If 0, Class=Mass Storage, Driver=uas, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/3p, 480M
        |__ Port 3: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 4: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 4: Dev 5, If 1, Class=Human Interface Device, Driver=usbhid, 12M

I ran the gdisk command to create a GUID Partition Table

wim@WimPi4-Backup:~ $ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.6

Warning: Partition table header claims that the size of partition table
entries is 0 bytes, but this program  supports only 128-byte entries.
Adjusting accordingly, but partition table may be garbage.
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

Warning: Invalid CRC on main header data; loaded backup partition table.
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.

Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!
Main header: ERROR
Backup header: OK
Main partition table: ERROR
Backup partition table: OK

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: damaged

Found valid MBR and corrupt GPT. Which do you want to use? (Using the
GPT MAY permit recovery of GPT data.)
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer: 1

Command (? for help): p
Disk /dev/sda: 15628053167 sectors, 7.3 TiB
Model: Backup+ Hub BK
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): E7CBB654-BC7B-49D9-839E-0067FF1C3A83
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 15628053133
Partitions will be aligned on 2048-sector boundaries
Total free space is 15623957100 sectors (7.3 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            8192          532479   256.0 MiB   0700  Microsoft basic data
   2          532480         4104191   1.7 GiB     8300  Linux filesystem

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

I looked to see the new partition ids of the volumes.

wim@WimPi4-Backup:~ $ ls -alF /dev/disk/by-partuuid/
total 0
drwxr-xr-x 2 root root  80 May  8 10:00 ./
drwxr-xr-x 8 root root 160 May  8 10:00 ../
lrwxrwxrwx 1 root root  10 May  8 10:02 3ecc3350-be31-438c-8876-76a6067d814e -> ../../sda2
lrwxrwxrwx 1 root root  10 May  8 10:02 74fb4bbc-f03a-4501-9b49-13b324f40a64 -> ../../sda1
wim@WimPi4-Backup:~ $ cat /boot/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=aeb14624-02 rootfstype=ext4 fsck.repair=yes rootwait

I had to modify the /boot/cmdline.txt and /etc/fstab files to update the PARTUUID values to the new vales in the GUID Partition Table. After modifying the files they now appear:

wim@WimPi4-Backup:~ $ sudo nano /boot/cmdline.txt
wim@WimPi4-Backup:~ $ cat /boot/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=3ecc3350-be31-438c-8876-76a6067d814e rootfstype=ext4 fsck.repair=yes rootwait

At this point I rebooted the device to make sure it still boots and the existing partitions get mounted correctly. I rebooted the Pi many times during this setup because I wanted to make sure each step was done properly.

wim@WimPi4-Backup:~ $ sudo systemctl reboot
wim@WimPi4-Backup:~ $ Connection to 192.168.0.66 closed by remote host.
Connection to 192.168.0.66 closed.

C:\Users\Wim>ssh 192.168.0.66
Linux WimPi4-Backup 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon May  8 10:10:44 2023 from 192.168.0.57
wim@WimPi4-Backup:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.7G  1.4G  213M  87% /
devtmpfs        3.6G     0  3.6G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           1.6G  1.2M  1.6G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/sda1       255M   31M  225M  13% /boot
tmpfs           782M     0  782M   0% /run/user/1000

So far so good. The issue now is that the root partition is only 1.7G in size. To fix this, I’m going to run fdisk, delete the root partition, and create it again in the same starting location but with the size I want.

wim@WimPi4-Backup:~ $ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sda: 7.28 TiB, 8001563221504 bytes, 15628053167 sectors
Disk model: Backup+ Hub BK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E7CBB654-BC7B-49D9-839E-0067FF1C3A83

Device      Start     End Sectors  Size Type
/dev/sda1    8192  532479  524288  256M Microsoft basic data
/dev/sda2  532480 4104191 3571712  1.7G Linux filesystem

Command (m for help): i
Partition number (1,2, default 2):

         Device: /dev/sda2
          Start: 532480
            End: 4104191
        Sectors: 3571712
           Size: 1.7G
           Type: Linux filesystem
      Type-UUID: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
           UUID: 3ECC3350-BE31-438C-8876-76A6067D814E
           Name: Linux filesystem

Command (m for help): d
Partition number (1,2, default 2):

Partition 2 has been deleted.

Command (m for help): n
Partition number (2-128, default 2):
First sector (34-15628053133, default 532480):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (532480-15628053133, default 15628053133): +500G

Created a new partition 2 of type 'Linux filesystem' and of size 500 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: N

Command (m for help): p

Disk /dev/sda: 7.28 TiB, 8001563221504 bytes, 15628053167 sectors
Disk model: Backup+ Hub BK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E7CBB654-BC7B-49D9-839E-0067FF1C3A83

Device      Start        End    Sectors  Size Type
/dev/sda1    8192     532479     524288  256M Microsoft basic data
/dev/sda2  532480 1049108479 1048576000  500G Linux filesystem

Command (m for help): w
The partition table has been altered.
Syncing disks.

wim@WimPi4-Backup:~ $ ls -alF /dev/disk/by-partuuid/
total 0
drwxr-xr-x 2 root root  80 May  8 10:21 ./
drwxr-xr-x 8 root root 160 May  8 10:08 ../
lrwxrwxrwx 1 root root  10 May  8 10:21 4178f32f-bc1b-474a-99b7-b750ce89fdd7 -> ../../sda2
lrwxrwxrwx 1 root root  10 May  8 10:21 74fb4bbc-f03a-4501-9b49-13b324f40a64 -> ../../sda1
wim@WimPi4-Backup:~ $ sudo nano /boot/cmdline.txt
wim@WimPi4-Backup:~ $ sudo nano /etc/fstab
wim@WimPi4-Backup:~ $ sudo systemctl reboot
wim@WimPi4-Backup:~ $ Connection to 192.168.0.66 closed by remote host.
Connection to 192.168.0.66 closed.

The GUID for the partition I changed has been changed, so I now need to update both the /boot/cmdline.txt and /etc/fstab files appropriately. I chose to only have the root partition set to 500 gigabytes instead of filling the entire drive because I wanted to have the majority of my drive formatted using the exFat filesystem to be able to plug the drive into a windows machine if I want to recover files directly from the drive.

After changing the partition table with fdisk and changing the /boot/cmdline.txt and /etc/fstab files I rebooted the machine once more to make sure it was operating from the new partition table, and then I ran the resize2fs command to resize the file system.

wim@WimPi4-Backup:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.7G  1.4G  213M  87% /
devtmpfs        3.6G     0  3.6G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           1.6G  1.2M  1.6G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/sda1       255M   31M  225M  13% /boot
tmpfs           782M     0  782M   0% /run/user/1000
wim@WimPi4-Backup:~ $ sudo resize2fs /dev/sda2
resize2fs 1.46.2 (28-Feb-2021)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 32
The filesystem on /dev/sda2 is now 131072000 (4k) blocks long.

wim@WimPi4-Backup:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       493G  1.4G  471G   1% /
devtmpfs        3.6G     0  3.6G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           1.6G  1.2M  1.6G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/sda1       255M   31M  225M  13% /boot
tmpfs           782M     0  782M   0% /run/user/1000
wim@WimPi4-Backup:~ $ sudo systemctl poweroff
wim@WimPi4-Backup:~ $ Connection to 192.168.0.66 closed by remote host.
Connection to 192.168.0.66 closed.

You can see that the filesystem has been resized from 1.7G to 493G. At this point I wanted to test my ssytem by plugging the drive into my windows machine. It all looked good, with a large amount of unalocated space on the drive. I used the windows Disk Managment tool to allocate that free space to a new volume and quick format it to exFat. I ejected it and restarted the Pi from the drive and reconnected.

wim@WimPi4-Backup:~ $ ls -alF /dev/disk/by-partuuid/
total 0
drwxr-xr-x 2 root root 100 May  8 10:34 ./
drwxr-xr-x 8 root root 160 May  8 10:34 ../
lrwxrwxrwx 1 root root  10 May  8 10:34 0a14a02f-ce46-4797-81dc-81e476205906 -> ../../sda3
lrwxrwxrwx 1 root root  10 May  8 10:34 4178f32f-bc1b-474a-99b7-b750ce89fdd7 -> ../../sda2
lrwxrwxrwx 1 root root  10 May  8 10:34 74fb4bbc-f03a-4501-9b49-13b324f40a64 -> ../../sda1
wim@WimPi4-Backup:~ $ sudo mkdir /media/`hostname`
wim@WimPi4-Backup:~ $ sudo nano /etc/fstab
wim@WimPi4-Backup:~ $ cat /etc/fstab
proc            /proc           proc    defaults          0       0
PARTUUID=74fb4bbc-f03a-4501-9b49-13b324f40a64  /boot           vfat    defaults          0       2
PARTUUID=4178f32f-bc1b-474a-99b7-b750ce89fdd7  /               ext4    defaults,noatime  0       1
PARTUUID=0a14a02f-ce46-4797-81dc-81e476205906  /media/WimPi4-Backup exfat defaults,uid=1000,gid=1000 0 2
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
wim@WimPi4-Backup:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       493G  1.4G  471G   1% /
devtmpfs        3.6G     0  3.6G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           1.6G  1.2M  1.6G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/sda1       255M   31M  225M  13% /boot
tmpfs           782M     0  782M   0% /run/user/1000
/dev/sda3       6.8T   10M  6.8T   1% /media/WimPi4-Backup

I edited the /etc/fstab file to include a third line for the new partition I wanted mounted with some extra options since it doesn’t support the ext4 file permissions and I wanted to make it easier to access.