Aliquam erat volutpat

Proin pellentesque nunc et libero suscipit, a dictum mauris consectetur. Suspendisse mi ex, condimentum ac arcu lobortis, aliquet bibendum metus. Morbi felis ipsum, efficitur et sodales ac, placerat porttitor nisi. Cras id neque eu mi scelerisque placerat. Sed rhoncus efficitur leo, ac fringilla nunc pretium sit amet. Pellentesque elementum magna ornare eros tempus, id sodales lacus euismod. Quisque dapibus, magna sit amet ultrices pharetra, diam tortor ullamcorper turpis, scelerisque lobortis diam orci in est.

4 Likes

We appreciate you taking the time to provide this guide.

Hi,

When making changes as you mention, this will be override with a future firmware upgrade?

If for instance the changed config.xml is invalid (some mistake while closing a tag) what is the side effect, it is possible to recover without losing the precious disk content?

Changing this config.xml void the warranty, but after a software update it is possible to detect those changes?

Sorry for many questions but it seems that you have good knowledge not this :grin:

Thanks

So using your method are you able to save the modified config.xml back to the NAND flash - BECAUSE THAT IS how you can make changes persistent. And after reading this I am unsure if your method accomplishes that.

Actually, I had analyzed and custom-compiled the firmware code of EX2 3 years ago…so I do know a bit more than basic Linux facts. I asked my earlier question because I did not see in your original post any mention of the NAND partitions being read/write - but I now see that it’s mentioned there…not sure if that added in of your 5 edits to the original post, or it was there from the beginning…I don’t recall seeing it there earlier when I asked my question, but it’s possible I missed it.

Anyway, good to see that you figured out what seems to be an alternate way to get the keys to the kingdom…I felt the same way 3 years ago when within a week I had hacked EX2’s code…and took the bold but risky step to custom compile it and load it on my EX2.

Hi @dswv42, Thank you for the outstanding insight! I’m really pissed off by not being able to add to cron simple rsync jobs for backing up the NAS to USB. As extensively explored other threads the built it solution on the dashboard never completes the task. Maybe you could show us how to do such thing by pointing out how to edit the config.xml file in the nand partition.

Thanks!

Hi @dswv42. I own a EX4 instead of the 4100. Check out the partitions and blkid commands output:

# cat /proc/partitions

rootfs / rootfs rw 0 0
/dev/root / ext2 rw,relatime,errors=continue,user_xattr 0 0
sysfs /sys sysfs rw,relatime 0 0
mdev /dev tmpfs rw,relatime 0 0
proc /proc proc rw,relatime 0 0
cgroup_root /cgroup tmpfs rw,nosuid,nodev,noexec,relatime 0 0
memory /cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
ubi0:config /usr/local/config ubifs rw,relatime 0 0
squash /usr/local/tmp ramfs rw,relatime,size=105m 0 0
/dev/loop0 /usr/local/modules squashfs ro,relatime 0 0
tmpfs /mnt tmpfs rw,relatime,size=1024k,nr_inodes=0 0 0
tmpfs /var/log tmpfs rw,relatime,size=40960k,nr_inodes=0 0 0
tmpfs /tmp tmpfs rw,relatime,size=102400k,nr_inodes=20000 0 0
/dev/sda4 /mnt/HD_a4 ext4 rw,relatime,user_xattr,barrier=1,stripe=128,data=ordered 0 0
/dev/sdb4 /mnt/HD_b4 ext4 rw,relatime,user_xattr,barrier=1,stripe=128,data=ordered 0 0
/dev/sdd4 /mnt/HD_d4 ext4 rw,relatime,user_xattr,barrier=1,stripe=128,data=ordered 0 0
/dev/sde4 /mnt/HD_e4 ext4 rw,relatime,user_xattr,barrier=1,stripe=128,data=ordered 0 0
/dev/md1 /mnt/HD/HD_a2 ext4 rw,noatime,nodiratime,user_xattr,barrier=1,stripe=48,data=ordered,usrquota,grpquota 0 0
none /proc/bus/usb usbfs rw,relatime 0 0
/dev/sdc1 /mnt/USB/USB1_c1 ufsd rw,relatime,nls=utf8,fmask=0,dmask=0,force,user_xattr 0 0

# blkid -o list

