[experimental] Debian running like a charm on Defy!!!

xdaid

Inactive Recognized Developer
Jul 12, 2009
514
648
0
Hi. Well, I've researched a lot to get to this. For now, I haven't used the mount commands (because there isn't support for loop devices, or at least, that I think; in my stock rom). Because of that, the files are in a folder in the Filesystem of android.
Nope, the problem here is not a lack of support for loop devices, the problem is the ext2 filesystem itself, which is not supported in our defy.

Check by yourself, type from terminal:
"cat /proc/filesystems"

So, what is the solution?

It's much easier than you can expect, when you build your debian.img file just make it a ext3 filesystem rather than an ext2 !

Then, in your bootdeb file remember you're going to mount ext3 instead of ext2, so the code looks something like:
"busybox mount -t ext3 -o noatime,nodiratime [your_loop_device] [your_dir]"

Another way would be: find an ext2.ko (linux kernel module) specifically compiled for defy's kernel and place "insmod ext2.ko" inside bootdeb.. but i was not be able to find such a module over the net (all those i tried failed).

Right now i have debian running, i made a debian.img (ext3) and got it mounted on /data/local/debian

Hope this can help

BTW i made a one-click apk installer for all those who want to skip the hard stuff :) i'll post it soon in a new thread
 

cocus

Senior Member
Feb 2, 2010
88
5
0
Rosario, Santa Fe, AR
Nope, the problem here is not a lack of support for loop devices, the problem is the ext2 filesystem itself, which is not supported in our defy.

Check by yourself, type from terminal:
"cat /proc/filesystems"

So, what is the solution?

It's much easier than you can expect, when you build your debian.img file just make it a ext3 filesystem rather than an ext2 !

Then, in your bootdeb file remember you're going to mount ext3 instead of ext2, so the code looks something like:
"busybox mount -t ext3 -o noatime,nodiratime [your_loop_device] [your_dir]"

Another way would be: find an ext2.ko (linux kernel module) specifically compiled for defy's kernel and place "insmod ext2.ko" inside bootdeb.. but i was not be able to find such a module over the net (all those i tried failed).

Right now i have debian running, i made a debian.img (ext3) and got it mounted on /data/local/debian

Hope this can help

BTW i made a one-click apk installer for all those who want to skip the hard stuff :) i'll post it soon in a new thread
Hey, yes, I know that the defy has the ext3 filesystem extension in the kernel, but always it gives me an error trying to mount ext3 images.

It would be great if you make the apk :). I can help you with the spanish translation, PM me if you want.
 

xdaid

Inactive Recognized Developer
Jul 12, 2009
514
648
0
Hey, yes, I know that the defy has the ext3 filesystem extension in the kernel, but always it gives me an error trying to mount ext3 images.

It would be great if you make the apk :). I can help you with the spanish translation, PM me if you want.
Below you can take a look to the whole code i used to get debian working

