ほとまるブログ

おっぱいアニメ愛好家のブログ (゚∀゚)o彡゜おっぱい!おっぱい!

BeagleBoardをDLNAサーバーにする

現状、BeagleBoardにはDebianがインストールされているので、
普通にMediaTombを入れればDLNAサーバーになるはず

環境

Host PC
IP_ADDR: 192.168.123.64
Kernel: Linux debian64 2.6.32-5-amd64 x86_64
BeagleBoard-xM
IP_ADDR: 192.168.123.31
Kernel: Linux debian 2.6.38.2-x1 armv71

インストール

HostからSSHBeagleBoardに接続する

$ ssh 192.168.123.31
The authenticity of host '192.168.123.31 (192.168.123.31)' can't be established.
RSA key fingerprint is 2d:54:48:72:34:c4:4e:f5:7d:d1:87:a3:ee:4f:59:eb.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.123.31' (RSA) to the list of known hosts.
kuma@192.168.123.31's password: 
Linux debian 2.6.38.2-x1 #1 SMP Sat Apr 2 00:32:56 UTC 2011 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

apt-getで普通にインストールする

$ sudo apt-get update
$ sudo apt-get install mediatomb
$ vi /etc/mediatomb/config.xml

変更箇所
・ブラウザで設定できるようにする
PS3サポートを設定する

-   <ui enabled="no" show-tooltips="yes">
+    <ui enabled="yes" show-tooltips="yes">
-    <protocolInfo extend="no"/><!-- For PS3 support change to "yes" -->
+    <protocolInfo extend="yes"/><!-- For PS3 support change to "yes" -->

MediaTombを起動する

$ sudo /etc/init.d/mediatomb start
Starting upnp media server: mediatomb.

MediaTombを自動起動させる

$ sudo update-rc.d mediatomb defaults 
update-rc.d: using dependency based boot sequencing

ストレージ用にSDカード追加

DLNAサーバーだったらそれなりに容量がないとね
とりあえず余ってた4GBのMicroSDをUSBコネクタに挿す

$ dmesg |tail 
[ 2650.052917] sd 0:0:0:0: [sda] Write Protect is off
[ 2650.061340] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[ 2650.072387] sd 0:0:0:0: [sda] No Caching mode page present
[ 2650.081542] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 2650.098205] sd 0:0:0:0: [sda] No Caching mode page present
[ 2650.107238] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 2650.119018]  sda: sda1
[ 2650.132537] sd 0:0:0:0: [sda] No Caching mode page present
[ 2650.141510] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 2650.150939] sd 0:0:0:0: [sda] Attached SCSI removable disk

sda1みたい

$ /sbin/fdisk -l /dev/sda

Disk /dev/sda: 4010 MB, 4010803200 bytes
55 heads, 54 sectors/track, 2637 cylinders
Units = cylinders of 2970 * 512 = 1520640 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               3        2638     3912704    b  W95 FAT32

FAT32でした
ext3でフォーマットしましょうw
パーティションの設定

$ /sbin/fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 4010 MB, 4010803200 bytes
55 heads, 54 sectors/track, 2637 cylinders
Units = cylinders of 2970 * 512 = 1520640 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               3        2638     3912704    b  W95 FAT32

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/sda: 4010 MB, 4010803200 bytes
55 heads, 54 sectors/track, 2637 cylinders
Units = cylinders of 2970 * 512 = 1520640 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

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2637, default 1): [Enter]
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2637, default 2637): [Enter]
Using default value 2637

Command (m for help): p

Disk /dev/sda: 4010 MB, 4010803200 bytes
55 heads, 54 sectors/track, 2637 cylinders
Units = cylinders of 2970 * 512 = 1520640 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        2637     3915918   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 13: Permission denied.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

ext3でフォーマット

$ sudo /sbin/mkfs.ext3 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
244800 inodes, 978176 blocks
48908 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1002438656
30 block groups
32768 blocks per group, 32768 fragments per group
8160 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

マウントする

$ sudo mkdir -p /mnt/data
$ sudo mount -t ext3 /dev/sda1 /mnt/data
$ df -h
Filesystem            Size   Used    Avail   Use% Mounted on
/dev/sda1             3.7G   72M   3.5G      3% /mnt/data

SDカードも自動マウントさせるためfstabを編集

$ sudo vi /etc/fstab
> /dev/sda1        /mnt/data   ext3      noatime      0  0

メディア用のフォルダを作成

$ sudo mkdir /mnt/data/videos
$ sudo chmod a+w /mnt/data/videos

SAMBAのインストール

scpでコピーしてもいいけど、僕のエンコードPCはWindowsなので
(sambaの方が楽なので)

$ sudo apt-get install samba

とりあえず"WORKGROUP"のまま(default)

$ sudo chown nobody:nogroup /mnt/data/videos

設定を編集する

$ sudo vi /etc/samba/smb.conf
globalの辺り
+ map to guest = Bad User
最後の辺りに、videosという名前のディレクトリのルールを記述
+ [videos]
+ path = /mnt/data/videos
+ writeable = yes
+ force create mode = 0666
+ force directory mode = 0777
+ guest ok = yes
+ guest only = yes

sambaを起動させる

$ sudo /etc/init.d/samba start
Starting Samba daemons: nmbd smbd.

HostPCからBeagleSambaに接続してみる
例えばNautilusのサイドペインから
Network -> Windows Network -> WORKGROUP -> DEBIAN[BeaglePCName] -> videos
試しに何か動画ファイルをコピーする

文字化けしてたので、日本語環境いれる

$ sudo dpkg-reconfigure locales
で、ja_JP.UTF-8 を選択
$ sudo apt-get install ttf-kochi-gothic ttf-kochi-mincho

MediaTombの設定をする

HostPCのブラウザでBeagleBoardのMediaTombを開く。MediaTombの使用ポート忘れたw

$ sudo nmap 192.168.123.31
Interesting ports on 192.168.123.31:
Not shown: 994 closed ports
PORT      STATE SERVICE
22/tcp    open  ssh
80/tcp    open  http
111/tcp   open  rpcbind
139/tcp   open  netbios-ssn
445/tcp   open  microsoft-ds
49152/tcp open  unknown

49152 ですね

http://192.168.123.31:49152/

あとは適当に設定する
file system から、/mnt/data/videos を追加する

現在調査中

今後の課題として
Nautilusでファイルをドラッグ&ドロップしたら、大きいファイル(700MB)でコピーエラー発生
なんとなくGUIと相性が悪いように感じたので結局rsyncでコピーした