---
# System prepended metadata

title: Semba & mount disk

---

# Semba & mount disk

## Mount disk
**看看 /dev 下面所有的硬碟情況**
```
ls /dev/[sh]d*
```
**再用 fdisk 確認一下：**
```
fdisk -l /dev/sdb
```
**格式化（Format）硬碟**
```
mkfs -t ext4 /dev/sdb1
```
**掛載（mount）硬碟**
使用 UUID 來指定磁碟，硬碟的 UUID 就像是它的身分證字號，每一顆硬碟都可不同的 UUID，使用 blkid 這個指令，它可以列出所有磁碟的 UUID：
```
sudo blkid
```
/dev/sda1: UUID="4fae7331-9307-4a57-84e1-10fa0b244ca1″ TYPE="ext4″ 
/dev/sda5: UUID="a9cd23e1-f2f4-4f96-9795-9124f34c5e5b" TYPE="swap" 
/dev/sdb1: UUID="008df623-2979-492c-b030-41975805487b" TYPE="ext4″

所以現在就是依樣畫葫蘆，把新的硬碟資訊寫進 /etc/fstab 中，在 /etc/fstab 加入下面這行：
UUID=008df623-2979-492c-b030-41975805487b /data2          ext4    defaults 0       0
下次重開機時，系統就會把新的硬碟掛載至 /data2


## Semba
**安裝Samba**
```
sudo apt-get install samba
```
**修改config檔 /etc/samba/smb.conf**

```
[global]
workgroup = WORKGROUP
security = user

[homes]
comment = Home Directories 
browseable = yes 
read only = no 
create mask = 644 
directory mask = 644 
valid users = %S 
read only = no

[data]
   comment = Data Directories
   path = /raid/samba_shared
   browseable = yes
   writable = yes
   create mode = 0664
   directory mode = 0775
   write list = @docker
```
**重啟samba服務**
```
sudo /etc/init.d/smbd restart
```
**新增samba user**
```
sudo pdbedit -a -u user
```

