Page 1 of 2

Solved- defective HW: Using an SD card for automated backup

PostPosted: Apr 18th, '21, 12:10
by hviaene
Mageia 8 Plasma on a laptop with a builtin card reader.
When I insert an SD card in the card reader, the system mounts it in /run/media/......, that works fine.
But now I try to use this card to automatically backup (in fact copy) some folders from the user's home to this card at login. That's done by making a liitle script with basically an rsync command, and use the Plasma systemsettings to make it run.
When testing after the card has been inserted, the script does work OK. Same when I logout/login the user. I then leave the card in place in the reader.
But when I reboot the system, the script runs after the user has logged in and fails and reports "/run/media/...... not found".
What is the trick to get this sd card mounted when the user logs in????

Re: Using an SD card for automated backup

PostPosted: Apr 18th, '21, 15:47
by doktor5000
Configure the devices applet to auto-mount this device upon login.

Re: Using an SD card for automated backup

PostPosted: Apr 24th, '21, 16:32
by hviaene
Tx, but with that the real problem shows up. And I tend to guess that the system is not behaving reliably.
On today' boot trials, the rsync command returned "I/O error", and plugging the SD card in and out did not show the card in anyway.
Running lsusb shows Realtek RTS5129, in MCC - HW the driver is listed as rtsx-usb.
On my last boot trial, I had the I/O error and the card does not show anywhere. But as soon as I had entered the lsusb command as the normal user, and the feedback was displayed, the device notifier sprung to life and I coud access the card. Coincidence ???????
The Realtekwebsite offers not much for this particular version of the device as far as I understand.

Re: Using an SD card for automated backup

PostPosted: Apr 24th, '21, 16:38
by hviaene
And that's not all: when the device notifier comes up, and I give the rsync command, I get "Read only file system". I have no idea why????

Re: Using an SD card for automated backup

PostPosted: Apr 24th, '21, 18:06
by doktor5000
Well, you don't provide any details. E.g. journal log excerpts after plugging the card, lsblk output and what filesystem is on that SD card - so how should we guess remotely what's wrong without more information?

Re: Using an SD card for automated backup

PostPosted: Apr 25th, '21, 11:15
by hviaene
You ask, here it is:
The SD card is vfat
Output of lsblk
Code: Select all
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   1,4T  0 disk
├─sda1   8:1    0   500M  0 part
├─sda2   8:2    0   100M  0 part /boot/EFI
├─sda3   8:3    0    16M  0 part
├─sda4   8:4    0  99,2G  0 part /
├─sda5   8:5    0   3,9G  0 part [SWAP]
└─sda6   8:6    0  1019G  0 part /home
sdb      8:16   0 465,8G  0 disk
├─sdb1   8:17   0    16M  0 part
└─sdb2   8:18   0 465,2G  0 part /media/windows
sdc      8:32   1   7,2G  0 disk /run/media/paul/F62D-9235
sr0     11:0    1  1024M  0 rom


The /run/media/paul/F62D-9235 is the USB stick I used to transfer the data to te desktop I'm responding on. So the card reader does not show.

The journalctl output (includes the plugging in of the USB-stick, the SD card is plugged in after that).
-- Logs begin at Fri 2021-04-16 11:20:45 CEST, end at Sun 2021-04-25 11:01:01 CEST. --

