Menu

Debian_Chroot

Anonymous

Howto Debian environment within SnakeOs.

Written by Robert Szabo.

Introduction

Very simple way to have Debian (and its huge number of packages). Chroot is a "jailed environment" (embedded system within a linux) where you have debian libraries, packages and the whole deb environment within SnakeOS host.)

You only need to have an USB device attached. (No serial connection needed.)

Use ext2 or ext3 file system to extract files below. (On FAT it will be extracted, but wont work!)

Details

  1. ssh to NAS - or putty from win
  2. #cd /usb/sda1
  3. Download chroot debian with wget:
  4. # wget http://snake-os.googlecode.com/files/debian_chroot.tgz
  5. backup your earlier debian config files if needed.
  6. # rm -R debian ** ! This will erase previous debian directory!**
  7. #tar -xvf debian.tgz
  8. #mount -o bind /proc /usb/sda1/debian/proc
  9. #mount -o bind /dev /usb/sda1/debian/dev
  10. #mount -o bind /usb/sda1 /usb/sda1/debian/mnt/sda1 - this is not mandatory
  11. edit /usb/sda1/debian/etc/resolv.conf -Set your name server, if you need. Default is 192.168.1.1
  12. #chroot /usb/sda1/debian/

Now you are in chrooted debian shell. To exit debian use "exit" command or reboot.

Debianctl

Steps eight to eleven can be automated with the debianctl package. Once installed go to Services->Debianctl and set the directory where Debian was extracted, the disks to mount and the services to start. From then on debianctl will automatically bring up Debian at system startup.

Current version: http://code.google.com/p/snake-os/downloads/detail?name=debianctl-0.3-1.opk

