Archlinux SAMBA Fileserver Btrfs Qnap TS-459 PRO II

I’ve got an used half dead Qnap TS-459 PRO II in hands. The original Qnap OS won’t detect the installed disks not quite stable, due to a faulty Marvell SATA-Controller Chip.
The other Marvell SATA-Controller works fine. So only 2 of 4 disks are working.

Archlinux has very good btrfs support due to the fresh packages. Otherwise I would have used debian or ubuntu.

Problems with this special type of hardware:
*) Bios does not detect the connected disks on this devices, thus you only can boot from the internal USB device

You have to set /boot to the internal USB-Device

I’ve changed the /boot/grub/grub.cfg at the first line

set root=’mduuid/daa55d04:df1b4f59:52419904:51489ef3′

set root=’hd0,msdos1′

Now grub is reading it’s config files from that USB-Device.

WARNING! If you recreate your grub.conf with gurb-mkconfig -o /boot/grub/grub.cfg this change will be overwritten. I was to lazy to fix that πŸ™‚

Archlinux booting from Software-RAID you have to:

mdadm –detail –scan >> /etc/mdadm.conf

vim /etc/mkinitcpio.conf

HOOKS=(base udev autodetect modconf block filesystems keyboard fsck mdadm btrfs)

mkinitcpio -p linux

mdadm will include the /etc/mdadm.conf in initramfs. I’m using btrfs for root and data partitions. Therefore I’ve added btrfs just in case :-). Normally it will be automatically included.

You also want some periodic check of your RAID consistency. This device has really old used disks built in. So I’ve “stolen” the checkarray script from an ubuntu installation and created a systemd timer

/etc/systemd/system/checkarray.timer

[Unit]
Description=Software RAID checkarray timer
[Timer]
OnCalendar=monthly
AccuracySec=1h
[Install]
WantedBy=timers.target

[Unit]
Description=Software RAID checkarray service
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/checkarray –all –idle –quiet

Might you want to have lm_sensors support.
*) vim /etc/modules-load.d/sensors.conf
it87
*) Install lm_sensors and run pwmconfig.

Fancontrol runs really nice on this board!

Here my samba config file if you need it. I’ve enabled samba audit for the “daten” share. Very handy to handle Crypto-Trojans faster and easier.

[global]
workgroup = nas01.local
server string = nas01
domain logons = No
domain master = No
printing = bsd
security = user
hosts allow = 127.0.0.1 192.168.0.0/16
printcap name = /dev/null
#Windows XP fix
lanman auth = yes
ntlm auth = yes
full_audit:failure = none
full_audit:success = mkdir rename unlink rmdir pwrite write
full_audit:prefix = IP=%I|USER=%u|MACHINE=%m|VOLUME=%S
full_audit:facility = local7
full_audit:priority = NOTICE

[daten]
comment = daten
hosts allow = 192.168.0.0/16
path = /daten/samba/daten
read only = No
valid users = daten
available = yes
create mode = 0644
directory mode = 0755
vfs objects = full_audit

[backup]
comment = daten
hosts allow = 192.168.0.0/16
path = /daten/samba/backup
read only = No
valid users = backup
available = yes
create mode = 0644
directory mode = 0755

[snapshots]
comment = daten
hosts allow = 192.168.0.0/16
path = /daten/.snapshots
force user = root
valid users = daten
read only = yes
available = yes

I’ve enabled btrfs snapshots with snapper and the corresponding systemd-timers of the Archlinux package. Useful if you want to recover accidentally deleted or overwritten files

WARNING! Snapshots do not replace a real Backup!

This device has also an LCD Display. Someone has written a very good ksh script dealing with it.
https://github.com/jdupl/QnapFreeLCD

I don’t need all of this goodness. So I wrote my on crappy script to display only the Information I need πŸ™‚ It does what it should do πŸ™‚

https://www.paranoids.at/downloads/lcdMonitor.php.txt

Have fun!

Archlinuxarm Raspberry Pi3 B+ btrfs root subvolume

Hi,

Archlinuxarm ARMv8 (AArch64) uses uboot to boot the system
You have to modify /boot/boot.txt with your rootflags
mine look like this:

setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=${uuid} rootflags=subvol=root,compress rw rootwait smsc95xx.macaddr=”${usbethaddr}”

So you have to insert “rootflags=subvol=root,compress” to boot from your btrfs subvolume!
After editing the text file you have to run

cd /boot/

./mkscr

This will recreate your boot.scr

Have fun!

mssql database transaction log blown

hi there

sometimes you have to fix an mssql server where transaction log is full. due to that the database is more or less unusable

*) check for big tables

SELECT sys.objects.name, SUM(reserved_page_count) * 8.0 / 1024 as Size
FROM sys.dm_db_partition_stats, sys.objects 
WHERE sys.dm_db_partition_stats.object_id = sys.objects.object_id 
GROUP BY sys.objects.name
ORDER BY Size DESC;
GO

*) create backup of mssql db

BACKUP DATABASE yourdbname
TO DISK = 'e:\backup\db-bkup.sql'
GO

*) backup transaction log of mssql

BACKUP LOG yourdbname TO DISK = 'e:\backup\yourdb_log.trn' WITH INIT;

*) shrink transaction log

USE yourdbname;
GO
DBCC SHRINKFILE(yourdbname_log, 200);
GO
USE [master];
GO
ALTER DATABASE yourdbname 
  MODIFY FILE
  (NAME = yourdbname_log, SIZE = 200MB, FILEGROWTH = 10MB);
GO

*) disable/reduce transaction log (if you don’t need it)

ALTER DATABASE yourdbname SET RECOVERY SIMPLE;
USE yourdbname;
GO
CHECKPOINT;
GO
CHECKPOINT; -- run twice to ensure file wrap-around
GO
DBCC SHRINKFILE(yourdbname_log, 200); -- unit is set in MBs
GO

*) select data from table

SELECT [a]
      ,[b]
      ,[c]
      ,[d]
      ,[e]
      ,[f]
 FROM [yourdbname].[dbo].[yourtablename] WHERE timestamp < DATEADD(MONTH, -36, GETDATE()) ORDER BY timestamp ASC

*) delete data from table older than 3 years

DELETE FROM [yourdbname].[dbo].[yourtablename] WHERE timestamp < DATEADD(MONTH, -36, GETDATE())

*) shrink databasefile (.mdf) to small size

ALTER DATABASE yourdbname SET RECOVERY SIMPLE;

mssql will produce immense IO and transaction logfile size

USE [yourdbname];
DBCC SHRINKFILE(yourdbname_dat, TargetSize);

*) limit ram usage of mssql server

properties of database-server -> memory -> maximum server memory

have fun

Ubuntu 18.04 Network Configuration ipv4 ipv6 Dual Stack

Hi

no /etc/network/interfaces ?

Let’s go for it πŸ™‚

vim /etc/netplan/01-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.1.2/24, "XXXX:XXXX:XXXX:XXXX::2/64"]
      gateway4: 192.168.1.1
      gateway6: XXXX:XXXX:XXXX:XXXX::1
      nameservers:
        addresses: [1.1.1.1, 1.0.0.1]

here a bridged example

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      interfaces: [eno1]
      dhcp4: no
      dhcp6: no
      addresses: [192.168.1.2/24, "XXXX:XXXX:XXXX:XXXX::2/64"]
      gateway4: 192.168.1.1
      gateway6: XXXX:XXXX:XXXX:XXXX::1
      nameservers:
        addresses: [1.1.1.1, 1.0.0.1]

here a bridged example with vlans

network:
  version: 2
  renderer: networkd
  ethernets:
    enp5s0f0:
      dhcp4: no
      dhcp6: no
  vlans:
    vlan302:
      id: 302
      link: enp5s0f0
      dhcp4: no
      dhcp6: no
    vlan412:
      id: 412
      link: enp5s0f0
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      interfaces: [vlan302]
      dhcp4: no
      dhcp6: no
      addresses: [1.1.1.2/24]
      gateway4: 1.1.1.1
      nameservers:
        addresses: [1.1.1.1, 1.0.0.1]
    br1:
      interfaces: [vlan412]
      dhcp4: no
      dhcp6: no

the spaces are mandatory!

Have fun