NAS Server Configuration

Kali just feels more comfortable to use—install it and it’s ready to go. Should’ve just stuck with Yuandao from the start p〒▽〒q

Steps

1. Install Kali

UEFI boot mode is recommended; otherwise there is a chance that after installation you end up stuck on a black screen with a _ blinking in the top-left corner when booting. That means the boot is broken, and the cause is unknown. Anyway, switch to UEFI boot in the BIOS and then install it again, and you will be able to enter the system.

2. Pre-process the Hard Drive

If you are using an old hard drive, consider deleting the partitions and then creating new partitions formatted as the ext4 file system as needed. If you run into problems with the steps below, try rebooting to refresh the file system.

  • View partitions

    1
    
    sudo fdisk -l
    

    Here, for example, sda, sdb represent whole hard drives, while sda1, sda2 are the different partitions on the drive sda.

  • Delete partitions (be careful with deletion operations)

    Be extremely careful. My hand slipped in the past two days, and I deleted the /etc on the server and the /dev on the NAS…

    Delete the specified partition:

    1
    
    sudo fdisk /dev/sdb # The hard drive whose partitions you want to delete.
    

    Then type m to view the help, d to delete; you will need to select the partition number. If you want to delete all the partitions of a whole hard drive, just delete them one by one with the defaults; you can also directly format the whole hard drive, see below for the steps. After deleting, remember to type w to save, otherwise the partitions will not be deleted.

  • Create new partitions

    The same partition operation commands:

    1
    
    sudo fdisk /dev/sdb
    

    Type n to create a new partition, type p to create a primary partition, enter the partition number, and the following steps determine the partition start position and partition size. If you have no special needs, just accept all defaults and make one partition over the whole hard drive.

    When done, remember to type w to save as well.

  • Format partitions (be careful with deletion operations)

    The command to format the specified partition is as follows:

    1
    
    sudo mkfs.ext4 /dev/sdb1
    

    The command to format the whole hard drive:

    1
    
    sudo mkfs.ext4 /dev/sdb
    

    It will ask for confirmation; don’t let your hand slip.

3. Mount the Hard Drive

  • Create a new mount point

    1
    
    mkdir -p /mnt/HDD_1
    
  • Temporary mount; canceled at shutdown

    1
    
    mount /dev/sdb1 /mnt/HDD_1
    
  • Unmount a partition

    1
    
    umount /dev/sdb1
    
  • Configure auto-mount at boot

    First view the UUID of the partition:

    1
    
    sudo blkid
    

    The output is as follows:

    1
    
    /dev/sdb1: UUID="11263962-9715-473f-9421-0b604e895aaa" TYPE="ext4"
    

    Configure auto-mount:

    1
    
    nano /etc/fstab
    

    Add a line:

    1
    
    UUID=11263962-9715-473f-9421-0b604e895aaa /mnt/HDD_1 ext4 defaults 0 0
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    <fs spec> <fs file> <fs vfstype> <fs mntops> <fs freq> <fs passno>
    
    Detailed explanation, using mounting /dev/sdb1 as an example:
    <fs spec>:   partition location; can be a UUID or LABEL, e.g. UUID=6E9ADAC29ADA85CD or LABEL=software
    <fs file>:   the specific mount point location, e.g. /mnt/HDD_1
    <fs vfstype>: mount filesystem type; Linux partitions are usually ext4, Windows partitions usually ntfs
    <fs mntops>: mount options; usually defaults
    <fs freq>:   disk check; default 0
    <fs passno>: disk check; default 0, no check needed
    

    Test the mount and see whether all the partitions have been successfully mounted.

    1
    
    sudo mount -a
    

    If there is a problem and you have rebooted, it may cause the system partition to fail to auto-mount and the system to fail to boot; the solution is to enter recovery mode and modify /etc/fstab.

4. Enable Samba

Before this, if you are not using the root user, other users will only have read-only permissions later, so depending on your needs, consider giving all users read, write and execute permissions:

1
sudo chmod 777 /mnt/HDD_1
  • Install Samba

    1
    
    sudo apt install samba
    
  • Configure Samba

    1
    
    nano /etc/samba/smb.conf
    

    If the default configuration is not needed, you can delete it all; configure it as follows:

    1
    2
    3
    4
    5
    
    [HDD_1]                 # Display name of the share
      path = /mnt/3TB_HDD_1 # Share path
      browseable = yes      # Allow browsing
      writeable = yes       # Allow writing
      read only = no        # Disable read-only
    
  • Add an SMB account

    1
    
    sudo smbpasswd -a <username> # Must be a username that exists on the system, e.g. the current username.
    
  • Start the smb service

    1
    2
    
    sudo systemctl restart smbd.service
    sudo systemctl restart nmbd.service
    
  • Enable auto-start at boot

    1
    2
    
    sudo systemctl enable smbd.service
    sudo systemctl enable nmbd.service
    

Done. Now you can connect to the NAS over SMB and enjoy life.