SyntaxHighlighter

2014年7月31日星期四

Pogoplug v4 Arch Linux ARM (ALARM) Setup

BASE: Follow http://archlinuxarm.org/platforms/armv5/pogoplug-series-4 to install ALARM.
Note: use ext4 -j for new fresh install!
Tuning: https://linuxengineering.wordpress.com/2014/08/03/performance-tuning-with-pogoplug-v4/


1. update system: pacman -Syyu, clean pacman cache : pacman -Scc
with sock5 proxy: export all_proxy="socks5://your.proxy:1080"
2. config  ALARM
  • use passwd to change root password
  • un comment en_US.UTF-8 in /etc/locale.gen
  • locale-gen
  • echo LANG=en_US.UTF-8 > /etc/locale.conf
[root@pogoplug ~]# timedatectl set-timezone Asia/Chongqing
[root@pogoplug ~]# hostnamectl set-hostname pogoplug
[root@pogoplug ~]# pacman -Sy parted
[root@pogoplug ~]# parted /dev/sda
(parted)mklabel gpt
(parted)mkpart primary xfs 0% 100%
(parted)quit
[root@pogoplug ~]# mkfs.xfs -f /dev/sdX
[root@pogoplug ~]# cat /etc/fstab
# 
# /etc/fstab: static file system information
#
# <file system> <dir>   <type>  <options>       <dump>  <pass>
#/dev/sda1 /mnt/hdd ext4 defaults 1 2
#/dev/sda2 swap swap defaults 0 0
/dev/sda /mnt/hdd xfs defaults,nofail,noatime,nodev 0 1
[root@pogoplug ~]# cat /etc/systemd/journald.conf
[Journal]
Storage=volatile
3. enable sda sleep
  • pacman -S hdparm
  • systemctl enable sdasleep
[root@pogoplug system]# cat /etc/systemd/system/sdasleep.service 
[Unit]
Description=enable sda sleep
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/hdparm -B 127 /dev/sda

[Install]
WantedBy=multi-user.target
4. install and config samba
  • pacman -S samba
  • systemctl enable smbd nmbd
[root@pogoplug samba]# cat smb.conf 
[global]
 workgroup = WORKGROUP
 server string = POGOPLUG
 netbios name = POGOPLUG
 load printers = no
 printing = bsd
 printcap name = /dev/null
 disable spoolss = yes
 log file = /var/log/samba/%m.log
 max log size = 50
 socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE
 write cache size = 2097152
 use sendfile = yes
 
 #unprotected/public share without login
 security = user
 map to guest = Bad User
 guest account = root
 

[hdd]
  path = /mnt/hdd
  read only = no
  public = yes
  writable = yes
  #force user = root
  guest ok = yes

5. install and config nfs server

[root@pogoplug ~]# pacman -S nfs-utils
[root@pogoplug ~]# cat /etc/exports
# /etc/exports - exports(5) - directories exported to NFS clients
#
# Example for NFSv2 and NFSv3:
#  /srv/home        hostname1(rw,sync) hostname2(ro,sync)
# Example for NFSv4:
#  /srv/nfs4        hostname1(rw,sync,fsid=0)
#  /srv/nfs4/home   hostname1(rw,sync,nohide)
# Using Kerberos and integrity checking:
#  /srv/nfs4        *(rw,sync,sec=krb5i,fsid=0)
#  /srv/nfs4/home   *(rw,sync,sec=krb5i,nohide)
#
# Use `exportfs -arv` to reload.
/mnt/hdd 192.168.88.0/24(rw,fsid=root,no_subtree_check,all_squash,insecure)
[root@pogoplug ~]# exportfs -rav
exporting 192.168.88.0/24:/mnt/hdd
[root@pogoplug ~]# systemctl enable rpcbind
[root@pogoplug ~]# systemctl enable nfs-server
[root@pogoplug ~]# systemctl start rpcbind
[root@pogoplug ~]# systemctl start nfs-server
[root@pogoplug lib]# showmount -e localhost
Export list for localhost:
/mnt/hdd 192.168.88.0/24

6. install and config thunder remote download
[root@pogoplug system]# cat xunlei.service 
[Unit]
Description=Xunlei
After=network.target

[Service]
Type=forking
PIDFile=/run/xunlei.pid
ExecStart=/root/portal

[Install]
WantedBy=multi-user.target

[root@pogoplug xunlei.service.d]# cat restart.conf
[Service]
Restart=always
RestartSec=30