device     fs_type label    mount point    UUID
-------------------------------------------------------------------------------
/dev/ubi0_0
           ubifs            (not mounted)  d6ecd034-8f8e-4d50-9dfd-222f985013c7
/dev/loop0 squashfs         /usr/local/modules 
/dev/sda1  linux_raid_member  (in use)     8d1319bb-64ff-3aff-ef17-b15d5db656ea
/dev/sda2  linux_raid_member 1 (in use)    79a7190c-6a6f-abfc-22ee-3092feec0922
/dev/sda4  ext4             /mnt/HD_a4     d9c223e2-0cb4-474c-9f59-69d5844e0115
/dev/sdb1  linux_raid_member  (in use)     8d1319bb-64ff-3aff-ef17-b15d5db656ea
/dev/sdb2  linux_raid_member 1 (in use)    79a7190c-6a6f-abfc-22ee-3092feec0922
/dev/sdb4  ext4             /mnt/HD_b4     809d7737-5fd4-4562-aa84-d5f0b22e31b5
/dev/sdd1  linux_raid_member  (in use)     8d1319bb-64ff-3aff-ef17-b15d5db656ea
/dev/sdd2  linux_raid_member 1 (in use)    79a7190c-6a6f-abfc-22ee-3092feec0922
/dev/sdd4  ext4             /mnt/HD_d4     2f953ec9-408d-4b00-bc4d-4a703195e699
/dev/sdc1  ntfs    Backup_RR /mnt/USB/USB1_c1 D8268EA9268E8868
/dev/sde1  linux_raid_member  (in use)     8d1319bb-64ff-3aff-ef17-b15d5db656ea
/dev/sde2  linux_raid_member 1 (in use)    79a7190c-6a6f-abfc-22ee-3092feec0922
/dev/sde4  ext4             /mnt/HD_e4     fc28f557-be9d-420f-a16f-2e12d25eb16b
/dev/md0   swap             <swap>         227ffad2-1b31-4134-9591-d60efb4d9c70
/dev/md1   ext4             /mnt/HD/HD_a2  cbbf678d-82a6-4790-b8c8-74081b801ffb