**Some useful - "must have" thing: **

  • to have tons of debian packages use APT:)
  • apt-get install packagename
  • mc - Midnight Commander - feature full file commander. Just run: mc
  • plowdown <--- downloading from hosting servicees like rapdishare and megaupload ( from http://code.google.com/p/plowshare/downloads/list. apt-get install plowdown.
  • screen <--- It allows you to run "virtual terminals" with the added benefit that closing the connection the process keep running, so no need to do 10 ssh sessions, or using nohup. apt-get install screen.
  • Mount dev and proc, you can use fstab if yo whish.

Related

Wiki: Snake-OS Wiki

Discussion

1 2 3 4 > >> (Page 1 of 4)
  • Anonymous

    Anonymous - 2010-04-19

    Originally posted by: robert1...@gmail.com

    Original idea is from Naxeras, and JG from the forum thank for them. :)

     
  • Anonymous

    Anonymous - 2010-04-30

    Originally posted by: jgu...@gmail.com

    Great to see a properly made howto. I am too lazy to do it, so I am happy now I just need to link your doc when someone asks for a binary of a given software for SnakeOS.

    Also I may add these "must" packages wget <--- for downloading from http and ftp (available thru apt-get) plowdown <--- downloading from hosting servicees like rapdishare and megaupload ( from http://code.google.com/p/plowshare/downloads/list beware it depends on many packages all available thru apt-get) screen <--- It allows you to run "virtual terminals" with the added benefit that closing the connection the process keep running, so no need to do 10 ssh sessions, or using nohup

    Thanks again robert1968

    JG

     
  • Anonymous

    Anonymous - 2010-05-06

    Originally posted by: mplaw...@gmail.com

    A couple of recommendations: (1) Better USB Mount in chroot Env To get access to your /dev/sd**'s, instead of mounting within the chrooted environment as suggested above (mkdir /mnt/sda1; mount /dev/sda1 /mnt/sda1), bind it from outside the chrooted environment:

    mount -o bind /usb/sda1 /usb/sda1/debian/mnt/sda1

    Now, if you chroot into /usb/sda1/debian, your sda1 will be accessible from within /mnt/sda1. **

    (2) SSH in chroot environment at boot Have the chrooted environment start-up on boot of the nas device with an sshd service running: ** Configure your chrooted /etc/ssh/sshd_config to use a port other than 22 (since the nas device is using 22) ** Create a file in your nas (which I will use to mean the "real," non-chroot environment) /etc/init.d directory called chroot-ssh-init.sh with the following contents: (assuming you put your chroot environment on sda1. Change as necessary)

    export CHROOTDIR=/usb/sda1/debian mount -t devpts devpts $CHROOTDIR/dev/pts mount -t proc proc $CHROOTDIR/proc mount -o bind /usb/sda1 $CHROOTDIR/mnt/sda2 chroot $CHROOTDIR /etc/init.d/ssh start

    ** Make the file executable

    chmod +x /etc/init.d/chroot-ssh-init.sh

    ** Drop out one of your services (note: this could be done prettier by modifying /usr/share/snakeos/rc.sysinit, what self-respecting computer geek uses telnet anyhow ;) ) to get this booted on startup:

    mv /etc/init.d/telnet /etc/init.d/telnet.nothankyou ln -s /etc/init.d/chroot-ssh-init.sh /etc/init.d/telnet

    ** Save the configuration (SnakeOS Web GUI System -> Config -> Save Configuration ** Start it up and test it out

    /etc/init.d/chroot-ssh-init.ssh ssh -p portyouusedinchroot root@nasipaddress

    ** Reboot the NAS device (don't pull the plug, use the GUI since it calls a reboot script that nicely shuts you down) and see that your system boots with the chrooted ssh! **

    (3) Cronjobs in chroot Because the chroot env don't run init scripts, your crontab is useless. You probably could start it up in the chroot-ssh-init.sh script above. However, you could also use the crond running on your nas: **Adding lines to the /etc/cron.d/root file (assuming, again, your chroot environment is in /usb/sda1/debian):

    30

    ** ** ** ** /usr/sbin/chroot /usb/sda2/debian /bin/su - someuser -c /usr/bin/flexget (Note: This assumes that you have created a user someuser in your chroot environment and you are logging in generally as root like a good computer geek... Obviously, if you are being sloppy and didn't create another user, you would not need the '/bin/su - someuser -c' portion in the line above. You probably also didn't change your sshd_config to not allow root login. Tsk tsk tsk.) ** Save your configuration! NAS Web GUI: System->Config->Save Config ** Restart your crond

    /etc/init.d/cron restart

    **

    (4) Flexget in chroot Yes, you may have noticed from the previous item that flexget works just fine. Just follow the Flexget installation instructions for Linux systems within your chroot environment. The debian port above only has python2.5, no worries - works fine.

    Enjoy!

     
  • Anonymous

    Anonymous - 2010-05-06

    Originally posted by: mplaw...@gmail.com

    Sorry about the formatting of the previous post. Didn't go as I expected. I hope you get the gist.

     
  • Anonymous

    Anonymous - 2010-05-09

    Originally posted by: ols...@gmail.com

    Hello,

    Can use usb/sda6 instead of usb/sda1 ? I have the first partition busy with storage, and sometime before I left sda6 for this purpose.

     
  • Anonymous

    Anonymous - 2010-05-30

    Originally posted by: joakim.b...@gmail.com

    Cant get SSH to work in chroot. My chroot-ssh-init.sh file looks like this:

    export CHROOTDIR=/usb/sda1/debian mount -t devpts devpts $CHROOTDIR/dev/pts mount -t proc proc $CHROOTDIR/proc mount -o bind /usb/sda1 $CHROOTDIR/mnt/sda2 chroot $CHROOTDIR /etc/init.d/ssh start

    The "ssh start" line wont be executed until I exit chroot.

     
  • Anonymous

    Anonymous - 2010-05-30

    Originally posted by: joakim.b...@gmail.com

    crappy formating. Trying again:

    export CHROOTDIR=/usb/sda1/debian

    mount -t devpts devpts $CHROOTDIR/dev/pts

    mount -t proc proc $CHROOTDIR/proc

    mount -o bind /usb/sda1 $CHROOTDIR/mnt/sda2

    chroot $CHROOTDIR

    /etc/init.d/ssh start

     
  • Anonymous

    Anonymous - 2010-05-30

    Originally posted by: joakim.b...@gmail.com

    Seems the problem was with formating all along.

    The last line is supose to be like this:

    chroot $CHROOTDIR /etc/init.d/ssh start

     
  • Anonymous

    Anonymous - 2010-06-06

    Originally posted by: rosanec...@gmail.com

    I'm able to successfully installed GCC package, but can't install libc6-dev package. apt-get keeps saying:

    Err http://security.debian.org stable/updates/main linux-libc-dev 2.6.26-1lenny4

    404 Not Found [IP: 195.20.242.89 80]

    Failed to fetch http://security.debian.org/pool/updates/main/l/linux-2.6/linux-libc-dev_2.6.26-21lenny4_arm.deb 404 Not Found [IP: 195.20.242.89 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

    Can anyone help me?

     
  • Anonymous

    Anonymous - 2010-06-17

    Originally posted by: ols...@gmail.com

    Hello

    I want to thank all that are working in development software for this reborn device, also all others like me that share their experiences.

    I cannot modify the rc.sysinit even as root file because it is read-only file system. how do you passed this barrier ?

    thanks in advance

     
  • Anonymous

    Anonymous - 2010-07-05

    Originally posted by: mike....@gmail.com

    I couldn't get the whole telnet thing working correctly with the whole rename-the telnet daemon & replace thing due to the whole "webstatus()" call within the telnet script. So i ended up doing a slight kludge and just editing the original telnet script to add the required lines in the startup script for telnet

    within start()

    /usr/sbin/telnetd &

    lets get ssh start in chroot working

    export CHROOTDIR=/usb/sda1/debian

    mount -t devpts devpts $CHROOTDIR/dev/pts

    mount -t proc proc $CHROOTDIR/proc

    mount -o bind /usb/sda1 $CHROOTDIR/mnt/sda2

    chroot $CHROOTDIR /etc/init.d/ssh start

    within stop()

    echo "Shutting down $KIND service..."

    lets get ssh stop in chroot working

    export CHROOTDIR=/usb/sda1/debian

    mount -t devpts devpts $CHROOTDIR/dev/pts

    mount -t proc proc $CHROOTDIR/proc

    mount -o bind /usb/sda1 $CHROOTDIR/mnt/sda2

    chroot $CHROOTDIR /etc/init.d/ssh stop

    pkill -f -9 "telnetd"

    I know it may be a bit redundant and is continually calling mount excessively, but i have managed to get it to work with the stop/start/restart buttons, so I'm pretty happy with that.

     
  • Anonymous

    Anonymous - 2010-07-16

    Originally posted by: Jenssond...@gmail.com

    Thanks for providing this, but HOW ON EARTH to install plowdown... No problem to download the package. I unpacked it through winrar and put the files on /sda1

    Then what ?

    Documentation is WONDERFUL then idiots like me ALSO got a chance.....

     
  • Anonymous

    Anonymous - 2010-07-19

    Originally posted by: nileshme...@gmail.com

    From memory I did somthing like below to get it installed. Hopefully I haven't missed any steps.

    #update /etc/resolv.conf with my nameserver
    apt-get update
    wget http://plowshare.googlecode.com/files/plowshare_0.9.3-1_all.deb
    dpkg -i plowshare_0.9.3-1_all.deb
    apt-get install plowshare
    apt-get -f install
    exit
    #chroot back into debian
    ln -s /proc/self/fd /dev/fd
    apt-get install util-linux
    
     
  • Anonymous

    Anonymous - 2010-07-25

    Originally posted by: duncanb...@gmail.com

    Nice work all - I'm happily running a chrooted SSH on my box now thanks to all the comments above.

    I found that because my disk was formatted in NTFS (yeah, I know, bad performance etc but I've got too much on the disk already to muck about reformatting), I had permissions problems if I just extracted debian.tgz to the filesystem.

    My solution: I created a 1G loopback ext2 filesystem and extracted debian onto that, dropped the file onto my NTFS filesystem and used a loopback mount command to run.

    Creating the loopback filesystem:

    root@myhost# dd if=/dev/zero of=/tmp/debian.img bs=1M seek=1024
    1+0 records in
    1+0 records out
    1048576 bytes (1.0 MB) copied, 0.00405798 s, 258 MB/s
    root@myhost# ls -lh /tmp/debian.img
    -rw-r--r-- 1 root root 1.1G 2010-07-25 22:59 /tmp/debian.img
    root@myhost# mkfs.ext2 /tmp/debian.img 
    mke2fs 1.41.11 (14-Mar-2010)
    /tmp/debian.img is not a block special device.
    Proceed anyway? (y,n) y
    warning: 256 blocks unused.
    
    Filesystem label=
    [etc]
    root@myhost# mkdir /tmp/debian
    root@myhost# mount -o loop /tmp/debian.img /tmp/debian
    root@myhost# tar xzf debian.tgz -C /tmp
    root@myhost# umount /tmp/debian
    root@myhost# cp /tmp/debian.img [YOUR USB DEVICE MOUNTPOINT HERE]
    

    Then I created a debian mountpoint in the root of my NTFS, and replaced /etc/init.d/telnet on the NS-K330 with:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    #!/bin/sh
    #
    # Hacked to provide chroot ssh
    
    CHROOTDIR="/usb/sda1/debian"
    export CHROOTDIR
    
    KIND="CHROOT_SSH"
    ENABLE=$(sed -n "s/^\(telnet_enable\)=\(.*\)$/\2/p" /etc/default/config)
    
    start() {
        if [ $ENABLE -eq 1 ] ; then
            PID=$(pgrep -f "/usr/sbin/sshd")
            if [ ${PID:-empty} = "empty" ] ; then
                echo "Starting $KIND service..."
                if ! mount | fgrep -q $CHROOTDIR; then
                    mount -o loop /usb/sda1/debian.img $CHROOTDIR
                    mount -t proc proc $CHROOTDIR/proc
                    mount -t devpts devpts $CHROOTDIR/dev/pts
                    mount -o bind /usb/sda1 $CHROOTDIR/mnt/sda1 
                fi  
                chroot $CHROOTDIR /etc/init.d/ssh start
                # /usr/sbin/telnetd &
            fi
        fi
    }
    
    stop() {
        echo "Shutting down $KIND service..."
            if ! mount | fgrep -q $CHROOTDIR; then                    
                mount -o loop /usb/TERABYTE/debian.img $CHROOTDIR
                mount -t proc proc $CHROOTDIR/proc
            mount -t devpts devpts $CHROOTDIR/dev/pts       
            mount -o bind /usb/sda1 $CHROOTDIR/mnt/sda1
        fi                                                      
        chroot $CHROOTDIR /etc/init.d/ssh stop
        # pkill -f -9 "telnetd"
    }
    
    restart() {
        stop
        sleep 1
        start
    }
    
    webstatus(){
        PID=$(pgrep -f "/usr/sbin/sshd")
        if [ ${PID:-empty} = "empty" ] ; then
            echo -n "$KIND is not running"
        else
            echo -n "$KIND is running"
        fi          
    }
    
    case "$1" in
      start)
        start
        sleep 1
        ;;
      stop)
        stop
        ;;
      restart)
        restart
        ;;
      webstatus)
        webstatus
        ;;
      *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
    esac
    

    and saved the config.

    Seems to work like a charm. Again, some of this is a bit crude, but hey...

     
  • Anonymous

    Anonymous - 2010-07-29

    Originally posted by: rde...@gmail.com

    Can I install transmission on the chroot? I think that it may be easy this way. So would I need to download the source and compile it? Or can I just install an .deb package of transmission?

    I need this because the private tracker that I use, doesn't accept older versions than 1.93 and the default on Snake OS is 1.92

     
  • Anonymous

    Anonymous - 2010-08-05

    Originally posted by: mthandre...@gmail.com

    Can there be install surveillance software for IP Cam on the device? I need a program where you can config one or more ip cam, so the stream image / video will be saved.

     
  • Anonymous

    Anonymous - 2010-08-09

    Originally posted by: yk4...@gmail.com

    You can have an updated debian system if you already have a debian installation ( the old chrooted one, installed on your computer, VM etc . ) cd to the media where you want it and do :

    apt-get install cdebootstrap

    cdebootstrap -aarm lenny lenny ftp://ftp.us.debian.org/debian

    then mount dev, proc ... etc. I've done it and it run very stable.

    Btw for macs users, you can have netatalk and avahi installed within the debian chroot, and use your device as a afp server ( more stable and fast than samba on macs ) and as a unofficial time capsule( it should work, not tested ).

     
  • Anonymous

    Anonymous - 2010-08-25

    Originally posted by: kinh.d...@gmail.com

    Is it possible to run GeexBox? or some other upnp / dlna software with this?

     
  • Anonymous

    Anonymous - 2010-09-11

    Originally posted by: ferris.w...@gmail.com

    Hi,

    I'd like to be able to compile and install stuff myself, much like the questions above. This is all very exciting, but I don't know much about how to proceed in this environment, so I'd like to ask some questions:

    - I have successfully installed the chroot described above, I can use apt-get to get some apps, make them etc. I tried to compile a device driver (I suppose it means it will be compiled as a kernel module), but get this response:

    Updating/Creating .config Preparing to compile for kernel version 2.6.16 File not found: /lib/modules/2.6.16-gazineu/build/.config at ./scripts/make_kconfig.pl line 32, <IN> line 4. make1?: ** No rule to make target .myconfig', needed byconfig-compat.h'. Stop. **

    So I guess the .config file is required to compile a kernel module/device driver, right? How could I get it? I suppose this would not be the last obstacle in building a kernel module - would I need something else and how could I get it?

    - In general, am I supposed to compile, install AND run the apps in the chroot, or could I just use it as a compilation environment and maybe install and run the apps on the "regular environment"?

    - Related to the previous question: could I have a cross-compilation environment on a Linux PC, to compile apps to run on the SnakeOS host? How could this be achieved?

    I'm sorry there's a lot of questions, probably some stupid ones too. Any answers or pointers to educational material around these issues would be greatly appreciated!

     
  • Anonymous

    Anonymous - 2010-09-13

    Originally posted by: duncanb...@gmail.com

    @kinh.dinh: upnp/dlna - Once you have the chrooted debian, you can install mediatomb. It's a bit heavy though, and you may find that the slim resources offered by the nas box get exhausted pretty quick. I had it running successfully briefly, streaming to my LG PVR just fine, but it clogged everything else up, so I turned it back off. I'm sure there's a lighter option out there somewhere...

     
  • Anonymous

    Anonymous - 2010-09-16

    Originally posted by: wellum...@gmail.com

    Hi!

    Got the chroot working and ssh too. Now I'm trying to get this box working a squid-proxy, but I can't use iptables at all. I need to use it in my transparent proxy setup.

    I could also install it to the nas side, but that doesn't work either :(

    I have mounted lib/modules /usb/sda2/debian/lib/modules but still getting errors on chroot side.

    Any help you can give me?

    These are the errors on chroot-system

    nas:~# iptables -L FATAL: Module ip_tables not found. iptables v1.4.2: can't initialize iptables table `filter': iptables who? (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. nas:~# depmod -a FATAL: Could not open /lib/modules/2.6.16-gazineu/modules.dep.temp for writing: Read-only file system nas:~# insmod ip_tables insmod: can't read 'ip_tables': No such file or directory nas:~#

     
  • Anonymous

    Anonymous - 2010-10-08

    Originally posted by: pinguin...@gmail.com

    Hi all .

    Server wlx652.discoversweb.com to dead . New online after one month . Another one . Problems we have changed .

    Please it uses http://wlx652.com or http://wlx652.byethost24.com/index.php?topic=80.0

    To feel much this change . Thanks you by its understanding . To this we dedicated it space to all you . http://wlx652.com as new redirecting server .

    Bests regards . pinguino7 :)

     
  • Anonymous

    Anonymous - 2010-11-13

    Originally posted by: payte...@gmail.com

    Hi All, Just bought a NS-K330. Switched to Snake-OS 1.2.0-20100621-from-original which worked without any problems. Then used these instructions to chroot to debian. I keep getting the same error each time I tar -xvf debian.tgz. The message tar: can't open 'debian/usr/share/man/man3/Term::ReadKey?.3pm.gz': Invalid argument

    I have deleted the debian directory and re-downloaded debian.tgz twice now with no difference. Same exact error message.

    Any ideas?

    Best Regards

     
  • Anonymous

    Anonymous - 2010-12-24

    Originally posted by: taoloo...@gmail.com

    Hi

    i update my nas 652 with last version of snake os from original .

    All worked perfect before i change the http port from 80 to 110.

    After this i reboot my NAS, and never refresh the page.

    My NAS has a current ip 192.168.1.10 , responde as ping , but http page doesnt start, i can not acces via internet explorer. it can connect with putty but after connection i don't know what can i do. Please help me. Thanks a lot

     
  • Anonymous

    Anonymous - 2011-01-01

    Originally posted by: masharp...@gmail.com

    @taoloo897 This may seem basic but you are putting the new port number after the ip address into internet explorer? eg 192.168.1.10:110

     

    Last edit: Anonymous 2017-12-11
1 2 3 4 > >> (Page 1 of 4)

Log in to post a comment.

MongoDB Logo MongoDB