找回密碼
 新用戶註冊
搜索
熱搜: hifi av 音樂
樓主: obee

[CAS] 又平又正的 CAS (MPD on Linux) - 2013-05-02

[複製鏈接]
發表於 2013-3-26 08:24:24 | 顯示全部樓層
CAS2012 發表於 2013-3-25 11:27
elo ching,
I use pogoplug as VAMP only, the idea is to stream music data from NAS through NAS's inte ...

CAS2012 hing

My Voyage starter kit retreive music file through Lan from my Synology NAS.

I also find the latest Ubuntu is rather slow and consume a lot of resources from the PC.
回復

使用道具 舉報

發表於 2013-3-26 09:52:47 | 顯示全部樓層
elo hing,
Good to know your Voyage starter kit is in streaming mode, how about the ArchLinux mpd?
回復

使用道具 舉報

發表於 2013-3-26 16:02:23 | 顯示全部樓層
I am still in business trip and not in Hong Kong.  Will start his ArchLinux MPD projectonce back to HK next week.
回復

使用道具 舉報

 樓主| 發表於 2013-3-26 16:33:51 | 顯示全部樓層
本帖最後由 obee 於 2013-3-30 19:01 編輯

把 Cubox 上的 Linux 改成 "read-only file system"
這是一個大工程, 我花了成個星期研究. 因為我不是Linux老手, 其實對某些人來說可是易如反掌的事情.

先說為何要改成 read-only file system, 目的是要用家不用每次打 command 去關機又不會因此而有 data corruption.

好了, 如果你有 cubox 又想跟住做, 建議你先細閱以下步驟先開始. 因為我覺得唔係咁易.

首先, 要令個 "root" partition read-only, 我地一定要找出所有會有"寫入"動作的 file, 這個有兩類的:
1. 每次的寫入是過慮積性的, 即是系統希望下次可以讀番以前寫入的資料. 例如 MPD 個 music library database (在 /var/lib/mpd/mpd.db)
2. 每次的寫入跟之前的沒有關連, 即是系統不會介意你將之前買了的 delete 左, 例如 MPD 的 log (/run/shm/mpd/mpd.log)

對於以上兩類 file, 我會將 "1" 果類放係 NAS 上, 另外 "2" 果類我會放係 RAM drive 內.

好了, 下一步係要找出所有會有"寫入"動作的 file. 我理解, 大多的寫入 (不計 /run, /proc) 都在 "/var" 的, 我(靠試)搵到幾個:

1. 先將 log 同 tmp 移走:
  1. mv /var/log /run
  2. ln -s /run/log /var/log
  3. mv /var/tmp /run
  4. ln -s /run/tmp /var/tmp
複製代碼
2. random number

  1. mv /var/lib/urandom /run/urandom
  2. ln -s /run/urandom /var/lib
  3. mv /var/lib/dhcp /run/urandom
  4. ln -s /run/dhcp /var/lib
複製代碼
3. 攪完 /var, 我建議改改 MPD:
  1. mkdir -p /run/music/nas
  2. ln -s /run/music /music
複製代碼
然後 edit "/etc/fstab", 把 /var/lib/mpd/music 的 mount point 改為 /music/nas, 跟住 remount:
  1. umount /var/lib/mpd/music
  2. mount /music/nas
複製代碼
Create 番D file:
  1. mkdir -p /music/nas/.mpdConf/cubox /music/nas/.mpdConf/playlists
  2. mv /var/lib/mpd/playlists /music/nas/.mpdConf/
  3. touch /music/nas/.mpdConf/cubox/db /music/nas/.mpdConf/cubox/state /music/nas/.mpdConf/cubox/sticker.sql
  4. chmod 777 -R /music/nas/.mpdConf
複製代碼
然後 update mpd.conf: vi /etc/mpd.conf
  1. music_directory         "/music"
  2. playlist_directory      "/music/nas/.mpdConf/playlists"
  3. db_file                 "/music/nas/.mpdConf/cubox/db"
  4. log_file                "/run/shm/mpd/mpd.log"
  5. pid_file                "/run/shm/mpd/pid"
  6. state_file              "/music/nas/.mpdConf/cubox/state"
  7. sticker_file            "/music/nas/.mpdConf/cubox/sticker.sql"