It seems that the NAND memory is mapped in ubifs by /dev/ubi0 (which is actually mounted to /usr/local/config and contains many .xml and .log files, as well as /dev/ubi0_0 which isn’t mounted.

# ls /usr/local/config/

CacheVolume
GAnalytics.xml-backup
access_lm.log
adjustTime
alert.xml
alert_email.conf
analytics_missed
certificate_https_all.pem
config.xml
dhcp6c.conf
dhcp6c.conf.bond0
dhcp6c.conf.egiga0
dhcp6c.conf.egiga1
dynamicconfig_config.ini
dynamicconfig_tmp.ini
ftp_download.xml
ga_default_flag
ganalytics
gid
gogoc.conf
group
hd_info.xml
hd_list.xml
hdd_white_list.xml
hosts
iconv_table
mail_event_conf.xml
mt-daapd.conf
mycl_id
mycloud.log
mycloud.log.1
onbrd.ini
orion.db
orion_cm.log
orion_cm.log.1
p2psettings.xml
passwd
passwd.webdav
power_schedule_info.xml
power_status
record_burn_in_fw_time
resolv.conf
routeap.conf
rtc-mfg-date.log
s3.conf
server.ca-bundle
server.crt
server.key
shadow
smbpasswd
sms_conf.xml
snmpd.conf
ssh_host_dsa_key
ssh_host_dsa_key.pub
syslog.conf
system.conf
tzmap.table
udhcpd.conf
udhcpd.conf.def
uid
usb_backup.xml
user.log
user.log.old
version.update
version_info
volume_encrypt.xml
wd_serial.txt
wdlog.conf
wdlog.filters
wdmcserver.log
wdmcserver.log.1
wdnas-rest-api.conf

I tried to mount /dev/ubi0_0 to check its contents but it yields:

# mount: /dev/ubi0_0 is not a block device

Which is as far as my superficial unix skills go :slight_smile:

Would you be interested in coaching me poke arround and dump some commands output here so we could maybe find a similar method to EX4 owners?

Regards

Rafael

Thanks for the orientation @dswv42 !

It did mount using:

# mount -t ubifs /dev/ubi0_0 /tmp/ubifs_flash

Here is the directory listing:

CacheVolume
GAnalytics.xml-backup
access_lm.log
adjustTime
alert.xml
alert_email.conf
analytics_missed
certificate_https_all.pem
config.xml
dhcp6c.conf
dhcp6c.conf.bond0
dhcp6c.conf.egiga0
dhcp6c.conf.egiga1
dynamicconfig_config.ini
dynamicconfig_tmp.ini
ftp_download.xml
ga_default_flag
ganalytics
gid
gogoc.conf
group
hd_info.xml
hd_list.xml
hdd_white_list.xml
hosts
iconv_table
mail_event_conf.xml
mt-daapd.conf
mycl_id
mycloud.log
mycloud.log.1
onbrd.ini
orion.db
orion_cm.log
orion_cm.log.1
p2psettings.xml
passwd
passwd.webdav
power_schedule_info.xml
power_status
record_burn_in_fw_time
resolv.conf
routeap.conf
rtc-mfg-date.log
s3.conf
server.ca-bundle
server.crt
server.key
shadow
smbpasswd
sms_conf.xml
snmpd.conf
ssh_host_dsa_key
ssh_host_dsa_key.pub
syslog.conf
system.conf
tzmap.table
udhcpd.conf
udhcpd.conf.def
uid
usb_backup.xml
user.log
user.log.old
version.update
version_info
volume_encrypt.xml
wd_serial.txt
wdlog.conf
wdlog.filters
wdmcserver.log
wdmcserver.log.1
wdnas-rest-api.conf

Which seems to be exactly the same contents of:

> ubi0:config /usr/local/config ubifs rw,relatime 0 0

I wonder if the OS loads content from that partition on boot, which would be logically similar to the PR4100 or if it has some different behavior considering that ubi0 is permanently mounted during normal operation.

Would you like me to check some file contents within that directory, or maybe devise a test by adding a basic edit to the config.xml files in those partitions and performing reboots?

Timestamps:

root@WDMyCloudEX4 root # ls -lh /usr/local/config/config.xml
-rwxr-xr-x    1 root     root       11.6K Apr 10 00:00 /usr/local/config/config.xml
root@WDMyCloudEX4 root # mount -t ubifs /dev/ubi0_0 /tmp/nand
root@WDMyCloudEX4 root # ls -lh /tmp/nand/config.xml
-rwxr-xr-x    1 root     root       11.6K Apr 10 00:00 /tmp/nand/config.xml
root@WDMyCloudEX4 root # ls -lh /usr/local/modules/default/config.xml
-rwxrwxr-x    1 root     root       10.6K Mar 21 07:30 /usr/local/modules/default/config.xml
root@WDMyCloudEX4 root # ls -lh /etc/NAS_CFG/config.xml
-rwxr-xr-x    1 root     root       11.6K Apr 10 00:00 /etc/NAS_CFG/config.xml
root@WDMyCloudEX4 root #

By the way, the <crond></crond> section in config.xml file structure in EX4 is exactly the same as your example extracted from PR4100. You won’t need to make any observations in the main guide on that regard.What is odd is that the <list> structure has 11 entries and the <count> number is 6, which seems a bit strange.

Except for the supposedly failback config.xml file you mentioned, they are all the same date / time. I wonder which one is the main partition and which one is the backup file. So I added slightly different cron jobs to each file and rebooted to find out.

:grimacing: tension :grimacing:

It did not brick! :relieved:

And the winner is…

/dev/ubi0_0 :astonished:

As it turns out the persistent config.xml file comes from the unmounted partition, similar behavior to PR4100 except it is far more simple since it only has one partition for that purpose.

With this I guess we can affirm that for EX4, and maybe EX2 and similar, in order to make persistent system changes you have to edit config.xml inside /dev/ubi0_0

Thank you for your help @dswv42 :clap: :+1:

As a follow up test, maybe someone who owns EX2 and other hardware versions could verify if the information we provided for PR4100 and EX4 covers all possible variations.

Gentlemen, pardon the intrusion in this thread, but I am really at a loss here, with my MyCloud Mirror and this thread is the only thing that was suggested to me, for help (and it might very well help me).

The problem I am facing with my NAS, is that all shares created have permissions of 777. In other words, open widely to the public. Obviously, I can change the permissions, after the shares are created, but every file copied to them will get 777 permissions. If I manually edit /etc/netatalk/afp.conf, and restart the corresponding processes, files copied to the shares do get the proper permissions I want, but the file /etc/netatalk/afp.conf, gets rewritten whenever the NAS is rebooted.

I followed this thread and mounted /dev/ubi0_0 and went through it, but I can’t find anything related to netatalk and afp, either in config.xml or any other .xml file in there.

Do you guys have any idea where I can intervene to change the afp.conf file, permanently?

Many thanks!

MANY THANKS for your reply, really appreciated!

One question, which perhaps can help me, without the need to access the SquashFS.

After the system is booted, can I just copy a modified afp.conf file to /etc/netatalk? The reason I am asking, is because if I manually change afp.conf file, after the system is booted, but before I mount the shares on my Mac, the system uses whatever permissions I have defined in the modified afp.conf. So I could -theoretically- save a modified afp.conf in one of my shares and copy that to /etc/netatalk before mounting the shares and have the proper permissions used.

Again, thanks!

Now I have to figure a way to do it. Maybe using a cron entry? hmmm time to think!

Update: I’ve managed to create a crontab entry, which copies a modified version of afp.conf to /etc/netatalk every 5 minutes (I wish I could just copy it once and be done with it, but I am not sure how to instract crontab to run the copy only once).

However, I strongly believe that this is a very serious issue, that Western Digital should address. It is crazy, for a consumer device, to need you to ssh to it, change the permissions manually, change the afp.conf file manually, and change ubi0_0 manually in order to set the NAS up, so that it sets safe permissions to whatever you copy to it. I have been using afp to mount disks from several different systems (including an Apple Server, a Centos-based server, an ancient Synology Cube station etc) all these afp implementations maintain the permissions of files copied, as they were in the original disk. So I have to assume that WD’s afp implementation is faulty.

Thanks are due to the participants of this discussion, for offering me the guidance to -somehow- fix a sever security issue affecting my MyCloudMirror device.

Thanks for some interesting concepts!

A while ago I posted some instructions how to run a user boot script. It’s also based on crontab hack.

You will find it here: How to run a user boot script at MyCloud Gen2 (2.11.xx) devices

Thank you dswv42 for this excellent guide!

Quick question: Is there any way to add a @reboot entry to the crontab?

Thanks.

What should be the best way to add a cronjob using @reboot?

Also, how can I add a ssh key persistently?

Thanks in advance.

If you have any app installed from the WD app store, you can modify the init / clean scripts to get persistent changes.

Example: persistent home directory (including .ssh dir with authorized_keys)

Go to the app directory.

cd /shares/Volume_1/Nas_Prog
ls

Pick an app, I’m using my entware package but you can use any dir that doesn’t start with an underscore.

cd entware

Prepare the home dir backup directory

mkdir -p home

Edit init.sh

vi init.sh

On app start (e.g. on boot), you want to restore your home directory to /home/root. Add this somewhere in the script. Press i to enter edit mode.

# the first argument is this application's directory
APPDIR=$1

# restore the home directory
rsync -a "${APPDIR}/home/" /home/root

Press escape to exit edit mode. Type :wq to write changes and exit.
Then edit clean.sh

vi clean.sh

On shutdown you want to backup your current home directory to {APPDIR}/home.
Press i for edit mode.

APPDIR=$1

# remove old backup
rm -rf "${APPDIR}/home"
# backup current home directory
rsync -a /home/root/ "${APPDIR}/home"

Press escape to exit edit mode. Type :wq to write changes and exit.

Now test the changes. We’ll check our if our .ash_history gets backed up. Use -a to show hidden files.

ls -a home            # nothing backed up yet
sh clean.sh .         # note the dot!
ls -a home            # tadaaaa!
2 Likes

You say you looked at the source for xmldbc. Where did you find it?

Is there absolutely no other option for scheduling jobs?

S3 backups from the GUI do not do what I need, crontab edits don’t stick, and I would rather not void the warranty. This is frustrating.

this worked for me.

edited init.sh of transmission

added

echo “* * * * * myscript.sh” >> /var/spool/cron/crontabs/root

my cron job get edited at reboot