This post has nothing to do with SQL Server, I just wanted to document a way to recreate a default shared folder on a QNAP NAS without having to recreate all of them and potentially losing some data.
Intro
I’ve previously moved the Web shared folder, that QNAP uses for its web server service, to a volume that was using 2 WD Red SSDs in RAID 1.
Recently, one of those two SSDs died after only 2 years of minimal usage, this ended up setting the volume as read-only and spammed me with the following warning.
Full warning message:
Shared Folders General [Shared Folders] The default shared folders (Web) do not exist. To restore these shared folders, go to “Control Panel > Shared Folders > Restore Default Shared Folders”
Another side effect of this, that makes no sense to me, is that it auto-disabled QNAP’s Multimedia Console even though that volume had nothing to do with the Multimedia Console service.
I’ve only needed the web server a little while and I don’t really care about the files stored on that volume.
And now I want that warning to stop and the Multimedia Console service to run again, so my first step was to delete said volume from the UI.
QNAP has a way of restoring default shared folders, but it’s unclear to me if it does that for all the other default shares (some of which I actually use) and if it deletes any of the data. So, even though I do take periodic backups of my NAS, I am not too keen on finding out the hard way if that deletes existing data or not.
Short detour into QNAP’s internal layout
All shared directories and their data live under the /share
directory.
QNAP maps each volume to a CACHEDEV#_DATA
directory under the /share
directory.
So the first volume is mapped to CACHEDEV1_DATA, the second volume would be CACHEDEV2_DATA and so on.
Then all the shares inside each volume have symbolic links pointing to them from the /share
directory.
So, in my case, the /share/Web
symlink would point to /share/CACHEDEV2_DATA/Web
.
All the shared folder related configuration is stored in the /etc/config/smb.conf
file.
The fix
Quick note: this needs SSH and the Admin account to be enabled, so, if you’re like me and keep them disabled, you’ll have to enable them before proceeding (this is temporary and you can disable them when done).
I connect to the NAS via SSH and I’m greeted by the main menu.
I press Q and Enter then confirm by pressing Y and Enter so that I can use the shell environment.
Then I navigate to the /share
directory.
1 | cd /share |
Directory structure
I remove the old symlink.
1 | rm Web |
From there I navigate to my remaining volume.
1 | cd CACHEDEV1_DATA |
Note that the directory already existed as a leftover from before it was migrated to the other volume.
Si I first remove it and then re-create it.
1 2 | rm -rf Web mkdir Web |
Then I also create the @Recicle directory, this is used by QNAP as a recycle bin for each shared folder.
1 | mkdir Web/@Recycle |
I then go back to the /share directory.
1 | cd /share |
And recreate the Web symbolic link so that it points to the directory I’ve just created.
1 | ln -s CACHEDEV1_DATA/Web Web |
Share configuration
Once that’s done, I use more (side note: Windows also has more that does pretty much the same thing) to read the /etc/config/smb.conf
configuration file.
1 | more /etc/config/smb.conf |
The block pertaining to the Web shared folder is obviously missing since it was erased when I’ve deleted the volume.
So I copy an existing block that has a similar configuration to the Web folder, In my case I picked the Download shared folder.
Here’s how that block looks:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | [Download] comment = System default share path = /share/CACHEDEV1_DATA/Download browsable = yes oplocks = yes ftp write only = no recycle bin = yes recycle bin administrators only = no qbox = no public = yes invalid users = "guest" read list = write list = [redacted] valid users = [redacted] inherit permissions = yes shadow:snapdir = /share/CACHEDEV1_DATA/_.share/Download/.snapshot shadow:basedir = /share/CACHEDEV1_DATA/Download shadow:sort = desc shadow:format = @GMT-%Y.%m.%d-%H:%M:%S smb encrypt = disabled strict allocate = yes streams_depot:check_valid = yes mangled names = yes create time = 2019:09:07:13:35:52:55 |
Note that I’ve redacted the values for the write list
and valid users
entries only here, in the config file they’re untouched.
I then open the file using vi.
1 | vi /etc/config/smb.conf |
Navigate to the end of the file, go into insert mode by pressing i add a new empty line and paste the previously copied block leaving an empty line between it and the previous block.
And then I update it so that it looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | [Web] comment = System default share path = /share/CACHEDEV1_DATA/Web browsable = yes oplocks = yes ftp write only = no recycle bin = yes recycle bin administrators only = no qbox = no public = yes invalid users = "guest" read list = write list = [redacted] valid users = [redacted] inherit permissions = yes shadow:snapdir = /share/CACHEDEV1_DATA/_.share/Web/.snapshot shadow:basedir = /share/CACHEDEV1_DATA/Web shadow:sort = desc shadow:format = @GMT-%Y.%m.%d-%H:%M:%S smb encrypt = disabled strict allocate = yes streams_depot:check_valid = yes mangled names = yes create time = 2019:09:07:13:35:52:55 |
I press the Esc key to exit insert mode and then : followed by w and q to save the file and quit vi
At this point the default shared folder is recreated and visible in QNAP’s UI, in Control Panel > Shared Folders, but I opt to restart the NAS just in case.
Conclusion
Didn’t expect WD Red SSDs to be so disappointing, but at least I’ve learned something new out of this.