Code: Select all
apr 25 10:58:32 localhost systemd[1]: systemd-hostnamed.service: Succeeded.
apr 25 10:58:34 localhost plasmashell[1959]: Cyclic dependency detected between "file:///usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/global/Globals.qml" and "file:///usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/NotificationHeader.qml"
apr 25 10:58:34 localhost dbus-daemon[1870]: [session uid=1000 pid=1870] Successfully activated service 'org.freedesktop.Notifications'
apr 25 10:58:35 localhost plasmashell[1959]: kf.guiaddons: Error: could not load plugin for platform "" error: "The shared library was not found." QObject(0x0)
apr 25 10:58:35 localhost plasmashell[1959]: file:///usr/lib64/qt5/qml/org/kde/plasma/extras/PlasmoidHeading.qml:53:5: Unable to assign [undefined] to int
apr 25 10:58:35 localhost plasmashell[1959]: trying to show an empty dialog
apr 25 10:58:35 localhost plasmashell[1959]: file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Desktop.qml:146:19: QML Loader: Binding loop detected for property "height"
apr 25 10:58:35 localhost plasmashell[1959]: file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Desktop.qml:146:19: QML Loader: Binding loop detected for property "height"
apr 25 10:58:37 localhost plasmashell[1959]: file:///usr/lib64/qt5/qml/org/kde/plasma/components.3/ComboBox.qml:74:9: Unable to assign [undefined] to QQmlComponent*
apr 25 10:58:39 localhost dbus-daemon[1870]: [session uid=1000 pid=1870] Activating via systemd: service name='org.freedesktop.Tracker3.Miner.Extract' unit='tracker-extract-3.service' requested by ':1.32' (uid=1000 pid=2061 comm="/usr/libexec/tracker-miner-fs-3")
apr 25 10:58:39 localhost systemd[1777]: Starting Tracker metadata extractor...
apr 25 10:58:39 localhost tracker-extract[2398]: tracker-extract-3 running as org.freedesktop.Tracker3.Miner.Extract. The service will exit when org.freedesktop.Tracker3.Miner.Files disappears from the bus.
apr 25 10:58:39 localhost dbus-daemon[1870]: [session uid=1000 pid=1870] Successfully activated service 'org.freedesktop.Tracker3.Miner.Extract'
apr 25 10:58:39 localhost systemd[1777]: Started Tracker metadata extractor.
apr 25 10:58:49 localhost systemd[1777]: tracker-extract-3.service: Succeeded.
apr 25 10:58:54 localhost plasmashell[1959]: trying to show an empty dialog
apr 25 10:59:00 localhost kernel: FAT-fs (sdc): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
apr 25 10:59:00 localhost udisksd[788]: Mounted /dev/sdc at /run/media/paul/F62D-9235 on behalf of uid 1000
apr 25 10:59:00 localhost udisksd[788]: udisks_state_check_mounted_fs_entry: block device /dev/sdc is busy, skipping cleanup
apr 25 10:59:00 localhost systemd[1777]: Started kde-open5.
apr 25 10:59:01 localhost systemd[1777]: Started Dolphin - Bestandsbeheerder.
apr 25 10:59:01 localhost systemd[1777]: app-kde\x2dopen5-bb3d58e1ce0342c39b484f96d1c40044.scope: Succeeded.
apr 25 10:59:09 localhost plasmashell[1959]: trying to show an empty dialog
apr 25 10:59:10 localhost plasmashell[1959]: file:///usr/share/plasma/plasmoids/org.kde.plasma.kicker/contents/ui/ItemListDialog.qml:51: TypeError: Cannot read property 'separatorCount' of null
apr 25 10:59:10 localhost plasmashell[1959]: trying to show an empty dialog
apr 25 10:59:11 localhost plasmashell[1959]: file:///usr/share/plasma/plasmoids/org.kde.plasma.kicker/contents/ui/ItemListDialog.qml:51: TypeError: Cannot read property 'separatorCount' of null
apr 25 10:59:11 localhost plasmashell[1959]: trying to show an empty dialog
apr 25 10:59:13 localhost systemd[1777]: Started Konsole - Terminal.
apr 25 10:59:38 localhost su[2507]: (to root) paul on pts/0
apr 25 10:59:38 localhost su[2507]: pam_unix(su-l:session): session opened for user root by paul(uid=1000)
apr 25 10:59:38 localhost dbus-daemon[755]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.80' (uid=0 pid=2524 comm="/usr/bin/hostnamectl --transient")
apr 25 10:59:38 localhost systemd[1]: Starting Hostname Service...
apr 25 10:59:38 localhost dbus-daemon[755]: [system] Successfully activated service 'org.freedesktop.hostname1'
apr 25 10:59:38 localhost systemd[1]: Started Hostname Service.
apr 25 10:59:55 localhost kernel: mmc0: tuning execution failed: -22
apr 25 10:59:55 localhost kernel: mmc0: error -22 whilst initialising SD card
apr 25 11:00:00 localhost kernel: mmc0: tuning execution failed: -22
apr 25 11:00:00 localhost kernel: mmc0: error -22 whilst initialising SD card
apr 25 11:00:02 localhost kernel: mmc0: tuning execution failed: -22
apr 25 11:00:02 localhost kernel: mmc0: error -22 whilst initialising SD card
apr 25 11:00:08 localhost systemd[1]: systemd-hostnamed.service: Succeeded.
apr 25 11:01:01 localhost CROND[2599]: (root) CMD (nice -n 19 run-parts --report /etc/cron.hourly)
apr 25 11:01:01 localhost anacron[2604]: Anacron started on 2021-04-25
apr 25 11:01:01 localhost anacron[2604]: Will run job `cron.daily' in 40 min.
apr 25 11:01:01 localhost anacron[2604]: Jobs will be executed sequentially


I can add to that , that the SD card is handled perfectly OK on this desktop PC with a Hama multi-format card reader, and is also handled OK on the subject laptop in Win 10.

Re: Using an SD card for automated backup

PostPosted: Apr 25th, '21, 15:14
by doktor5000
For one, you didn't unmount the USB drive properly before removing it:

apr 25 10:59:00 localhost kernel: FAT-fs (sdc): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
apr 25 10:59:00 localhost udisksd[788]: Mounted /dev/sdc at /run/media/paul/F62D-9235 on behalf of uid 1000
apr 25 10:59:00 localhost udisksd[788]: udisks_state_check_mounted_fs_entry: block device /dev/sdc is busy, skipping cleanup


For the SD card, seems either the kernel is picky about the SD card reader or the SD card is damaged somehow. As you say it's working elsewhere, I'd say it's the former.
Code: Select all
apr 25 10:59:55 localhost kernel: mmc0: tuning execution failed: -22
apr 25 10:59:55 localhost kernel: mmc0: error -22 whilst initialising SD card
apr 25 11:00:00 localhost kernel: mmc0: tuning execution failed: -22
apr 25 11:00:00 localhost kernel: mmc0: error -22 whilst initialising SD card
apr 25 11:00:02 localhost kernel: mmc0: tuning execution failed: -22
apr 25 11:00:02 localhost kernel: mmc0: error -22 whilst initialising SD card


You could try something like mentioned here: https://www.0xf8.org/2016/01/workaround ... ion-4-1-8/ or at https://bugzilla.kernel.org/show_bug.cgi?id=109231#c1 or try a different SD card and/or reader.
Although I still wonder what has changed since the initial post, where you mentioned that manual mounting works fine - and now it doesn't mount anymore at all ?

Apart from that, I'd suggest not using an SD cards for backups, and definitely don't use FAT as a filesystem. It does not have journaling and has some other limitations including filesize.

Re: Using an SD card for automated backup

PostPosted: Apr 26th, '21, 11:08
by hviaene
Reading back what i've written before, I realize that at that time, I was happy I could READ the card, but I didn't try to wite onto it at the time.
In the mean time, I looked further googling and found that Realtek has two linux drivers available for their sd card readers, see https://www.realtek.com/en/component/zoo/category/card-reader-solutions-card-reader-controllers-software, but the versions don't quite match with what running lsusb shows: Realtek RTS5129. So I wonder whether one of these would help. I think I'll try your suggestion first.
As far as your remarks on the use and format of the sd card goes, I cann't do anything but accept and agree. But what I am trying to do is a simple and cheap solution to have some backup. I'm still considering whether I will simply supply the script so the user can start the operation manually, or put it in Plasma's autostart. In the end it will probably depend on the users wishes.

Re: Using an SD card for automated backup

PostPosted: Apr 27th, '21, 10:22
by hviaene
Inserted debug_quirks2="0x80000000" into the kernel parameters using grub-customizer. Checked on boot that the string is there.
But there is no effect on the output of lsusb and lsblk and the card does not show up immediately after logging in. Leaving the system running results in the device notifier coming up after a few minutes, but then I have to wait again before it can be mounted and eventually the card shows up, but read-only. Once there, it also shows up in the lsblk output as mmcblk0p1. All operations in dolphin (opening the folders) are very slow to respond.

Re: Using an SD card for automated backup

PostPosted: Apr 27th, '21, 17:35
by doktor5000
That is not a kernel parameter, it's an option for the sdhci module, it should be put into e.g. /etc/modprobe.d/sdhci.conf as
Code: Select all
sdhci debug_quirks2="0x80000000"


You also don't need to reboot to try that out. Simply unplug the card, then unload and reload the kernel module with this option:
Code: Select all
rmmod sdhci sdhci_pci sdhci_acpi
modprobe sdhci debug_quirks2="0x80000000"
modprobe sdhci_pci

Re: Using an SD card for automated backup

PostPosted: Apr 28th, '21, 14:50
by hviaene
I cpoied your statements to an USB stick, and transfer that one to the laptop, trying to avoid typo's.
First remark: there was no such file sdhci.conf, so I created it as root user ans inserted that line, nothing else.
Then i went to the commands as root user:
rmmod answered : "module xxxx not currently loaded" for each of the modules, seems fair enough.
But then, the " modprobe sdhci debug_quirks2="0x80000000" ' responded:
libkmod: kmod_config_parse: /etc/modprobe.d/sdhci.conf line 1: ignoring bad line starting with 'sdhci'
Searching showed me the line should read
options sdhci debug_quirks2="0x80000000"
Do I have that correct????
I'll come back later with feedback on the behavior of the card now, trying things out.

Re: Using an SD card for automated backup

PostPosted: Apr 28th, '21, 18:09
by doktor5000
hviaene wrote:Searching showed me the line should read
options sdhci debug_quirks2="0x80000000"
Do I have that correct????

Yes, that's what it should look like.

Re: Using an SD card for automated backup

PostPosted: Apr 29th, '21, 14:42
by hviaene
I'm still missing a step. When I do your commands, then I get two sdhci modules loaded, right??? I can see those with lsmod.
But when I reboot, these aren't there. I've been looking around so it seems I need to add two files for sdhci and sdhci_pci to /etc/modules-load.d/ directory , is that correct???

Re: Using an SD card for automated backup

PostPosted: Apr 29th, '21, 16:42
by doktor5000
/etc/modprobe.d/sdhci.conf only configures options which are automatically applied when this module is loaded, not if the module itself is loaded automatically.
So after a reboot it would be normal that you don't see this module.

If you insert your SD card, which module gets loaded ?

Re: Using an SD card for automated backup

PostPosted: Apr 29th, '21, 17:42
by hviaene
lsmod | grep sdhci returns nothing after reboot and sd card unplugged.
Plug in card and after wait for about 10 min. still nothing.
Entering then the modprobe commands seems to trigger something and the device notifier appears.
lsblk shows the mmcblk0 device and the mmcblk0p1 partition, but it doesn't get mounted. I had fthe filesystem ext4 on it and had been formatted.
mount command results: "structure must be cleaned". I ran e2fsck on it and each time it reports a lot of actions, but seldom a usable device. I have once been able to copy the whole /home of the user, but after the next boot, the device was again unreadable.

Re: Using an SD card for automated backup

PostPosted: Apr 29th, '21, 19:51
by doktor5000
It would help if you could post actual lsmod and lsblk outputs and maybe some journal excerpts, otherwise it's hard to tell remotely.

Do you unmount the SD card after you did your backup?

Re: Using an SD card for automated backup

PostPosted: Apr 30th, '21, 12:13
by hviaene
Do you want the complete lsmod or just a grep sdhci ???

Re: Using an SD card for automated backup

PostPosted: Apr 30th, '21, 13:40
by hviaene
I want to start with a clean sheet, so I formatted the sd card to ext4 on my desktop PC using MCC - Local disks. After that give the umount command - was not mounted. Unplugged the card, plugged in and the device notifier jumps up and I can open drom there dolphin.
Now i remark - and never noticed before, since I only read such cards e.g. from my photo camera - that the card is mounted in run/media/herman as owned by root and readonly for others. That is not what I need.
I'll try to find info on that.

Re: Using an SD card for automated backup

PostPosted: May 3rd, '21, 12:29
by hviaene
I will upload a zip file with the results of the lsmod and lsblk commands plus some journal info. You can see the sequence of the commands by the timestamp of the files.
What I've done - remember the /etc/modprobe.d/sdhci.conf is in place.
Started the laptop, no sdcard inserted, lsmod and lsblk output registered and journalctl -xe
Inserted the sd card and took lsmod and lsblk.
Wait more than 10 minutes, nothing happens, card is not detected.
Issue modprobe command, take card out and insert again: card is recognized , and took lsmod and lsblk. Also journalctl.
But, the card cannot be mounted. "structure needs cleaning". The same card is recognized immediately and mounts wthout problem on ,my desktop PC using an external card reader. And works perfectly OK with the same external card reader. on the offending laoptop

Re: Using an SD card for automated backup

PostPosted: May 3rd, '21, 16:55
by doktor5000
You didn't mention yet whether you properly unmount that SD card or not ...

Please don't use journalctl -xe but instead use journalctl -ab or -af, otherwise the log is not chronological. And at least add some information on the timestamp where you did what - do you expect somebody to search through all of those logs and figure that out themselves ?

This information would have been sufficient:

Code: Select all
mei 03 11:29:48 localhost kernel: mmc0: new ultra high speed SDR50 SDXC card at address aaaa
mei 03 11:29:48 localhost kernel: mmcblk0: mmc0:aaaa SC128 119 GiB
mei 03 11:29:48 localhost kernel:  mmcblk0: p1
mei 03 11:30:02 localhost kernel: EXT4-fs (mmcblk0p1): ext4_check_descriptors: Block bitmap for group 496 not in group (block 7404494481245863973)!
mei 03 11:30:02 localhost kernel: EXT4-fs (mmcblk0p1): group descriptors corrupted!

mei 03 11:32:28 localhost kernel: EXT4-fs (mmcblk0p1): ext4_check_descriptors: Block bitmap for group 24 overlaps superblock
mei 03 11:32:28 localhost kernel: EXT4-fs (mmcblk0p1): group descriptors corrupted!

mei 03 11:33:14 localhost kernel: mmc0: card aaaa removed


I don't see any module for sdhci so the card reader/card is driven by a different module, so it's normal that the options are not effective

Code: Select all
memstick               24576  1 rtsx_usb_ms
mmc_block              53248  0
mmc_core              192512  2 rtsx_usb_sdmmc,mmc_block

roles                  16384  1 intel_xhci_usb_role_switch
rtsx_usb               32768  2 rtsx_usb_sdmmc,rtsx_usb_ms
rtsx_usb_ms            24576  0
rtsx_usb_sdmmc         32768  0

usb_common             16384  3 xhci_hcd,usbcore,uvcvideo
usbcore               323584  6 xhci_hcd,usbhid,rtsx_usb,uvcvideo,btusb,xhci_pci
usbhid                 65536  0

xhci_hcd              307200  1 xhci_pci
xhci_pci               20480  0
xhci_pci_renesas       20480  1 xhci_pci

Re: Using an SD card for automated backup

PostPosted: May 4th, '21, 12:04
by hviaene
To answer your remarks:
1. I could not unmount since the card never got mounted in the first place.
2. Timestamps: each file has the timestamp it has been created by a command like lsmod > lsmodstart.txt. I think the names of the files indicate when in the sequence of events I described, have been generated.
3. Your question was "maybe some journal excerpts," , that's not very specific, is it. I don't know what you wanted to see. And I don't know what specifically to look for, otherwise I might not have been constrained to ask for help. As far as the -xe option goes, I'm used to, whenever in testing a service launching fails, to see the feedback "use journalctl -xe to get more info.
4. That there is another module is involved, I mentioned it in my posting of April 24 above. So it means we're back at square one: start the laptop without card, insert the card after the user has been logged in. There is a noticeable waiting time, then the card is recognized, but it cannot be mounted because the format is not recognized.

Re: Using an SD card for automated backup

PostPosted: May 4th, '21, 16:42
by doktor5000
The card is recognised, with indications of a damaged filesystem. If that is an actual issue with the filesystem or with the module that is used to access the SD card is something that you would have to test yourself.

Re: Using an SD card for automated backup

PostPosted: May 4th, '21, 16:57
by hviaene
No, as I stated before, the same card is accepted and mounts OK on my desktop PC with an external USB-card reader and on the offending laptop with the same external USB-card reader. The failure occurs with the internal card reader of the laptop.

Re: Using an SD card for automated backup

PostPosted: May 4th, '21, 18:07
by doktor5000
doktor5000 wrote:If that is an actual issue with the filesystem or with the module that is used to access the SD card is something that you would have to test yourself.

Sorry, can't help you any further.

Solved: Defective HW: Using an SD card for automated backup

PostPosted: May 5th, '21, 14:42
by hviaene
To Doktor 5000:
I just had a call from the owner of the laptop. I explained I had still problems with the card reader.
His reaction was : "I forgot to tell you, the laptop has also Win 10, and on Win 10 I have problems with that internal card reader as well, so I quit using it and use an exteranal USB-card reader".
I tested my procedure and rsync-script with my exteranal USB-card reader and all works perfectly. So I conlude that I spent a lot of time (and yours as well) on defective HW that probably will never work OK anymore in a consistent way. I returned the laptop and wished him goodluck.
Tx a lot and sorry for your efforts spent on this issue.