Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

samba

sudo apt-get update
sudo apt-get -y install samba

Edit samba.conf with sudo nano /etc/samba/smb.conf and add the following lines to the bottom of the file:

[Files]
   comment = Share
   path = "/home/crostiniuser"
   writeable = yes
   guest ok = yes
   create mask = 0777
   directory mask = 0777
   force user = crostiniuser
   follow symlinks = yes
   wide links = yes
   acl allow execute always = True

Map the crostini user to your Windows user with:

echo "crostiniuser = windowsuser" | sudo tee /etc/samba/usermap.txt > /dev/null

Samba Password

Set a password for the Samba share with:

sudo smbpasswd -a crostiniuser

Finally, restart Samba to apply the new config with:

sudo systemctl restart smbd.service

UNC Access

Then, in your Windows VM, browse to \192.168.122.1\Files, enter your username and password, and you should now be able to access your home folder.

If you want to share a different folder instead, change the path = entry in samba.conf to point to the new directory. You can copy/paste that block to set up multiple shares as well.

Mount Share on NAS

sudo apt install cifs-utils nfs-common smbclient

Various Samba/Mount Tests

showmount -e 192.0.2.2
smbclient -L //192.0.2.2
mount -l

1. Make a Mount Point

mkdir -p /mnt/nas2-iso

2. Mount Remote to Mount Point

You can mount cifs, ntfs, vgat, nfs, etx3/ext4, iso9660 etc. Most often you will decide between nfs (linux to linux, and typically faster) or cifs ( linux + windows ).

sudo mount -t cifs //192.0.2.2/iso /mnt/nas2-iso -o rw,username=james,vers=2.0,uid=$(id -u james),gid=$(id -g james)
Password for james@//192.0.2.2/iso:

Need to know your UID?

id
uid=1000(james) gid=1000(james) groups=1000(james),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),100(users),101(netdev),113(wireshark),114(bluetooth),123(scanner),130(kaboxer),990(bumblebee)

3. Creds Files for cifs

sudo vim /etc/cifs-credentials
username=james
password=blehbleh
sudo chmod 600 /etc/cifs-credentials

4. Modify fstab for Boot Persistence

sudo vim /etc/fstab
//192.0.2.2/docs /mnt/nas2-docs cifs rw,vers=2.0,uid=1000,gid=1000,credentials=/etc/cifs-credentials,noauto,user 0 0
//192.0.2.2/games /mnt/nas2-games cifs rw,vers=2.0,uid=1000,gid=1000,credentials=/etc/cifs-credentials,noauto,user 0 0
//192.0.2.2/iso /mnt/nas2-iso cifs rw,vers=2.0,uid=1000,gid=1000,credentials=/etc/cifs-credentials,noauto,user 0 0

5. Reload Mount File

sudo mount -av
sudo systemctl daemon-reload

Sometimes manually accessing with //192.0.2.2/ is required to reset thunar

Manual Mounts, if needed

Remember, you need to mkdir -p the various /mnt/points first

sudo mount -t cifs //192.0.2.2/iso /mnt/nas2-iso -o rw,username=james,vers=2.0,uid=$(id -u james),gid=$(id -g james)
sudo mount -t cifs //192.0.2.2/docs /mnt/nas2-docs -o rw,username=james,vers=2.0,uid=$(id -u james),gid=$(id -g james)
sudo mount -t cifs //192.0.2.2/games /mnt/nas2-games -o rw,username=james,vers=2.0,uid=$(id -u james),gid=$(id -g james)