複製代碼
restart MPD:
  1. service mpd restart
複製代碼
看看可否播歌? 如果OK, 繼續... 唔OK, check 下點解/重做

好了, 現在試下 mount root as read-only:
  1. mount -o remount,ro /
複製代碼
如果 ok, 咁可以繼續... 唔OK, check 下點解/重做
最後就要叫 system 每次開機都 create 番果 d 空穀 folder / file 同埋自動 remount as read-only:

  1. vi /etc/init.d/readonlySetup
複製代碼

  1. #!/bin/sh

  2. ### BEGIN INIT INFO
  3. # Provides:          read-only file-system preparation
  4. # Required-Start:    $remote_fs $syslog
  5. # Required-Stop:     $remote_fs $syslog
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: prepare for read-only root FS
  9. # Description:       prepare for read-only root FS
  10. ### END INIT INFO

  11. prep_start () {
  12.         echo "Prep for read-only FS"
  13.         /bin/mkdir -p /run/log /run/tmp /run/urandom /run/dhcp /run/music/nas
  14.         /bin/chmod -R 777 /run/log /run/tmp /run/urandom /run/dhcp /run/music/nas
  15.         /bin/mount -o remount,ro /
  16. }

  17. prep_stop () {
  18.         echo "Prep for read-only FS (stop)"
  19.         /bin/mount -o remount,rw /
  20. }

  21. case "$1" in
  22.     start)
  23.         prep_start
  24.         ;;
  25.     stop)
  26.         prep_stop
  27.         ;;
  28.     *)
  29.         echo "Usage: $0 {start|stop}"
  30.         exit 2
  31.         ;;
  32. esac
複製代碼
再放番去 rcX.d:

  1. chmod 777 /etc/init.d/readonlySetup
  2. ln -s /etc/init.d/readonlySetup /etc/rc1.d/S10readonlySetup
  3. ln -s /etc/init.d/readonlySetup /etc/rc2.d/S10readonlySetup
  4. ln -s /etc/init.d/readonlySetup /etc/rc3.d/S10readonlySetup
  5. ln -s /etc/init.d/readonlySetup /etc/rc4.d/S10readonlySetup
  6. ln -s /etc/init.d/readonlySetup /etc/rc5.d/S10readonlySetup
複製代碼
完成!

  1. sync
  2. reboot
複製代碼
(以上的可能有錯漏, 因為小弟都係摸住石頭過河, 請大家多多指教 )

評分

1

查看全部評分

回復

使用道具 舉報

 樓主| 發表於 2013-3-26 17:20:12 | 顯示全部樓層
繼上文...
以後如果你要改 sdcard 上的資料, 一定要先將 root partition 改為 read-write mode先:
  1. mount -o remount,rw /
複製代碼
改後打番:
  1. mount -o remount,ro /
複製代碼
便可

評分

1

查看全部評分

回復

使用道具 舉報

 樓主| 發表於 2013-3-27 09:57:49 | 顯示全部樓層
本帖最後由 obee 於 2013-3-27 19:09 編輯

