Unable to use or install-to SanDisk USB stick

Brief description of the problem :

Connecting a particular model of USB stick to the machine causes a Web-UI error.
Stick model : “SanDisk UltraFit USB 3.2 64GB” (tried 4 of them)(brand new sticks)
Of course, impossible to install Rockstor to this disk : webUI won’t work…

Rockstor version : 5.0.9-0 (Leap 15.6)

Detailed step by step instructions to reproduce the problem

On any machine running Rockstor, just plug a USB stick of this model and go to the Web-UI in Storage > Disks > Rescan.
You will get the following message : “Houston, we have a problem : […] not enough values to unpack (expected 2, got 1)”.

(then, if you remove this USB stick and click “Rescan” again, everything goes well)

Web-UI screenshot

Error Traceback provided on the Web-UI

Traceback (most recent call last):

File “/opt/rockstor/src/rockstor/rest_framework_custom/generic_view.py”, line 41, in _handle_exception
yield

File “/opt/rockstor/src/rockstor/storageadmin/views/disk.py”, line 418, in post
return self._update_disk_state()
^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/lib64/python3.11/contextlib.py”, line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^

File “/opt/rockstor/src/rockstor/storageadmin/views/disk.py”, line 115, in _update_disk_state
attached_disks = scan_disks(MIN_DISK_SIZE)
^^^^^^^^^^^^^^^^^^^^^^^^^

File “/opt/rockstor/src/rockstor/system/osi.py”, line 330, in scan_disks
blk_dev_properties: dict = {
^

File “/opt/rockstor/src/rockstor/system/osi.py”, line 336, in
for key, value in (
^^^^^^^^^^

ValueError: not enough values to unpack (expected 2, got 1)

Analysis :

Looking at the code in “/opt/rockstor/src/rockstor/system/osi.py” around line 330 as said in the traceback, I saw the issue comes when it tries to parse the output of the “LSBLK” command, so I ran it myself and found out what makes the Web-UI bug :

  • In the LSBLK output line about my USB stick, the VENDOR field is : VENDOR=" USB "
  • In the “osi.py” file, line 336, the code is
    for key, value in (
    key_value.split(“=”) for key_value in line.strip().split('" ')
    )

As this USB stick has its “VENDOR” field starting with a whitespace, the split('" '") function does a “wrong split”, cutting in the middle of this “VENDOR” field, which causes the error.

Workaround :

As a workaround, I changed the above line.strip().split(‘" ‘) in “osi.py” into re.findall(r’\S+=“{1}[^”]*"{1}’, line) and made a reboot of the system.
It works like a charm now !

For beginners having this problem, you can :

  • on the Web-UI, go to System > Services, and turn on the “Shell in a box” service
  • open the “System shell” in the Web-UI
  • login with your admin account
  • type su to continue with root privileges. When password is asked, type the root password.
  • run nano /opt/rockstor/src/rockstor/system/osi.py
  • use [Ctrl] + [Shift] + [-] keys to open the “Go To Line” tool and go to line 336
  • do the above changes in the code
    Note : if you copy/paste code from above, be aware of the quotes : use only “straight” quotes, not “round” quotes as the forum automatically displays :wink:
  • use [Ctrl] + [o] to save changes
  • use [Ctrl] + [x] to exit Nano editor
  • type reboot to reboot the system

Hope this may help people having the same problem, and hope it may help developpers to remove this issue in the next versions.

Regards,
David

2 Likes

Hi @dadoubou ,

Well done on identifying that issue, getting a fix, and taking the time to share it with others in such a clear way!

You’re 100% correct on the root cause there!
This is actually a bug that was discovered shortly after we released 5.0.9 and for which a fix was released in 5.0.11 (V5.0+ Testing Channel Changelog - #22 by phillxnet). If you activate the Testing channel (Software update — Rockstor documentation) and update to the latest version, you should now no longer see this issue (not that it matters much for you as you already fixed it yourself). I simply wanted to clarify this for those users encountering that problem as well.

Please let us know how it goes with the rest of your endeavor!

2 Likes