Code:
#----------------------------------------------------------------
#  From linux: build debian image
#----------------------------------------------------------------
dd if=/dev/zero of=debian.img seek=838860800 bs=1 count=1
mkfs.ext3 -F debian.img
mkdir debian
mount -o loop debian.img debian/
cp -r debian-bak/* debian
umount debian/
rm -r debian/
tar -cjf debian.img.bz2 bootdeb debian.img
#----------------------------------------------------------------
# From device: setup debian image (that is what installer does)
#----------------------------------------------------------------
busybox tar -xvf /sdcard/debian/debian.img.bz2 -C /sdcard/debian
mkdir data/local/debian
mount -o remount,rw -t yaffs2 /dev/block/mmcblk1p21 /system
cp /sdcard/debian/bootdeb /system/bin/bootdeb
chmod 755 /system/bin/bootdeb
ln /dev/block/loop5 /dev/loop5
mount -o remount,ro -t yaffs2 /dev/block/mmcblk1p21 /system
#----------------------------------------------------------------
# From device: launch debian (bootdeb file content)
#----------------------------------------------------------------
mount -o remount,rw -t yaffs2 /dev/block/mmcblk1p21 /system
echo "Setting up paths.."
export bin=/system/bin
export img=/mnt/sdcard/debian/debian.img
export mnt=/data/local/debian
export OLDPATH=$PATH
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
echo "Mounting Linux image.."
busybox mknod /dev/block/loop5 b 7 0
busybox losetup /dev/block/loop5 $img
busybox mount -t ext3 -o noatime,nodiratime /dev/block/loop5 $mnt
busybox mount -t devpts devpts $mnt/dev/pts
busybox mount -t proc proc $mnt/proc
busybox mount -t sysfs sysfs $mnt/sys
echo "Setting up network.."
busybox sysctl -w net.ipv4.ip_forward=1
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "Mounting sdcard.."
busybox mount --bind /mnt/sdcard/ $mnt/mnt/sdcard
echo "Launching debian.."
echo " "
echo "------------------------------"
echo "  Make sure to exit properly"
echo "  Type EXIT to close session"
echo "------------------------------"
echo " "
busybox chroot $mnt /bin/bash
echo " "
echo "Shutting down.."
busybox umount $mnt/mnt/sdcard
busybox sysctl -w net.ipv4.ip_forward=0
busybox umount $mnt/dev/pts
busybox umount $mnt/proc
busybox umount $mnt/sys
busybox umount $mnt
busybox losetup -d /dev/block/loop5
export PATH=$OLDPATH
mount -o remount,ro -t yaffs2 /dev/block/mmcblk1p21 /system
Note:
* debian-bak folder contains all the debian files
* the installer i made places debian.img in the folder /sdcard/debian
 

cocus

Senior Member
Feb 2, 2010
88
5
0
Rosario, Santa Fe, AR
Below you can take a look to the whole code i used to get debian working

Code:
#----------------------------------------------------------------
#  From linux: build debian image
#----------------------------------------------------------------
dd if=/dev/zero of=debian.img seek=838860800 bs=1 count=1
mkfs.ext3 -F debian.img
mkdir debian
mount -o loop debian.img debian/
cp -r debian-bak/* debian
umount debian/
rm -r debian/
tar -cjf debian.img.bz2 bootdeb debian.img
#----------------------------------------------------------------
# From device: setup debian image (that is what installer does)
#----------------------------------------------------------------
busybox tar -xvf /sdcard/debian/debian.img.bz2 -C /sdcard/debian
mkdir data/local/debian
mount -o remount,rw -t yaffs2 /dev/block/mmcblk1p21 /system
cp /sdcard/debian/bootdeb /system/bin/bootdeb
chmod 755 /system/bin/bootdeb
ln /dev/block/loop5 /dev/loop5
mount -o remount,ro -t yaffs2 /dev/block/mmcblk1p21 /system
#----------------------------------------------------------------
# From device: launch debian (bootdeb file content)
#----------------------------------------------------------------
mount -o remount,rw -t yaffs2 /dev/block/mmcblk1p21 /system
echo "Setting up paths.."
export bin=/system/bin
export img=/mnt/sdcard/debian/debian.img
export mnt=/data/local/debian
export OLDPATH=$PATH
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
echo "Mounting Linux image.."
busybox mknod /dev/block/loop5 b 7 0
busybox losetup /dev/block/loop5 $img
busybox mount -t ext3 -o noatime,nodiratime /dev/block/loop5 $mnt
busybox mount -t devpts devpts $mnt/dev/pts
busybox mount -t proc proc $mnt/proc
busybox mount -t sysfs sysfs $mnt/sys
echo "Setting up network.."
busybox sysctl -w net.ipv4.ip_forward=1
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "Mounting sdcard.."
busybox mount --bind /mnt/sdcard/ $mnt/mnt/sdcard
echo "Launching debian.."
echo " "
echo "------------------------------"
echo "  Make sure to exit properly"
echo "  Type EXIT to close session"
echo "------------------------------"
echo " "
busybox chroot $mnt /bin/bash
echo " "
echo "Shutting down.."
busybox umount $mnt/mnt/sdcard
busybox sysctl -w net.ipv4.ip_forward=0
busybox umount $mnt/dev/pts
busybox umount $mnt/proc
busybox umount $mnt/sys
busybox umount $mnt
busybox losetup -d /dev/block/loop5
export PATH=$OLDPATH
mount -o remount,ro -t yaffs2 /dev/block/mmcblk1p21 /system
Note:
* debian-bak folder contains all the debian files
* the installer i made places debian.img in the folder /sdcard/debian
First of all, I've followed all of your script step-by-step without any errors, except when I try to run it:

mknod: /dev/block/loop5: File exists
losetup: /dev/block/loop5: No such file or directory
mount: mounting /dev/block/loop5 on /data/local/debian failed: Invalid argument
mount: mounting devpts on /data/local/debian/dev/pts failed: No such file or directory
mount: mounting proc on /data/local/debian/proc failed: No such file or directory
mount: mounting sysfs on /data/local/debian/sys failed: No such file or directory
Setting up network..
net.ipv4.ip_forward = 1
/system/bin/bootdeb: line 19: /data/local/debian/etc/resolv.conf: No such file or directory
/system/bin/bootdeb: line 20: /data/local/debian/etc/resolv.conf: No such file or directory
/system/bin/bootdeb: line 21: /data/local/debian/etc/hosts: No such file or directory
Mounting sdcard..
mount: mounting /mnt/sdcard/ on /data/local/debian/mnt/sdcard failed: No such file or directory
Launching debian..

------------------------------
Make sure to exit properly
Type EXIT to close session
------------------------------

chroot: can't execute '/bin/bash': No such file or directory

Shutting down..
umount: can't umount /data/local/debian/mnt/sdcard: No such file or directory
net.ipv4.ip_forward = 0
umount: can't umount /data/local/debian/dev/pts: No such file or directory
umount: can't umount /data/local/debian/proc: No such file or directory
umount: can't umount /data/local/debian/sys: No such file or directory
umount: can't umount /data/local/debian: Invalid argument
losetup: /dev/block/loop5: No such device or address
 
Last edited:

xdaid

Inactive Recognized Developer
Jul 12, 2009
514
648
0
First of all, I've followed all of your script step-by-step without any errors, except when I try to run it:

mknod: /dev/block/loop5: File exists
losetup: /dev/block/loop5: No such file or directory
mount: mounting /dev/block/loop5 on /data/local/debian failed: Invalid argument
mount: mounting devpts on /data/local/debian/dev/pts failed: No such file or directory
mount: mounting proc on /data/local/debian/proc failed: No such file or directory
mount: mounting sysfs on /data/local/debian/sys failed: No such file or directory
Setting up network..
net.ipv4.ip_forward = 1
/system/bin/bootdeb: line 19: /data/local/debian/etc/resolv.conf: No such file or directory
/system/bin/bootdeb: line 20: /data/local/debian/etc/resolv.conf: No such file or directory
/system/bin/bootdeb: line 21: /data/local/debian/etc/hosts: No such file or directory
Mounting sdcard..
mount: mounting /mnt/sdcard/ on /data/local/debian/mnt/sdcard failed: No such file or directory
Launching debian..

------------------------------
Make sure to exit properly
Type EXIT to close session
------------------------------

chroot: can't execute '/bin/bash': No such file or directory

Shutting down..
umount: can't umount /data/local/debian/mnt/sdcard: No such file or directory
net.ipv4.ip_forward = 0
umount: can't umount /data/local/debian/dev/pts: No such file or directory
umount: can't umount /data/local/debian/proc: No such file or directory
umount: can't umount /data/local/debian/sys: No such file or directory
umount: can't umount /data/local/debian: Invalid argument
losetup: /dev/block/loop5: No such device or address
- mknod: /dev/block/loop5: File exists

this is nothing wrong, mknod is there just in case there's no loop5 in /dev/block/

losetup: /dev/block/loop5: No such file or directory

this is the error, but just to be sure,
did you checked if the file debian.img was exactly in the folder
/sdcard/debian/ ?

losetup was looking for
/sdcard/debian/debian.img
and note, the output
"/dev/block/loop5: No such file or directory"
is the same even if the device (loop5) or the img file was not found.

Otherwise, this is a pretty weird error, try to insert
"ln /dev/block/loop5 /dev/loop5"
at the top of bootdeb

let me know
 

cocus

Senior Member
Feb 2, 2010
88
5
0
Rosario, Santa Fe, AR
- mknod: /dev/block/loop5: File exists

this is nothing wrong, mknod is there just in case there's no loop5 in /dev/block/

losetup: /dev/block/loop5: No such file or directory

this is the error, but just to be sure,
did you checked if the file debian.img was exactly in the folder
/sdcard/debian/ ?

losetup was looking for
/sdcard/debian/debian.img
and note, the output
"/dev/block/loop5: No such file or directory"
is the same even if the device (loop5) or the img file was not found.
Code:
[18:43 localhost] <21 /sdcard/debian/> ls
bootdeb
debian.img
Otherwise, this is a pretty weird error, try to insert
"ln /dev/block/loop5 /dev/loop5"
at the top of bootdeb

let me know
Code:
ln /dev/block/loop5 /dev/loop5
link failed File exists
Those are the weird errors that Im getting, even with all the stuff in place.
 

xdaid

Inactive Recognized Developer
Jul 12, 2009
514
648
0
well, just another attempt, let's try in another way

from bootdeb cut these lines:

busybox mknod /dev/block/loop5 b 7 0
busybox losetup /dev/block/loop5 $img
busybox mount -t ext3 -o noatime,nodiratime /dev/block/loop5 $mnt

and replace with:

busybox mount -t ext3 -o loop /sdcard/debian/debian.img /data/local/debian


(just in case you didn't try it yet)
 

cocus

Senior Member
Feb 2, 2010
88
5
0
Rosario, Santa Fe, AR
well, just another attempt, let's try in another way

from bootdeb cut these lines:

busybox mknod /dev/block/loop5 b 7 0
busybox losetup /dev/block/loop5 $img
busybox mount -t ext3 -o noatime,nodiratime /dev/block/loop5 $mnt

and replace with:

busybox mount -t ext3 -o loop /sdcard/debian/debian.img /data/local/debian


(just in case you didn't try it yet)
Now it worked. But, just in case, I have to keep the line
Code:
busybox mknod /dev/block/loop5 b 7 0
to create the loop if it didnt exists?
 

xdaid

Inactive Recognized Developer
Jul 12, 2009
514
648
0
Now it worked. But, just in case, I have to keep the line
Code:
busybox mknod /dev/block/loop5 b 7 0
to create the loop if it didnt exists?
Actually doing in this way you don't choose which loop device will be selected (or at least, i think so) but let the system do it for you. So, i think you can skip that line.
 

xdaid

Inactive Recognized Developer
Jul 12, 2009
514
648
0
Hey wait, look at this line in the bootdeb file:

export img=/mnt/sdcard/debian/debian.img

replace with:

export img=/sdcard/debian/debian.img

then i think you can keep the bootdeb file i posted as is (except for that line).

Probably, the path in which the sdcard is mounted could change from a rom release to another.
 
Last edited: