{"id":835,"date":"2022-06-29T20:13:12","date_gmt":"2022-06-29T18:13:12","guid":{"rendered":"https:\/\/spoton.cz\/?p=835"},"modified":"2022-07-01T22:18:37","modified_gmt":"2022-07-01T20:18:37","slug":"qnap-os-on-a-virtual-machine-and-how-to-save-data-with-cli","status":"publish","type":"post","link":"https:\/\/spoton.cz\/index.php\/2022\/06\/29\/qnap-os-on-a-virtual-machine-and-how-to-save-data-with-cli\/","title":{"rendered":"QNAP OS on a virtual machine and how to save data with CLI"},"content":{"rendered":"\n<h2>Enabling SSH<\/h2>\n\n\n\n<p>Since it is a real pain to work in an rdp, or a graphical console on 25&#215;80 characters, first thing we want to have is an ssh session to work with. From the convenient console of our liking, where we can paste and log. This took me some painful hours of guessing the commands from scripts and a lot of trial and error. Enjoy, Let&#8217;s get to it. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">setcfg LOGIN \"SSH Enable\" TRUE\n\/etc\/init.d\/login.sh start\n\n# if this is not enough, there is one config file that needs editing\nvi \/etc\/default_config\/uLinux.conf\n\n# search for this section and change the FALSE to TRUE for sshd Enable\n[LOGIN]             \nSSH Enable = TRUE \nSSH Port = 22 \nTELNET Enable = FALSE\nTELNET Port = 13131\n<\/pre>\n\n\n\n<p>What this does, is: <\/p>\n\n\n\n<p>1, create the ssh separation user, group (guest) and it&#8217;s directories, which is by the way<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[sshd]:x:110:65534:SSHD Privilege Separation:\/var\/empty:\/bin\/sh<\/pre>\n\n\n\n<p>2, it creates the rsa and dsa key pairs<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[~] # ll \/etc\/config\/ssh\/\ntotal 24K\ndrwxr-xr-x  2 admin administrators  200 Jun 29 19:59 .\/\ndrwxr-xr-x 21 admin administrators 2.5K Jun 29 20:00 ..\/\nlrwxrwxrwx  1 admin administrators   16 Jun 29 19:59 id_rsa -> ssh_host_rsa_key\nlrwxrwxrwx  1 admin administrators   20 Jun 29 19:59 id_rsa.pub -> ssh_host_rsa_key.pub\n-rw-------  1 admin administrators 1.4K Jun 29 19:59 ssh_host_dsa_key\n-rw-r--r--  1 admin administrators  605 Jun 29 19:59 ssh_host_dsa_key.pub\n-rw-------  1 admin administrators 2.6K Jun 29 19:59 ssh_host_rsa_key\n-rw-r--r--  1 admin administrators  569 Jun 29 19:59 ssh_host_rsa_key.pub\n-rw-r--r--  1 admin administrators  188 Jun 29 19:59 sshd_config\n-rw-r--r--  1 admin administrators   17 Jun 29 19:59 sshd_user_config\n<\/pre>\n\n\n\n<h2>Carefully assemble the mdRaid (Raid5 in my case)<\/h2>\n\n\n\n<p>A missing disk? We&#8217;ll look into that later. For the purpose of data extraction, 3 out of 4 is enough, if you are in a hurry.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[~] # mdadm --examine --scan\nARRAY \/dev\/md\/256  metadata=1.0 UUID=8063634e:7a5599c9:99b40cd2:24878311 name=256\nARRAY \/dev\/md\/322  metadata=1.0 UUID=520848dd:98eff90e:ed5a241f:3bbae5b7 name=322\nARRAY \/dev\/md\/9  metadata=1.0 UUID=35cf0ce4:294f39d0:e02ad1da:e53f776a name=9\nARRAY \/dev\/md\/256  metadata=1.0 UUID=d4ad498a:7da8fb33:6e9f5b0d:001b575b name=256\nARRAY \/dev\/md\/1  metadata=1.0 UUID=2a5370b7:b7218673:3c062ecc:4df3f825 name=1\nARRAY \/dev\/md\/13  metadata=1.0 UUID=76b64c56:edecd52e:9791d137:df3fe4ce name=13\nARRAY \/dev\/md\/322  metadata=1.0 UUID=966bbcc7:ff9e8288:8e982269:8bdffd1f name=322\n\n[~] # mdadm --examine --scan >> \/etc\/mdadm.conf \n\n[~] # mdadm --detail \/dev\/md1 \n\/dev\/md1:\n        Version : 1.0\n  Creation Time : Mon Sep  7 12:04:35 2020\n     Raid Level : raid5\n     Array Size : 11691190272 (11149.59 GiB 11971.78 GB)\n  Used Dev Size : 3897063424 (3716.53 GiB 3990.59 GB)\n   Raid Devices : 4\n  Total Devices : 3\n    Persistence : Superblock is persistent\n\n    Update Time : Wed Jun 29 16:59:31 2022\n          State : clean, degraded \n Active Devices : 3\nWorking Devices : 3\n Failed Devices : 0\n  Spare Devices : 0\n\n         Layout : left-symmetric\n     Chunk Size : 512K\n\n           Name : 1\n           UUID : 2a5370b7:b7218673:3c062ecc:4df3f825\n         Events : 57750\n\n    Number   Major   Minor   RaidDevice State\n       0       0        0        0      removed\n       1       8       19        1      active sync   \/dev\/sdb3\n       2       8       67        2      active sync   \/dev\/sde3\n       3       8       35        3      active sync   \/dev\/sdc3\n\n<\/pre>\n\n\n\n<p>Initialize LVM<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\n[~] # \/etc\/init.d\/init_lvm.sh help\nChanging old config name...\nmv: can't rename '\/etc\/config\/ssdcache.conf': No such file or directory\nmv: can't rename '\/etc\/config\/qlvm.conf': No such file or directory\nmv: can't rename '\/etc\/config\/qdrbd.conf': No such file or directory\nReinitialing...\nDetect disk(8, 80)...\nignore non-root enclosure disk(8, 80).\nDetect disk(8, 48)...\nignore non-root enclosure disk(8, 48).\nDetect disk(8, 16)...\nignore non-root enclosure disk(8, 16).\nDetect disk(8, 64)...\nignore non-root enclosure disk(8, 64).\nDetect disk(8, 32)...\nignore non-root enclosure disk(8, 32).\nDetect disk(8, 0)...\nignore non-root enclosure disk(8, 0).\ndev_count = 0\nDetect disk(8, 80)...\nignore non-root enclosure disk(8, 80).\nDetect disk(8, 48)...\nignore non-root enclosure disk(8, 48).\nDetect disk(8, 16)...\nignore non-root enclosure disk(8, 16).\nDetect disk(8, 64)...\nignore non-root enclosure disk(8, 64).\nDetect disk(8, 32)...\nignore non-root enclosure disk(8, 32).\nDetect disk(8, 0)...\nignore non-root enclosure disk(8, 0).\nsys_startup_p2:got called count = -1\nDone\n\n[~] # pvs\n  PV         VG   Fmt  Attr PSize  PFree\n  \/dev\/md1   vg1  lvm2 a--  10.89t    0 \n\n[~] # vgs\n  VG   #PV #LV #SN Attr   VSize  VFree\n  vg1    1  57   0 wz--n- 10.89t    0 \n\n[~] # lvs\n  LV        VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert\n  lv1       vg1  Vwi---t---   8.00t tp1                                                \n  lv1312    vg1  -wi-------   1.11g                                                    \n  lv2       vg1  Vwi---t---   2.00t tp1                                                \n  lv3       vg1  Vwi---t---   2.00t tp1                                                \n  lv4       vg1  Vwi---t---   1.07t tp1                                                \n  lv544     vg1  -wi------- 111.49g                                                    \n  snap10001 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10002 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10003 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10004 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10005 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10006 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10007 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10008 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10009 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10010 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10011 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10012 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10013 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10014 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10015 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10016 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10017 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10018 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10019 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10020 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10021 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10022 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10023 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10024 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10025 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10026 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10027 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10028 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10029 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10030 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10031 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10032 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10033 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10034 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10035 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10036 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10037 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10038 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10039 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10040 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10041 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10042 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10043 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10044 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10045 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10046 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10047 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10048 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10049 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  snap10050 vg1  Vwi---t---   8.00t tp1  lv1                                           \n  tp1       vg1  twi---t---  10.71t                                                    \n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Enabling SSH Since it is a real pain to work in an rdp, or a graphical console on 25&#215;80 characters, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/835"}],"collection":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/comments?post=835"}],"version-history":[{"count":4,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/835\/revisions"}],"predecessor-version":[{"id":841,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/posts\/835\/revisions\/841"}],"wp:attachment":[{"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/media?parent=835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/categories?post=835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spoton.cz\/index.php\/wp-json\/wp\/v2\/tags?post=835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}