7. install and config Baidu Yun sync
[root@pogoplug system]# cat syncy.service
[Unit]
Description=Baidu Yun Sync
After=network.target

[Service]
Type=simple
ExecStart=/bin/python2 /root/syncy.py

[Install]
WantedBy=multi-user.target

[root@pogoplug config]# pwd
/etc/config
[root@pogoplug config]# cat syncy

config syncy
        option ondup 'rename'
        option blocksize '10'
        option maxrecvspeed '0'
        option syncperiod '0-24'
        option retrydelay '3'
        option datacache 'on'
        option excludefiles '*/Thumbs.db'
        option maxsendspeed '0'
        option listnumber '100'
        option retrytimes '3'
        option syncyerrlog '/tmp/syncy.err.log'
        option syncinterval '3600'
        option syncylog '/tmp/syncy.log'

config syncpath
        option synctype 'download'
        option enable '1'
        option localpath '/mnt/hdd/baidu'
        option remotepath '/'

8. install and config shadowsocks client
  • pacman -S shadowsocks-libev
[root@pogoplug shadowsocks]# pwd
/etc/shadowsocks
[root@pogoplug shadowsocks]# cat alex.json 
{
    "server":"173.254.244.72",
    "server_port":20061,
    "local_address":"0.0.0.0",
    "local_port":7777,
    "password":"ssserver.biz",
    "timeout":600,
    "method":"AES-128-CFB"
}

  • systemctl enable shadowsocks-libev@alex
  • 9. reverse SSH
    • ssh-keygen
    • ssh-copy-id root@remote-host
    /etc/ssh/ssh_config
    
    Host *
        ServerAliveInterval 240
        ServerAliveCountMax 3
        ExitOnForwardFailure yes
    

    [root@pogoplug system]# cat revertssh.service
    [Unit]
    Description=Revert SSH
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/ssh -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval=60" -o "ServerAliveCountMax=2" -N -R 19999:localhost:22 [email protected]
    
    [Install]
    WantedBy=multi-user.target
    

    [root@pogoplug revertssh.service.d]# cat restart.conf
    [Service]
    Restart=always
    RestartSec=30


    KMS
    • https://github.com/Wind4/vlmcsd
    [root@pogoplug system]# cat kms.service
    [Unit]
    Description=Windows KMS server
    After=network.target
    
    [Service]
    Type=oneshot
    ExecStart=/root/KMS/static/vlmcsd-armv5el-musl-thumb-static
    
    [Install]
    WantedBy=multi-user.target
    



    10. Turn ArchLinux on Pogoplug v4


    Boot from SD card!

    • http://forum.doozan.com/read.php?3,12381
    • http://blog.qnology.com/2014/07/hacking-pogoplug-v4-series-4-and-mobile.html
    Kill Pogoplug Service and Download uBoot Flashing Utilities

    #stop my.pogoplug.com service
    killall hbwd

    #download firmware utilities

    cd /tmp
    wget http://download.doozan.com/uboot/nanddump
    wget http://download.doozan.com/uboot/nandwrite
    wget http://download.doozan.com/uboot/flash_erase
    wget http://download.doozan.com/uboot/fw_printenv

    #make execuable
    chmod +x flash_erase fw_printenv nanddump nandwrite

    #printenv and setenv are normally symbolic links
    cp fw_printenv fw_setenv

    #remount '/' as read/write
    #by default the Pogoplug OS (internal flash) is read only
    #skip if running from Debian/ALARM
    mount -o remount,rw /

    #setup fw_env.config
    echo "/dev/mtd0 0xc0000 0x20000 0x20000">/etc/fw_env.config
    Download and Flash new uBoot

    #download uboot and md5
    wget http://download.qnology.com/pogoplug/v4/uboot.2014.07-tld-1.pogo_v4.bodhi.tar
    wget http://download.qnology.com/pogoplug/v4/uboot.2014.07-tld-1.pogo_v4.bodhi.md5

    #check md5 sum (output should match)
    md5sum uboot.2014.07-tld-1.pogo_v4.bodhi.tar
    cat uboot.2014.07-tld-1.pogo_v4.bodhi.md5

    #extract uboot
    tar -xf uboot.2014.07-tld-1.pogo_v4.bodhi.tar
    #erase and flash uboot on mtd0
    #BE EXTRA CAREFUL WITH THE NEXT TWO COMMANDS. NO TYPOS!
    /tmp/flash_erase /dev/mtd0 0 4
    /tmp/nandwrite /dev/mtd0 /tmp/uboot.2014.07-tld-1.pogo_v4.mtd0.kwb



    Download and Flash uBoot Environment Parameters

    #download default uboot env settings and md5
    wget http://download.qnology.com/pogoplug/v4/uboot.2014.07-tld-1.environment.img.bodhi.tar
    wget http://download.qnology.com/pogoplug/v4/uboot.2014.07-tld-1.environment.img.bodhi.md5

    #check md5 sum (output should match)
    md5sum uboot.2014.07-tld-1.environment.img.bodhi.tar
    cat uboot.2014.07-tld-1.environment.img.bodhi.md5

    #extract uboot env settings
    tar -xf uboot.2014.07-tld-1.environment.img.bodhi.tar

    #flash default uboot env setting
    #BE EXTRA CAREFUL WITH THE NEXT TWO COMMANDS. NO TYPOS!
    /tmp/flash_erase /dev/mtd0 0xc0000 1
    /tmp/nandwrite -s 786432 /dev/mtd0 uboot.2014.07-tld-1.environment.img

    Update uBoot Environment Parameters

    #SET MACADDRESS
    /tmp/fw_setenv ethaddr "$(cat /sys/class/net/eth0/address)"

    #double check the MAC Address matches with 
    #what is on the bottom of your Pogoplug
    /tmp/fw_printenv ethaddr

    #set archNumber and machid (for LED)
    /tmp/fw_setenv arcNumber 3960
    /tmp/fw_setenv machid F78

    #set rootfs file system type
    /tmp/fw_setenv usb_rootfstype ext3

    #set to original mtd partition layout
    /tmp/fw_setenv mtdparts 'mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)'

    #print out all uboot environment parameters
    #make sure there are no errors
    /tmp/fw_printenv


    Setup Netconsole (Optional but highly recommended)

    More info here - http://forum.doozan.com/read.php?3,14,14

    #Update IP Addresses as needed
    /tmp/fw_setenv serverip 192.168.1.100
    /tmp/fw_setenv ipaddr 192.168.1.10
    /tmp/fw_setenv if_netconsole 'ping $serverip'
    /tmp/fw_setenv start_netconsole 'setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;'
    /tmp/fw_setenv preboot 'run if_netconsole start_netconsole'
    11. Add Option to Boot Default Pogoplug OS when USB/SD Card is Not Attached
    • http://blog.qnology.com/p/pogoplug-v4-boot-default-pogoplug-os.html?showComment=1408411870403
    From Arch Linux ARM (untested under Debian):

    #download firmware utilities
    cd /tmp
    wget http://download.doozan.com/uboot/fw_printenv

    #make execuable
    chmod +x fw_printenv

    #printenv and setenv are normally symbolic links
    cp fw_printenv fw_setenv

    #setup fw_env.config
    echo "/dev/mtd0 0xc0000 0x20000 0x20000">/etc/fw_env.config


    #mount mtd4 partition
    ubiattach /dev/ubi_ctrl -O 2048 -p /dev/mtd4
    mkdir /tmp/mtd4
    mount -t ubifs ubi0:rootfs /tmp/mtd4

    #download original uboot

    #update uboot environment parameters
    #update boot order to include pogoplug OS
    /tmp/fw_setenv bootcmd 'run bootcmd_usb; run bootcmd_mmc; run bootcmd_sata; run bootcmd_pogo; reset'

    #chain load original uboot
    /tmp/fw_setenv bootcmd_pogo 'if ubi part root 2048 && ubifsmount ubi:rootfs && ubifsload 0x800000 uboot.mtd0.dockstar.original.kwb ; then go 0x800200; fi'



    #if you previously installed the uboot from archlinuxarm.org
    #we need to reset some of the uboot parameters
    cd /tmp
    wget http://download.doozan.com/uboot/blparam
    chmod +x blparam
    /tmp/blparam arcNumber > /dev/null 

    /tmp/blparam mainlineLinux=no > /dev/null
    /tmp/blparam bootcmd='run boot_nand' > /dev/null


    #unplug USB drive and SD Card and test
    reboot
    ........
    [root@pogoplug ~]# curl -O http://download.doozan.com/uboot/fw_printenv
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  652k  100  652k    0     0   113k      0  0:00:05  0:00:05 --:--:--  154k
    [root@pogoplug ~]# chmod +x fw_printenv
    [root@pogoplug ~]# ./fw_printenv 
    Cannot parse config file: No such file or directory
    [root@pogoplug ~]# ls
    cfg  fw_printenv  lib  portal  syncy.log  syncy.py
    [root@pogoplug ~]# echo "/dev/mtd0 0xc0000 0x20000 0x20000">/etc/fw_env.config
    [root@pogoplug ~]# ./fw_printenv 
    arcNumber=3960
    baudrate=115200
    bootcmd=run bootcmd_usb; run bootcmd_mmc; run bootcmd_sata; run bootcmd_pogo; reset
    bootcmd_mmc=run mmc_init; run set_bootargs_mmc; run mmc_boot
    bootcmd_pogo=if ubi part root 2048 && ubifsmount ubi:rootfs && ubifsload 0x800000 uboot.mtd0.dockstar.original.kwb ; then go 0x800200; fi
    bootcmd_sata=run sata_init; run set_bootargs_sata; run sata_boot;
    bootcmd_usb=run usb_init; run set_bootargs_usb; run usb_boot;
    bootdelay=10
    console=ttyS0,115200
    device=0:1
    ethact=egiga0
    ethaddr=00:25:31:05:08:2e
    if_netconsole=ping $serverip
    ipaddr=192.168.1.10
    led_error=orange blinking
    led_exit=green off
    led_init=green blinking
    machid=F78
    mainlineLinux=yes
    mmc_boot=mw 0x800000 0 1; run mmc_load_uimage; if run mmc_load_uinitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi
    mmc_init=mmc rescan
    mmc_load_uimage=ext2load mmc $device 0x800000 /boot/uImage
    mmc_load_uinitrd=ext2load mmc $device 0x1100000 /boot/uInitrd
    mmc_root=/dev/mmcblk0p1
    mtdids=nand0=orion_nand
    mtdparts=mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)
    ncip=192.168.1.100
    partition=nand0,2
    preboot=run if_netconsole start_netconsole
    preboot_nc=run if_netconsole start_netconsole
    rootdelay=10
    rootfstype=ext4
    sata_boot=mw 0x800000 0 1; run sata_load_uimage; if run sata_load_uinitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi
    sata_init=ide reset
    sata_load_uimage=ext2load ide $device 0x800000 /boot/uImage
    sata_load_uinitrd=ext2load ide $device 0x1100000 /boot/uInitrd
    sata_root=/dev/sda1
    serverip=192.168.1.100
    set_bootargs_mmc=setenv bootargs console=$console root=$mmc_root rootdelay=$rootdelay rootfstype=$rootfstype $mtdparts
    set_bootargs_sata=setenv bootargs console=$console root=$sata_root rootdelay=$rootdelay rootfstype=$rootfstype $mtdparts
    set_bootargs_usb=setenv bootargs console=$console root=$usb_root rootdelay=$rootdelay rootfstype=$rootfstype $mtdparts
    start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;
    stderr=nc
    stdin=nc
    stdout=nc
    usb_boot=mw 0x800000 0 1; run usb_load_uimage; if run usb_load_uinitrd; then bootm 0x800000 0x1100000; else bootm 0x800000; fi
    usb_init=usb start
    usb_load_uimage=ext2load usb $device 0x800000 /boot/uImage
    usb_load_uinitrd=ext2load usb $device 0x1100000 /boot/uInitrd
    usb_root=/dev/sda1
    usb_rootfstype=ext3
    [root@pogoplug ~]# curl -O http://download.doozan.com/uboot/blparam
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 14168  100 14168    0     0  12606      0  0:00:01  0:00:01 --:--:-- 12627
    [root@pogoplug ~]# chmod +x blparam 
    [root@pogoplug ~]# ./blparam 
    baudrate=115200
    loads_echo=0
    rootpath=/mnt/ARM_FS/
    netmask=255.255.0.0
    run_diag=yes
    CASset=min
    MALLOC_len=1
    ethprime=egiga0
    load_nand=nboot 0x800000 0 0x200000
    load_nand2=nboot 0x800000 0 0x500000
    boot=bootm 0x800000
    boot_nand=run load_nand boot || run load_nand2 boot
    ethmtu=1500
    usb0Mode=host
    nandEcc=1bit
    ethact=egiga0
    ethaddr=00:25:31:05:08:2e
    cesvcid=VPLE24UWT7KRSFFRJGPGV77L56
    ceboardver=PPV4A3
    ipaddr=192.168.58.233
    serverip=192.168.58.188
    bootargs=console=ttyS0,115200 root=ubi0:rootfs ubi.mtd=4,2048 rootfstype=ubifs
    stdin=serial
    stdout=serial
    stderr=serial
    enaMonExt=no
    enaCpuStream=no
    enaWrAllo=no
    pexMode=RC
    disL2Cache=no
    setL2CacheWT=yes
    disL2Prefetch=yes
    enaICPref=yes
    enaDCPref=yes
    sata_dma_mode=yes
    netbsd_en=no
    vxworks_en=no
    bootdelay=1
    disaMvPnp=no
    hddPowerCtrl=no
    pcieTune=no
    arcNumber=3960
    mainlineLinux=yes
    bootcmd=if usb start; then run alarm_boot; else nand read 0x800000 0x100000 0x73d0c; go 0x800000; fi
    alarm_boot=ide reset; run alarm_revert; if ide part 0; then run alarm_ide; else setenv isDisk no; fi; run alarm_usb
    alarm_revert=if fatls usb 0:1 /revert; then setenv mainlineLinux no; setenv arcNumber; setenv bootcmd run boot_nand; saveenv; reset; fi
    alarm_args=setenv bootargs console=ttyS0,115200 root=$device rootwait rootfstype=ext3
    alarm_which=if test $isDisk = yes; then setenv device /dev/sdb1; else setenv device /dev/sda1; fi
    alarm_ide=if ext2load ide 0:1 0x800000 /boot/uImage; then setenv device /dev/sda1; run alarm_args; bootm 0x800000; else setenv isDisk yes; fi
    alarm_usb=if ext2load usb 0:1 0x800000 /boot/uImage; then run alarm_which; run alarm_args; bootm 0x800000; fi
    [root@pogoplug ~]# ./blparam arcNumber > /dev/null
    [root@pogoplug ~]# ./blparam mainlineLinux=no > /dev/null
    [root@pogoplug ~]# ./blparam bootcmd='run boot_nand' > /dev/null
    [root@pogoplug ~]# ./blparam
    baudrate=115200
    loads_echo=0
    rootpath=/mnt/ARM_FS/
    netmask=255.255.0.0
    run_diag=yes
    CASset=min
    MALLOC_len=1
    ethprime=egiga0
    load_nand=nboot 0x800000 0 0x200000
    load_nand2=nboot 0x800000 0 0x500000
    boot=bootm 0x800000
    boot_nand=run load_nand boot || run load_nand2 boot
    ethmtu=1500
    usb0Mode=host
    nandEcc=1bit
    ethact=egiga0
    ethaddr=00:25:31:05:08:2e
    cesvcid=VPLE24UWT7KRSFFRJGPGV77L56
    ceboardver=PPV4A3
    ipaddr=192.168.58.233
    serverip=192.168.58.188
    bootargs=console=ttyS0,115200 root=ubi0:rootfs ubi.mtd=4,2048 rootfstype=ubifs
    stdin=serial
    stdout=serial
    stderr=serial
    enaMonExt=no
    enaCpuStream=no
    enaWrAllo=no
    pexMode=RC
    disL2Cache=no
    setL2CacheWT=yes
    disL2Prefetch=yes
    enaICPref=yes
    enaDCPref=yes
    sata_dma_mode=yes
    netbsd_en=no
    vxworks_en=no
    bootdelay=1
    disaMvPnp=no
    hddPowerCtrl=no
    pcieTune=no
    alarm_boot=ide reset; run alarm_revert; if ide part 0; then run alarm_ide; else setenv isDisk no; fi; run alarm_usb
    alarm_revert=if fatls usb 0:1 /revert; then setenv mainlineLinux no; setenv arcNumber; setenv bootcmd run boot_nand; saveenv; reset; fi
    alarm_args=setenv bootargs console=ttyS0,115200 root=$device rootwait rootfstype=ext3
    alarm_which=if test $isDisk = yes; then setenv device /dev/sdb1; else setenv device /dev/sda1; fi
    alarm_ide=if ext2load ide 0:1 0x800000 /boot/uImage; then setenv device /dev/sda1; run alarm_args; bootm 0x800000; else setenv isDisk yes; fi
    alarm_usb=if ext2load usb 0:1 0x800000 /boot/uImage; then run alarm_which; run alarm_args; bootm 0x800000; fi
    mainlineLinux=no
    bootcmd=run boot_nand

    [root@pogoplug ~]# 
    ........

    TIP: use ncftp to upload folder
    ncftpput -R -y ls-qvl /disk2/500g/AV/ $1

    没有评论:

    发表评论