Cent OS Samba 설치 및 HDD Mount 하기
여기저기서 미친듯이 퍼왔습니다.
12.09.03
#yum -y erase samba «– 삼바 삭제,
이후 설치중
Another app is currently holding the lock; waiting for it to exit … 나오면
root 계정으로 들어간뒤
프로세스중에서 yum이 진행되는걸 확인하기 위해서
#ps -aef | grep yum 입력 실행되고 있는 프로세스 확인 후 날리기 위해서
#cd/var/run/ 이동 #rm yum.pid 입력 ? 나오면 y 입력 엔터 삭제됨.
이후 – 하니까 CentOS 날라감 ㄳ.. (하면 안됨 ^^;)
#yum install -y samba 입력.
-
samba 설치확인 > rpm -qa samba
-
yum 으로 samba 설치 > yum install -y samba
-
samba 설정 > vi /etc/samba/smb.conf 파일을 수정
캐릭터셋 설정
unix charset = utf-8 dos charset = utf-8 display charset = utf-8
워크그룹 설정
workgroup = WORKGROUP server string = Samba Server Version %v
접속 허용 IP 설정 (192.168.0.* 허용, 123.123.123.123 허용)
hosts allow = ...
예) hosts allow 123.123.123.
특정 유저 허용
security = user passdb backend = tdbsam
로그인한 유저 홈 디렉토리로 삼바 홈 디렉토리 설정
[homes] comment = Home Directories browseable = no writable = yes ; valid users = %S ; valid users = MYDOMAIN\%S
로그인한 사용자의 홈 디렉토리 이외의 디렉토리 공유
# 아래의 설정은 testuser1는 홈 디렉트로와 /data/share 디렉토리를 같이 공유 한다. [share] comment = share directories path = /data/share browseable = yes writeable = yes valid users = testuser1
아래는 내꺼
[file] comment = File Server path = /data/file browseable = yes valid users = administrator writable = yes public = yes create mask = 0777 directory mask = 0777
(참고) samba 에서 공유디렉토리를 지정할 때 사용하는 옵션 설명
- read only : 공유 디렉토리를 읽기만 가능하게 할 것인지를 결정
- writable, write ok : 공유 디렉토리를 쓰기 가능하게 할 것인지를 결정
- valid users : 공유 디렉토리에 로그인할 수 있는 사용자를 결정
- public, guest ok : 다른 사용자들이 이용하게 할 지를 결정
- browseable : 공유 디렉토리의 리스트를 보여줄 지를 결정
-
printable : 공유 디렉토리에 스풀 파일을 지정할 것인지를 결정
- path : 공유할 디렉토리의 절대경로를 지정
- comment : 간단한 설명을 적음
- create mask, create mode : 파일을 생성할 때의 모드를 umask 결정.
- write list : 쓰기가 가능한 특정 사용자를 지정
그러나, 부팅마다 자동으로 실행시키고 싶다면, 다음과 같이 하자.
# 현재 samba 설정 상태 조회 $ chkconfig –list smb smb 0:off 1:off 2:off 3:off 4:off 5:off 6:off
부팅시 자동 시작되게 바꾸기
$ chkconfig smb on $ chkconfig –list smb
smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off
runlevel 3, 5에서 시작되게 바꾸기
$ chkconfig –level 35 smb on $ chkconfig –list smb smb 0:off 1:off 2:off 3:on 4:off 5:on 6:off
– 네트웍 이름 바꾸기
coLinux의 리눅스에서 두 개의 파일을 수정합니다. 첫번째는 /etc/sysconfig/network입니다. ]# vi /etc/sysconfig/network
NETWORKING=yesHOSTNAME=localhost.localdomain
위의 내용을 아래와 같이 변경합니다.
NETWORKING=yes HOSTNAME=coLinux
GATEWAY=123.123.123.1
두번째는 /etc/hosts 입니다. ]# vi /etc/hosts
Do not remove the following line, or various programs
that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6
위의 내용을 아래와 같이 coLinux 이름을 추가합니다.
127.0.0.1 coLinux localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 ping으로 변경된 이름으로 에코가 돌아오면 정상적으로 처리된 것입니다. ]# service network restart –> 변경된 환경으로 네트워크 다시 시작 ]# ping coLinux PING coLinux (127.0.0.1) 56(84) bytes of data. 64 bytes from coLinux (127.0.0.1): icmp_seq=1 ttl=64 time=0.000 ms 64 bytes from coLinux (127.0.0.1): icmp_seq=2 ttl=64 time=0.000 ms 64 bytes from coLinux (127.0.0.1): icmp_seq=3 ttl=64 time=10.0 ms
— coLinux ping statistics — 3 packets transmitted, 3 received, 0% packet loss, time 2899ms rtt min/avg/max/mdev = 0.000/3.333/10.000/4.714 ms ]#
– 사용자 계정 추가
#vim /etc/samba/smbusers 에 들어간다. 아래 리스트는 보면 리눅스 계정 = 윈도우에서 접속할때 쓸 계정 이다. 추가시킬 administrator = administrator 로 추가시킨다
root = root nobody = guest pcguest smbguest administrator = administator <—
저장 하고 나온 뒤
vim /etc/samba/smb.conf 로 들어가서
————————— Filesystem Options —————————
#
The following options can be uncommented if the filesystem supports
Extended Attributes and they are enabled (usually by the mount option
user_xattr). Thess options will let the admin store the DOS attributes
in an EA and make samba not mess with the permission bits.
#
Note: these options can also be set just per share, setting them in global
makes them the default for all shares
; map archive = no ; map hidden = no ; map read only = no ; map system = no username map = /etc/samba/smbusers ; encrypt passwords = yes ; guest ok = no ; guest account = nobody ; store dos attributes = yes
처럼해서 users 경로를 추가시킨다.
사용자 계정 추가한다.
adduser administrator
삼바에도 계정 추가시킨다.
smbpasswd administrator 비밀번호 비밀번호 adduser… <— 완료 ㅋㅋ
// 12.09.27 /////////////////
계정 추가가 안될시에는
smbpasswd -a 계정 치면 된다.
////////////////////////////
이후 path로 설정된 폴더쪽에 권한을 부여시킨다.
chmod 777 /data/file «— 경로
이후
윈도우 시작 눌러서 \file 입력하면 끗. ㅋㅋ
======================= hdd 마운트
- fdisk 파티션을 잡는다 fdisk /dev/hdb(IDE 하드인 경우), fdisk /dev/sdb (SCSI 하드인 경우) p로 기존 파티션이 잡혀있는지 확인한다. d로 기존 파티션이 잡혀있으면 삭제후 p로 확인한다. n으로 파티션 추가 -> p(primary로) -> 1 -> 크기 지정 defualt 1 입력 (full로 잡을시, 디폴트가 Full) -> 엔터 w 로 쓴다.
***** fdisk 할때 중요한점.
fdisk -l 을하면 추가한 하드디스크 이름이 나타난다. 예) /dev/sdc 이런식
그럼 fdisk /dev/sdc 이렇게 처음에 치고 들어가면 된다.
이후 p를 눌럿을때 파티션이 나뉘어져있으면
d를 눌러서 파티션을 삭제한다 (파티션 갯수만큼 d눌러줘야될거다.)
이후 위에 방법대로 그대로 하면 됨.
============= 2016.03.11 추가 ==========================
ubuntu@dev-server:/$ sudo fdisk -l
WARNING: GPT (GUID Partition Table) detected on ‘/dev/sda’! The util fdisk doesn’t support GPT. Use GNU Parted.
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 234441647 117220823+ ee GPT
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
81 heads, 63 sectors/track, 382818 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x5534d1cf
Device Boot Start End Blocks Id System
/dev/sdb1 1953525167 1953525167 0+ 83 Linux
Partition 1 does not start on physical sector boundary.
ubuntu@dev-server:/$ sudo fdisk
Usage:
fdisk [options]
fdisk [options] -l
fdisk -s
Options:
-b
-c[=
-h print this help text
-u[=
-v print program version
-C
-H
-S
ubuntu@dev-server:/$ sudo fdisk /dev/sdb
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (1-4, default 2): 1
Partition 1 is already defined. Delete it before re-adding it.
Command (m for help): d
Selected partition 1
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1953525167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1953525167, default 1953525167):
Using default value 1953525167
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
ubuntu@dev-server:/$
ubuntu@dev-server:/$
ubuntu@dev-server:/$
ubuntu@dev-server:/$ sudo fdisk -l
WARNING: GPT (GUID Partition Table) detected on ‘/dev/sda’! The util fdisk doesn’t support GPT. Use GNU Parted.
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 234441647 117220823+ ee GPT
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
78 heads, 63 sectors/track, 397542 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x5534d1cf
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1953525167 976761560 83 Linux
ubuntu@dev-server:/$
ubuntu@dev-server:/$
ubuntu@dev-server:/$
ubuntu@dev-server:/$
ubuntu@dev-server:/$
ubuntu@dev-server:/$
ubuntu@dev-server:/$
ubuntu@dev-server:/$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
61054976 inodes, 244190390 blocks
12209519 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7453 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
ubuntu@dev-server:/$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Feb 12 16:40 0500-2B92 -> ../../sda1
lrwxrwxrwx 1 root root 10 Feb 12 16:40 19012ca3-255e-49c9-b694-9ac90645aa45 -> ../../sda3
lrwxrwxrwx 1 root root 10 Mar 11 15:56 b1dc7365-8494-4b4a-971e-446fb08ddb69 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Feb 12 16:40 f81b04cb-13ff-4c57-bb4a-44daa4d54ecf -> ../../sda2
ubuntu@dev-server:/$ sudo nano /etc/fstab
# 1TB disk mount
UUID=b1dc7365-8494-4b4a-971e-446fb08ddb69 /data ext4 errors=remount-ro 0 1
ubuntu@dev-server:/$ sudo mount -a
ubuntu@dev-server:/$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.8G 4.0K 7.8G 1% /dev
tmpfs 1.6G 1.2M 1.6G 1% /run
/dev/sda2 94G 8.6G 81G 10% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 7.8G 144K 7.8G 1% /run/shm
none 100M 40K 100M 1% /run/user
/dev/sda1 511M 3.4M 508M 1% /boot/efi
/dev/sdb1 917G 72M 871G 1% /data
ubuntu@dev-server:/$ sudo chown daihanAdmin:daihanAdmin /data
ubuntu@dev-server:/$ ll
drwxr-xr-x 3 daihanAdmin daihanAdmin 4096 Mar 11 15:56 data/
- 포멧부분
ext3 : mke2fs -j /dev/이름 ext2 : mkfs -t ext2 /dev/hdb
마운트할 디렉토리 생성
mkdir /경로/경로
- mount
ex3 : mount -t ext3 /dev/이름 /경로 ex2 : mount -t ext2 /dev/이름 /경로
- fstab 수정
vi /etc/fstab
LABEL =/home /home ext3/ default 1 2 (를 카피하여 페이스트 하여 아래와 같이 편집) -> /dev/hdb/home2 ext3 defaults 1 2
-
df -h 로 마운트 확인
-
재부팅후 이상없이 올라온후 마운트 되었는지 확인!!!
*마운트 해제시 sudo umount 해제할 경로
예)sudo umount /home/krr/jwc
끝!!!!