DDC Card 早幾天收到了. (購自:http://item.taobao.com/item.htm?id=18075891198




將 pogoplug 同 ddc card 合體, 再加個 cheap cheap $4 RCA 頭 (唔用BNC 因為條COAXIAL都係RCA頭




成功, 開聲煲煲先

評分

2

查看全部評分

回復

使用道具 舉報

發表於 2013-3-27 10:13:32 | 顯示全部樓層
obee 發表於 2013-3-27 09:57
DDC Card 早幾天收到了.

obee兄好勁呀,連部野都改埋機
回復

使用道具 舉報

 樓主| 發表於 2013-3-27 10:18:37 | 顯示全部樓層
baki1105 發表於 2013-3-27 10:13
obee兄好勁呀,連部野都改埋機

因為我的DAC只有1個USB, 加張DDC可以用同軸入DAC. 講到底, 純粹身痕

評分

1

查看全部評分

回復

使用道具 舉報

 樓主| 發表於 2013-3-27 17:47:57 | 顯示全部樓層
令 Cubox 可以播放 USB 手指上的音樂檔
繼上文, 把 Cubox 改成 read-only file system 後, 個 music folder 改為 "/music/nas", 以下會講如何教系統自己detect 到有 USB 手指而去 mount.

先改番 root 做 read-write mode:
  1. mount -o remount,rw /
複製代碼
生一個新 file:
  1. vi /etc/udev/rule.d/11-auto-mount.rules
複製代碼
輸入以下後 save:
  1. KERNEL=="mmc*", GOTO="auto_mount_end"
  2. KERNEL!="sd[a-z]*", GOTO="auto_mount_end"
  3. ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="auto_mount_end"

  4. # Set environment
  5. ACTION=="add", IMPORT{program}="/sbin/blkid -o udev -p -s TYPE -s LABEL %N"

  6. # Global mount options
  7. ACTION=="add", ENV{mount_options}="ro,relatime,users,umask=0"

  8. # Filesystem specific options
  9. ACTION=="add", ENV{ID_FS_TYPE}=="vfat", ENV{mount_options}="%E{mount_options},showexec"
  10. ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", ENV{mount_options}="%E{mount_options},utf8"

  11. # Get mount point
  12. # use basename to correctly handle labels such as ../mnt/foo
  13. ACTION=="add", ENV{ID_FS_LABEL}=="?*", PROGRAM="/usr/bin/basename '%E{ID_FS_LABEL}'", ENV{dir_name}="%c"
  14. ACTION=="add", ENV{dir_name}!="?*", ENV{dir_name}="usbhd-%k"

  15. # Main action
  16. ACTION=="add", ENV{dir_name}=="?*", RUN+="/bin/mkdir -p '/usb/usb/%E{dir_name}'", RUN+="/bin/mount -o %E{mount_options} /dev/%k '/run/usb/%E{dir_name}'"
  17. ACTION=="remove", ENV{dir_name}=="?*", RUN+="/bin/umount -l '/run/usb/%E{dir_name}'", RUN+="/bin/rmdir '/run/usb/%E{dir_name}'", RUN+="/bin/ln -s '/run/usb/%E{dir_name}' '/music/%E{dir_name}'"

  18. LABEL="auto_mount_end"

  19. # label must be cleared
  20. ENV{ID_FS_LABEL}=""
複製代碼
咁就OK了. 唔使 reboot, 只要插入 usb 手指 (可以係 ntfs / fat / ext2...) 咁 "music" 內會多左個 "usb" folder, 入去會見到有 USB 手指的 partition, 再入去會有手指內的歌 (MPD 要按 "update database" 或者 set 左 auto update)

評分

1

查看全部評分

回復

使用道具 舉報

發表於 2013-3-28 02:49:00 | 顯示全部樓層
本帖最後由 CAS2012 於 2013-3-28 02:50 編輯

obee ching,
I tried to install ArchLinux  + mpd  twice, yesterday and today. Sad to know that the pogoplug failed to boot up after a few trial. I spent 6 hours already.
Obee hing, this thread is very confusing, sometimes is cube and sometime is pogoplug, is it possible to open a new thread or a complete step by step tutorial for pogoplug only. I am now using Synology 212j NAS internal Sueezebox player, I got two pogoplugs (p1 & p2) installed VAMP, I can play different musics on p1 and p2. However, I tried to install Squeezebox server on the 3rd  pogoplug, it can only stream mp3, cannot stream wav file. I guess the hardware of pogoplug is only suitable for VAMP.
回復

使用道具 舉報

 樓主| 發表於 2013-3-28 07:36:48 | 顯示全部樓層
CAS2012 發表於 2013-3-28 02:49
obee ching,
I tried to install ArchLinux  + mpd  twice, yesterday and today. Sad to know that the po ...


1. I can open another post later for pogoplug.
2. VAMP requires additional library in order to play WAV file. I guess this is because the creator of VAMP only plays FLAC & MP3 files.
回復

使用道具 舉報

發表於 2013-3-28 08:26:45 | 顯示全部樓層
CAS2012 發表於 2013-3-28 02:49
obee ching,
I tried to install ArchLinux  + mpd  twice, yesterday and today. Sad to know that the po ...

Obee hing

My pogoplug mpd also could not boot up yesterday and seems that all the USB ports failed to see the USB drive. Any idea what happenes?

Thanks.
回復

使用道具 舉報

 樓主| 發表於 2013-3-28 09:56:46 | 顯示全部樓層
elo 發表於 2013-3-28 08:26
Obee hing

My pogoplug mpd also could not boot up yesterday and seems that all the USB ports faile ...


Did you type "sync" before poweroff?
I guess your USB card has data corruption. It happens very easy in pogoplug. On the other hand, Cubox doesn't get data corruption that easy.
回復

使用道具 舉報

發表於 2013-3-28 12:43:48 | 顯示全部樓層
obee 發表於 2013-3-28 09:56
Did you type "sync" before poweroff?
I guess your USB card has data corruption. It happens very ea ...

May be it is the reason.  However when I try to install ArchLinux, it cannot find the USB drive when do the fdisk command.  That's why I suspect the USB ports having problem.



回復

使用道具 舉報

 樓主| 發表於 2013-3-28 12:46:01 | 顯示全部樓層
elo 發表於 2013-3-28 12:43
May be it is the reason.  However when I try to install ArchLinux, it cannot find the USB drive wh ...

mn... Try this USB key on another machine, like NAS or PC, to make sure it is readable first. I have several pogoplugs and usb keys and I never have such problem.
回復

使用道具 舉報

發表於 2013-3-28 12:52:36 | 顯示全部樓層
obee 發表於 2013-3-28 12:46
mn... Try this USB key on another machine, like NAS or PC, to make sure it is readable first. I ha ...

The USB drive can be recognized by my Mac so really don't understand what happened.  Can the  Pogoplug reset to its factory spec.  so I can try it over again ?
回復

使用道具 舉報

 樓主| 發表於 2013-3-28 13:16:55 | 顯示全部樓層
elo 發表於 2013-3-28 12:52
The USB drive can be recognized by my Mac so really don't understand what happened.  Can the  Pogo ...

There is a "reset" button inside the pogoplug near the LED, but it is not "factory reset" button. It just "just cut the power and connect again".

What you have modified is just the booting sequence, the default version of pogoplug never read the USB keys inserted for bootup, it just boot from the internal NAND. What the modify did are:
1. Amend the boot sequence, allows it to scan all the USB ports for bootable USB keys
2. Disable the pogoplug cloud station service, because this service has "over-the-air" firmware update feature, that the OS in NAND drive (and the modification) might be overwritten automatically by the pogoplug official. Disables that service just make the pogoplug not connected to the "cloud", if you re-enable it, it will act like original.
回復

使用道具 舉報

 樓主| 發表於 2013-3-28 17:42:00 | 顯示全部樓層
CAS2012 發表於 2013-3-28 02:49
obee ching,
I tried to install ArchLinux  + mpd  twice, yesterday and today. Sad to know that the po ...


Please refer to this post.
http://www.hiendy.com/hififorum/ ... p;extra=#pid1385487

I only talk about ArchLinux + mpd. For the others, please refer to the old post or other source on web.
回復

使用道具 舉報

發表於 2013-4-5 01:22:04 | 顯示全部樓層
Obee Ching,
你新裝個塊Usb卡系好野黎!
Usb to I2S ,support DSD!
Work 嗎?
回復

使用道具 舉報

 樓主| 發表於 2013-4-5 07:48:53 | 顯示全部樓層
stupidguy 發表於 2013-4-5 01:22
Obee Ching,
你新裝個塊Usb卡系好野黎!
Usb to I2S ,support DSD!

Work. But my DAC no DSD support so only PCM. And I use coaxial output.
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 新用戶註冊

本版積分規則

Archiver|小黑屋|聯絡我們|刊登廣告|Hiendy.com 影音俱樂部 一個屬於音響愛好者的家

GMT+8, 2024-4-20 13:56 , Processed in 0.044782 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回復 返回頂部 返回列表