안녕하세요. 이번에는 NFS / CIFS (Samba) 를 마운트 하는 방법을 알아보겠습니다.




1. 삼바 마운트 하기 (CIFS)


아래의 명령어로 마운트할 폴더를 mnt 아래에 하나 만들고 mount 명령어를 통해서 마운트를 진행합니다.


root@u5pvr-debian:~# mkdir /mnt/samba

root@u5pvr-debian:~# mount -t cifs -o username=djj9405,password=djj9405 //192.168.100.41/volume /mnt/samba

root@u5pvr-debian:~# cd /mnt/samba

root@u5pvr-debian:/mnt/samba# ls

1.mp4  Girls.Generation.Genie.4in1.200907.HDTV.x264.2160p.60fps.DTSES.6.1ch.mkv  htdocs  lost+found

root@u5pvr-debian:/mnt/samba#


mount -t cifs -o username=아이디,password=비번 //호스트이름 or 아이피/공유이름 /마운트위치


입니다.


참 쉽죠?



(사진이 넣을께 없어서 임시로 넣어둡니다. 게시글 옆에 사진 표시 없으면 조회수가 낮은 감이 있어서요 ㅎㅎ)




2. NFS 마운트 하기


(차후에 다른 해결방안이 적용되면 아래의 글은 무통보 수정이 됩니다.)


글을 시작하기 전에 먼저 말씀드립니다. NFS 커널 모듈이나 혹은 다른 문제가 있어서 statd 는 실행이 불가능한 상황입니다. 즉 NFS 서버는 구동이 어렵습니다.


그러나 클라이언트로의 활용은 잘 됩니다.


nfs-common 패키지를 설치합니다. 중간에 statd 가 실행되지 않았다고 에러가 뜹니다.


root@u5pvr-debian:~# apt-get install nfs-common

Reading package lists... Done

Building dependency tree

Reading state information... Done

Suggested packages:

  open-iscsi watchdog

The following NEW packages will be installed:

  nfs-common

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 0 B/189 kB of archives.

After this operation, 554 kB of additional disk space will be used.

Selecting previously unselected package nfs-common.

(Reading database ... 33729 files and directories currently installed.)

Preparing to unpack .../nfs-common_1%3a1.2.8-9_armhf.deb ...

Unpacking nfs-common (1:1.2.8-9) ...

Processing triggers for systemd (215-17+deb8u6) ...

Processing triggers for man-db (2.7.0.2-5) ...

Setting up nfs-common (1:1.2.8-9) ...


Creating config file /etc/idmapd.conf with new version

[FAIL] Starting NFS common utilities: statd failed!

invoke-rc.d: initscript nfs-common, action "start" failed.

dpkg: error processing package nfs-common (--configure):

 subprocess installed post-installation script returned error exit status 1

Processing triggers for systemd (215-17+deb8u6) ...

Errors were encountered while processing:

 nfs-common

E: Sub-process /usr/bin/dpkg returned an error code (1)

root@u5pvr-debian:~#


실제로는 위 에러가 발생해도 클라이언트로 사용하는데에는 문제가 없습니다만 한번 저렇게 에러가 걸려버리면 차후에 다른 패키지를 설치할 때에도 위 에러 메시지가 반복이 됩니다. 


그래서 해당 문제를 해결하기 위해서는 아래의 수정이 필요합니다.


root@u5pvr-debian:~# nano /etc/default/nfs-common


# If you do not set values for the NEED_ options, they will be attempted

# autodetected; this should be sufficient for most people. Valid alternatives

# for the NEED_ options are "yes" and "no".


# Do you want to start the statd daemon? It is not needed for NFSv4.

NEED_STATD=no        <-- NO로 입력합니다.


# Options for rpc.statd.

#   Should rpc.statd listen on a specific port? This is especially useful

#   when you have a port-based firewall. To use a fixed port, set this

#   this variable to a statd argument like: "--port 4000 --outgoing-port 4001".

#   For more information, see rpc.statd(8) or http://wiki.debian.org/SecuringNFS

STATDOPTS=


# Do you want to start the idmapd daemon? It is only needed for NFSv4.

NEED_IDMAPD=no        <-- NO 로 입력합니다.


# Do you want to start the gssd daemon? It is required for Kerberos mounts.

NEED_GSSD=


다시 nfs-common 패키지를 설치하는 명령어를 입력합니다.


root@u5pvr-debian:~# apt-get install nfs-common

Reading package lists... Done

Building dependency tree

Reading state information... Done

nfs-common is already the newest version.

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

1 not fully installed or removed.

After this operation, 0 B of additional disk space will be used.

Do you want to continue? [Y/n]

Setting up nfs-common (1:1.2.8-9) ...

[ ok ] Starting NFS common utilities:.

root@u5pvr-debian:~#


문제 에러 없이 설치가 되었습니다.


다음으로 nfs 공유를 마운트 해 보겠습니다.


root@u5pvr-debian:~# mkdir /mnt/nfs

root@u5pvr-debian:~# mount -t nfs -o nolock 192.168.100.30:/media/volume/tvheadend /mnt/nfs

root@u5pvr-debian:~# cd /mnt/nfs

root@u5pvr-debian:/mnt/nfs# ls

LIVE-4-U-SBS-MTV2016-11-21.ts                        ????????????-(874???)-CUBE-TV2017-02-27.ts

........................................................................................


마운트가 잘 됩니다. (실제로 lock 옵션을 사용하려면 statd 가 실행중이여야 되는데 아직 문제를 해결하지 못해서 nolock 옵션을 붙입니다.)


mount -t nfs -o nolock 아이피주소:/경로 /마운트위치



3. FTP 혹은 SAMBA 로 접근해보기


먼저 FTP 로 접근을 해 보겠습니다.




다음은 SAMBA 로 접근한 화면 입니다.





정상적으로 잘 됩니다.




4. 재부팅 시 자동마운트 하기


실제로 마운트 관리는 android 에서 관리하기 때문에 /etc/fstab 이 작동하지 않습니다.


따라서 rc.local 에 스크립트를 배치하는 것으로 해결을 봅니다.


root@u5pvr-debian:~# nano /etc/rc.local



# 아래의 내용을 추가합니다.

# cifs mount

mkdir /mnt/samba

mount -t cifs -o username=djj9405,password=djj9405 //192.168.100.41/volume /mnt/samba


# nfs mount

mkdir /mnt/nfs

mount -t nfs -o nolock 192.168.100.30:/media/volume/tvheadend /mnt/nfs


다만, 와이파이를 이용하시는 분들께서는 이 방법을 이용하실 때 주의하시길 바랍니다.


리눅스 부팅 과정 때, 와이파이가 붙어있지 않으면 연결 에러가 발생하기 때문입니다.


따라서 이 문제를 해결하기 위해서는 마운트 하기 전에 sleep 옵션을 주는 등의 방법이 있습니다.



유선으로 U5PVR 에 인터넷이 물려 있는 경우는 문제가 없습니다.


감사합니다.

http://cafe.naver.com/mk802/20660









+ Recent posts