LINUX - BTRFS and shared with SAMBA

MAKING BTRFS SHARE ON DEBIAN BOX WITH USER PERMISSIONS

NOTE THE WINDOWS BOX IS JOINED TO THE DOMAIN BUT NOT THE LINUX BOX, THIS MAKES NO DIFFERENCE BESIDES THAT I CANT LOG IN WITH GUEST CREDENTIALS (no user no password) SINCE DOMAINS DONT HAVE GUEST USERS (BY DEFAULT) SO I HAD TO MAKE A SAMBA USER

BONUS TOPICS COVERED HERE:
* MAKING A SWAP PARTITION ON THE NEW DISK IM ADDING, IM GOING TO MAKE IT SO ITS PERSISTENT AS WELL - MEANING IT WILL BE ON WHEN THE SYSTEM REBOOTS
* SCANNING FOR NEWLY ADDED SATA DISKS WHILE THE SYSTEM IS ON

(step1)
Add the SATA disk to your system ( I added an 8 gb disk, because Im using a VM, but thats just extra unimportant information)

(step2)
reboot or scan for disks so the system will recognize your new SATA disk

To reboot:
"reboot -f" but make sure all your work is saved and your save to force a reboot with your linux system

To scan for disk: (THIS METHOD IS GOOD IF YOU DONT HAVE udev AND mdev -s SETUP TO DETECT hot plug EVENTS)
What to do?
First you need to find out how many host folders you have with the command: "ls /sys/class/scsi_host/" and it will show you all the scsi hosts. For me It shows "host0" and "host1" so that means I need to run the following command for each host.
So I will run the following command, this is the general form - where you see # is the host number:
# echo "- - -" > /sys/class/scsi_host/host#/scan

What I Did?
So since 

# ls /sys/class/scsi_host

returns

host0 and host1

So to scan for disks
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan

Why scan or reboot?

When you add a new disk to a system, the system will not awknoledge it till you reboot or scan the scsi hosts. After rebooting and or scanning the scsi hosts:

cat /proc/partitions will now show you the new added disk most likely as sdb (if you only had one disk before.)

(step3)
see the name of the new disk
# cat /proc/partitions

(step4)
partition the disk that you see is new in my case I saw i had a new /dev/sdb
# apt-get install cfdisk
# cfdisk /dev/sdb
I partitioned 2 partitions 1gb and 7gb. Both just as primary partitions, but not as bootable partitions since im not going be booting from them. 
The first partition I made of the type "linux swap", the second partition I left as default "linux". 1 gb for swap and 7 gb for btrfs (sidenote "mkswap /dev/sdb1" and then "swapon /dev/sdb1" to make swap work)

(step 5)
To confirm you have 2 partitions, you should now see /dev/sdb and /dev/sdb1 and /dev/sdb2
# cat /proc/partitions

(step 6)
Get btrfs installed and set it up with default options on the big partition
# apt-get install btrfs-tools
# mkfs.btrfs /dev/sdb2

(step 7)
mount the new partition
# mkdir /vol
# mount /dev/sdb2 /vol

(step 8)
To make it persistently mountable even when you reboot edit fstab file and add the entries below
# vim /etc/fstab
add the entry to the bottom:
/dev/sdb2       /vol    btrfs   defaults 0       0

Also add this entry below to make the swap work:
/dev/sdb1       swap    swap    defaults 0       0

(step 9)
To get file sharing need to install samba
# apt-get install samba

(step 10)
Edit the samba config file
# vim /etc/samba/smb.conf
In [global] section unhash "# security = user" so it doesnt have # in front of it and simply reads:
security = user

Make a new section called [vol] thats the name of the share
[vol]
    comment = btrfs
    path = /vol/
    writable = yes
    guest ok = yes
    browsable = yes

(step 11)
Reload your new settings
# /etc/init.d/samba reload

(step 12)
Make user that can use the samba system
# adduser samba1
I gave it the password 12345678

(step 13)
Add user to samba user list
# smbpasswd -a samba1

(step 14)
If you want to be able to write - either way make sure the UNIX/POSIX permissions are all access
# chmod 777 -R /vol

(step 15)
On windows open cmd and type
net use Q: \\172.20.18.201\vol
feed the username: samba1 and password: 12345678

HOW MY SMB.CONF LOOKS LIKE
usually I would  "grep ^[^#] smb.conf" but they also have ; for comments need to add "\;" into the "[]" class section of the regular expression
This next command removes blank lines, comments that start with # and comments that start with ;
# grep ^[^#\;] smb.conf

[global]
   workgroup = WORKGROUP
   server string = %h server
   dns proxy = no
   log file = /var/log/samba/log.%m
   max log size = 1000
   syslog = 0
   panic action = /usr/share/samba/panic-action %d
   security = user
   encrypt passwords = true
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
[vol]
    comment = btrfs
    path = /vol/
    writable = yes
    guest ok = yes
    browsable = yes
Comments