{"id":2489,"date":"2015-03-06T08:15:16","date_gmt":"2015-03-05T22:15:16","guid":{"rendered":"https:\/\/www.penguinpunk.net\/blog\/?p=2489"},"modified":"2015-06-01T14:54:47","modified_gmt":"2015-06-01T04:54:47","slug":"qnap-add-swap-to-your-nas-for-large-volume-fsck-activities","status":"publish","type":"post","link":"https:\/\/www.penguinpunk.net\/blog\/qnap-add-swap-to-your-nas-for-large-volume-fsck-activities\/","title":{"rendered":"QNAP &#8211; Add swap to your NAS for large volume fsck activities"},"content":{"rendered":"<p>That&#8217;s right, another heading from the Department of not terribly\u00a0catchy blog article titles. I&#8217;ve been having a mighty terrible time with one of my QNAP arrays lately. After updating to 4.1.2, I&#8217;ve been getting some weird symptoms. For example, every time the NAS reboots, the filesystem is marked as unclean. Worse, it mounts as read-only from time to time. And it seems generally flaky. So I&#8217;ve spent the last week trying to evacuate the data with the thought that maybe I can re-initialize it and clear out some of the nasty stuff that&#8217;s built up over the last 5 years. Incidentally, while we all like to moan about how slow SATA disks are, try moving a few TB via a USB2 interface. The eSATA seems positively snappy after that.<\/p>\n<p>Of course, QNAP released <a title=\"Release Notes for QTS\" href=\"https:\/\/www.qnap.com\/i\/en\/releasenotes\/\" target=\"_blank\">version 4.1.3<\/a> of their platform recently, and a lot of the symptoms I&#8217;ve been experiencing have stopped occurring. I&#8217;m going to continue down this path though, as I hadn&#8217;t experienced these problems on my other QNAP, and just don&#8217;t have a good feeling about the state of the filesystem. And you thought that I would be all analytical about it, didn&#8217;t you?<\/p>\n<p>In any case, I&#8217;ve been running e2fsck on the filesytem fairly frequently, particularly when it goes read-only and I have to stop the services, unmount and remount the volume.<\/p>\n<pre><strong>[\/] # cd \/share\/MD0_DATA\/\r\n<\/strong><strong>[\/share\/MD0_DATA] # cd Qmultimedia\/ \u00a0 \u00a0\r\n<\/strong><strong>[\/share\/MD0_DATA\/Qmultimedia] # mkdir temp\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\r\n<\/strong><strong>mkdir: Cannot create directory `temp': Read-only file system\r\n<\/strong><strong>[\/share\/MD0_DATA\/Qmultimedia] # cd \/\r\n<\/strong><strong>[\/] # \/etc\/init.d\/services.sh stop\r\n<\/strong><strong>Stop qpkg service: chmod: \/share\/MD0_DATA\/.qpkg: Read-only file system\r\n<\/strong><strong>Shutting down Download Station: OK\r\n<\/strong><strong>Disable QUSBCam ...\u00a0\r\n<\/strong><strong>Shutting down SlimServer...\u00a0\r\n<\/strong><strong>Error: Cannot stop, SqueezeboxServer is not running.\r\n<\/strong><strong>WARNING: rc.ssods ERROR: script \/opt\/ssods4\/etc\/init.d\/K20slimserver failed.\r\n<\/strong><strong>Stopping thttpd-ssods .. OK.\r\n<\/strong><strong>rm: cannot remove `\/opt\/ssods4\/var\/run\/thttpd-ssods.pid': Read-only file system\r\n<\/strong><strong>WARNING: rc.ssods ERROR: script \/opt\/ssods4\/etc\/init.d\/K21thttpd-ssods failed.\r\n<\/strong><strong>Shutting down QiTunesAir services: Done\r\n<\/strong><strong>Disable Optware\/ipkg\r\n<\/strong><strong>.\r\n<\/strong><strong>Stop service: cloud3p.sh vpn_openvpn.sh vpn_pptp.sh ldap_server.sh antivirus.sh iso_mount.sh qbox.sh qsyncman.sh rsyslog.sh snmp lunportman.sh iscsitrgt.sh twonkymedia.sh init_iTune.sh ImRd.sh crond.sh nvrd.sh StartMediaService.sh bt_scheduler.sh btd.sh mysqld.sh recycled.sh Qthttpd.sh atalk.sh nfs ftp.sh smb.sh versiond.sh .\r\n<\/strong><strong>[\/] # umount \/dev\/md0<\/strong><\/pre>\n<p>&nbsp;<\/p>\n<p>So then I run e2fsck to check the filesystem. But on a large volume (in this case 8 and a bit TB), it uses a lot of RAM. And invariably runs out of swap space.<\/p>\n<pre><strong>[\/] # e2fsck \/dev\/md0\r\n<\/strong><strong>e2fsck 1.41.4 (27-Jan-2009)\r\n<\/strong><strong>\/dev\/md0: recovering journal\r\n<\/strong><strong>\/dev\/md0 contains a file system with errors, check forced.\r\n<\/strong><strong>Pass 1: Checking inodes, blocks, and sizes\r\n<\/strong><strong>Error allocating block bitmap (4): Memory allocation failed\r\n<\/strong><strong>e2fsck: aborted<\/strong><\/pre>\n<p>&nbsp;<\/p>\n<p>So here&#8217;s what I did to enable some additional swap on a USB stick (courtesy of a\u00a0<a title=\"TS-859 Pro+ crashing e2fsck_64\" href=\"http:\/\/forum.qnap.com\/viewtopic.php?p=216117\" target=\"_blank\">QNAP forum post<\/a> from <a title=\"RottUlf\" href=\"http:\/\/forum.qnap.com\/memberlist.php?mode=viewprofile&amp;u=103916&amp;sid=f8eb886ace98fa705289e0d65e2b2ce4\" target=\"_blank\">RottUlf<\/a>).<\/p>\n<p>Insert a USB stick with more than 3GB of space. Create a swap file on it.<\/p>\n<pre><strong>[\/] # <\/strong><strong>dd if=\/dev\/zero of=\/share\/external\/sdi1\/myswapfile bs=1M count=3072<\/strong><\/pre>\n<p>Set it as a swap file.<\/p>\n<pre><strong>[\/] # <\/strong><strong>mkswap \/share\/external\/sdi1\/myswapfile<\/strong><\/pre>\n<p>Enable it as swap for the system.<\/p>\n<pre><strong>[\/] # <\/strong><strong>swapon \/share\/external\/sdi1\/myswapfile<\/strong><\/pre>\n<p>Check it.<\/p>\n<pre><strong>[\/] # cat \/proc\/swaps\r\n<\/strong><strong>Filename Type Size Used Priority\r\n<\/strong><strong>\/dev\/md8 partition 530040 8216 -1\r\n<\/strong><strong>\/share\/external\/sdi1\/myswapfile file 3145720 12560 -2<\/strong><\/pre>\n<p>You should then be able to run e2fsck. Note that the example I linked to used e2fsck_64, but this isn&#8217;t available on the TS639 Pro II. Once you&#8217;ve fixed your filesystem issues, you&#8217;ll want to disable the swap file on the stick, remount the volume and restart your services.<\/p>\n<pre><strong>[\/] # swapoff \/share\/external\/sdi1\/myswapfile\r\n<\/strong><strong>[\/] # mount \/dev\/md0\r\n<\/strong><strong>mount: can't find \/dev\/md0 in \/etc\/fstab or \/etc\/mtab<\/strong><\/pre>\n<p>Oh no &#8230;<\/p>\n<pre><strong>[\/] # mount \/dev\/md0 \/share\/MD0_DATA\/<\/strong><\/pre>\n<p>Yeah, I don&#8217;t know what&#8217;s going on there either. I&#8217;ll report back in a while when I&#8217;ve wiped it and started again.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>That&#8217;s right, another heading from the Department of not terribly\u00a0catchy blog article titles. I&#8217;ve been having a mighty terrible time with one of my QNAP arrays lately. After updating to 4.1.2, I&#8217;ve been getting some weird symptoms. For example, every time the NAS reboots, the filesystem is marked as unclean. Worse, it mounts as read-only [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[142,5],"tags":[96,800,390,306,787,721],"class_list":["post-2489","post","type-post","status-publish","format-standard","hentry","category-qnap","category-storage","tag-memory","tag-qnap","tag-raid","tag-rebuild","tag-storage","tag-swapon"],"_links":{"self":[{"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/posts\/2489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/comments?post=2489"}],"version-history":[{"count":7,"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/posts\/2489\/revisions"}],"predecessor-version":[{"id":2914,"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/posts\/2489\/revisions\/2914"}],"wp:attachment":[{"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/media?parent=2489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/categories?post=2489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.penguinpunk.net\/blog\/wp-json\/wp\/v2\/tags?post=2489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}