Armbian linux as nas

Step by step configuration linux as nas

🚀 Step-by-Step Guide for Setting Up Your Debian Server

1. Install sudo Command

  1. Switch to root user:
    su -
    
  2. Install sudo:
    apt-get install sudo
    
  3. Add user to sudo groups:
    usermod -aG sudo username
    
  4. Check user groups:
    id username
    
  5. Logout and login SSH again.

2. 🐋 Install Docker & Portainer 2.0 on Debian-Based Distros

  1. Install Docker:

    sudo apt install docker.io
    sudo systemctl start docker
    
  2. Download and run Portainer 2.0:

    sudo docker pull portainer/portainer-ce
    sudo docker run --restart=always --name=portainer -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce
    
  3. Access Portainer at http://[WORKSTATION_IP_ADDRESS]:9000 and create a username and password.

  4. Give user permission for Docker:

    sudo groupadd docker
    sudo usermod -aG docker $USER
    logout & login ssh
    

3. 📦 Install Docker Compose v2

  1. Create the directory for Docker CLI plugins:

    sudo mkdir -p /usr/local/lib/docker/cli-plugins
    
  2. Download Docker Compose v2:

    • For x86 device:
      sudo curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
      
    • For ARM device:
      sudo curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-aarch64 -o /usr/local/lib/docker/cli-plugins/docker-compose
      
  3. Make it executable:

    sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
    
  4. Verify installation:

    docker compose version
    

4. 👤 Add a New User and Assign to sudo and docker Groups

  1. Add a new user:

    sudo adduser new_username
    

    Follow the prompts to set the user’s password and other details.

  2. Add the user to the sudo group:

    sudo usermod -aG sudo new_username
    
  3. Add the user to the docker group:

    sudo usermod -aG docker new_username
    
  4. Check user groups to confirm:

    id new_username
    

5. 💾 Mount Hard Disk in Armbian

  1. Check hard disk:

    lsblk
    sudo blkid
    
  2. Mount hard disk:

    sudo mkdir /mnt/wd
    sudo chown -hR $(whoami):$(whoami) /mnt/wd
    
  3. Edit /etc/fstab to auto-mount on boot:

    sudo blkid
    sudo nano /etc/fstab
    

    Add:

    UUID="ID From blkid" /mnt/wd ext4 rw,user,auto 0 0
    
  4. Reboot:

    sudo reboot
    

6. 🗂️ Set up Samba Shares

  1. Install Samba:

    sudo apt-get install samba samba-common-bin
    
  2. Edit Samba configuration:

    sudo nano /etc/samba/smb.conf
    

    Add:

    [mynas]
    comment = Samba on My NAS
    path = /mnt/wd
    read only = no
    browsable = yes
    
  3. Create shared directory:

    sudo mkdir -p /mnt/wd
    sudo chown nobody:nogroup /mnt/wd
    sudo chmod 0775 /mnt/wd
    
  4. Add Samba user:

    sudo smbpasswd -a $(whoami)
    sudo smbpasswd -a anotheruser
    
  5. Restart Samba:

    sudo service smbd restart
    
  6. Connect to the share:

    • From Windows: \\IP address of NAS
    • From Linux: smb://IP address of NAS
  7. If you are unable to access from Windows, try rebooting your Windows machine and test again.

  8. Verify Samba status:

    sudo systemctl status smbd
    
  9. Troubleshooting:

    • Ensure firewall allows SMB traffic.
    • Verify SELinux or AppArmor settings.
    • Check user permissions and passwords.
    • Look at logs in /var/log/samba/.

7. 🌐 View Linux Machines from a Windows 10 Network

  1. Install WSD on Ubuntu:

    cd /tmp
    wget https://github.com/christgau/wsdd/archive/master.zip
    unzip master.zip
    sudo mv wsdd-master/src/wsdd.py wsdd-master/src/wsdd
    sudo cp wsdd-master/src/wsdd /usr/bin
    sudo cp wsdd-master/etc/systemd/wsdd.service /etc/systemd/system
    sudo nano /etc/systemd/system/wsdd.service
    

    Comment out:

    ; User=nobody
    ; Group=nobody
    
  2. Reload daemon and start WSDD:

    sudo systemctl daemon-reload
    sudo systemctl start wsdd
    sudo systemctl enable wsdd
    
  3. Check service status:

    sudo service wsdd status
    
  4. Reboot Windows and Ubuntu machines if necessary.

8. ❌ Disable ZRAM (Optional)

  1. Edit configuration:

    sudo vim /etc/default/armbian-zram-config
    

    Uncomment:

    SWAP=false
    
  2. Reboot:

    sudo reboot
    

Add New Raid to system Debian

  1. Install mdadm

    First, you’ll need to install the mdadm package if it’s not already installed.

    sudo apt update
    sudo apt install mdadm
    
  2. Identify the Disks

    Identify the disks you want to use for the RAID array. You can use lsblk or fdisk -l to list all available disks.

    lsblk

    Make a note of the device names (e.g., /dev/sdb, /dev/sdc, etc.).

  3. Create the RAID Array

    Use mdadm to create the RAID array. The following example creates a RAID 1 array (mirroring) with two disks:

    sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
    
    • /dev/md0 is the RAID device name.
    • –level=1 specifies the RAID level (RAID 1 in this case).
    • –raid-devices=2 specifies the number of devices in the array.
    • /dev/sdb and /dev/sdc are the disks to be used in the RAID array.
  4. Create a Filesystem

    Once the RAID array is created, you need to create a filesystem on it. For example, to create an ext4 filesystem:

    sudo mkfs.ext4 /dev/md0

  5. Mount the RAID Array

    Create a mount point and mount the RAID array:

    sudo mkdir -p /mnt/raid sudo mount /dev/md0 /mnt/raid

  6. Update /etc/fstab

    To ensure the RAID array is mounted automatically at boot, add an entry to /etc/fstab. First, get the UUID of the RAID array:

    sudo blkid /dev/md0

    Add the following line to /etc/fstab, replacing UUID= with the actual UUID:

    UUID=<your-uuid> /mnt/raid ext4 defaults 0 0

  7. Verify the RAID Array

    You can check the status of the RAID array using:

    sudo mdadm --detail /dev/md0
    

10. ⚙️ Mount RAID 0 on Debian

  1. Install mdadm:

    sudo apt-get update
    sudo apt-get install mdadm
    
  2. Assemble RAID array:

    sudo mdadm --assemble --scan
    
  3. Verify RAID array:

    cat /proc/mdstat
    
  4. Mount RAID array:

    sudo mkdir -p /mnt/raid0
    sudo mount /dev/md0 /mnt/raid0
    
  5. Verify mount:

    df -h
    lsblk
    
  6. Auto-mount on boot:

    sudo blkid /dev/md0
    sudo nano /etc/fstab
    

    Add:

    UUID=your-raid-uuid /mnt/raid0 ext4 defaults 0 0
    

    Replace your-raid-uuid with UUID from blkid command.

🎉 Your server is now set up and ready to use! Enjoy!