Snott

Category: Linux

Linux Related stuff, system administration, installation tutorials and more

  • Automating Sia for hosting

    Automating Sia for hosting

    Sia is an Open Source Decentralized storage platform, which splits apart, encrypts, and distributes your files across a decentralized network. Since you hold the keys, you own your data. No outside company can access or control your files, unlike traditional cloud storage providers.

    Below is a quick and simple way to integrate siad (the process sia runs) with systemctl, so that you can control it from within systemd the normal way you control the rest of your processes on a Linux System.

    Systemd unit file (put this in /usr/lib/systemd/system/sia.service):

    [Unit]
    Description=Sia daemon
    After=network.target
    
    [Service]
    Type=simple
    User=sia
    Nice=5
    # WorkingDirectory may not be required but to be sure.
    WorkingDirectory=/sia
    # This could be more dynamic, but if we don't limit this, we will get swap problems.
    # Legacy setting for use with cgroups v1.
    MemoryLimit=3.5G
    # Unified hierarchy, supported starting with systemd 231 and later, while CentOS 7 uses 219.
    #MemoryHigh=3G
    #MemoryMax=3.5G
    # Introduced with systemd 232 while CentOS 7 uses 219.
    #MemorySwapMax=0
    ExecStart=/sia/siad --sia-directory /sia
    Restart=on-failure
    RestartSec=30
    
    [Install]
    WantedBy=multi-user.target
    ---
    
    Do systemctl edit sia, an editor will open, add the following:
    [Service]
    Environment="SIA_WALLET_PASSWORD=word1 word2 whatever etc omg lol rofl lmao"
    
    That will make the environment variable accessible from the service so that the wallet is auto-unlocked every time the service starts
    Now you can do "systemctl status|start|stop|restart sia" and if the process fails it will restart by itself within 30 secs.
  • How to move a system folder into a newly created LVM?

    How to move a system folder into a newly created LVM?

    Let’s say you need to mount /var into a different LVM, how do you do that on a running system?

    Change to root

    $ su

    # telinit 1

    telinit may be used to change the SysV system runlevel. Since the concept of SysV runlevels is obsolete the runlevel requests will be transparently translated into
    systemd unit activation requests (if you are using systemd of course!).

    # lvcreate -L 2G -n suse_var /dev/vg_Dell01

    create 2GB logical volume

    # mkfs -t reiserfs /dev/vg_Dell01/suse_var

    Format using Reiserfs (or whatever filesystem you need

    # mkdir /mnt/tmp
    # mount -t resierfs /dev/vg_Dell01/suse_var /mnt/tmp

    create a folder, and mount your new LVM there

    # cp -R /var /mnt/tmp
    # mv /var /var.old

    Copy everything over, rename the old var folder just in case something goes wrong

    # umount /mnt/tmp
    # rmdir /mnt/tmp

    Unmount LVM and remove mount point directory

    # mount -t resierfs /dev/vg_Dell01/suse_var /var

    Mount our new LVM, now this has all of our /var contents

    # vi /etc/fstab …..

    Edit /var mountpoint to point to your new LVM
    # mount -a

    EXTREMELY IMPORTANT, make sure you get no errors when running this, if you do, fix those errors before rebooting or the system won’t boot.

    # telinit 2

    You are done!