Search code examples
readonlynexus-7ubuntu-touch

Install linux-headers on nexus 7 2013 running ubuntu touch


I have installed ubuntu touch on my nexus 7 2013 recently, and have faced problem installing driver for Moxa Uport usb adapter. Actually the driver needs to be compilled and this is why I need linux headers to be installed. I have found, that:

apt-get install linux-headers-`uname -r`

needs to write something to /lib/modules and this path belongs to /dev/loop1 which is mounted as readonly. I'm able to remount it to rw, but on single attempt to write there, it falls back to readonly.

nothing about loop1 or /lib/modules in /etc/fstab

command:

mount | grep loop1

output:

/dev/loop1 on /android/system type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /etc/ubuntu-touch-session.d/android.conf type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /lib/udev/rules.d/70-android.rules type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /usr/share/powerd/device_configs/config-default.xml type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /lib/modules type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /var/lib/lxc/android/rootfs/system type ext4 (ro,relatime,data=ordered)

command:

blockdev --report |grep loop1

output:

ro   256   512  4096          0       126427136   /dev/loop1

then:

blockdev --setrw /dev/loop1
blockdev --report |grep loop1

output:

rw   256   512  4096          0       126427136   /dev/loop1

command:

mount -o remount,rw /dev/loop1
mount | grep loop1

output:

/dev/loop1 on /android/system type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /etc/ubuntu-touch-session.d/android.conf type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /lib/udev/rules.d/70-android.rules type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /usr/share/powerd/device_configs/config-default.xml type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /lib/modules type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /var/lib/lxc/android/rootfs/system type ext4 (rw,relatime,data=ordered)

strange, only /var/lib/lxc/android/rootfs/system was set to rw

so:

mount -o remount,rw /lib/modules
mount | grep loop1

output:

/dev/loop1 on /android/system type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /etc/ubuntu-touch-session.d/android.conf type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /lib/udev/rules.d/70-android.rules type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /usr/share/powerd/device_configs/config-default.xml type ext4 (ro,relatime,data=ordered)
/dev/loop1 on /lib/modules type ext4 (rw,relatime,data=ordered)
/dev/loop1 on /var/lib/lxc/android/rootfs/system type ext4 (rw,relatime,data=ordered)

but:

mkdir /lib/modules/rrr

output:

mkdir: cannot create directory Б─≤/lib/modules/rrrБ─≥: Read-only file system

dmesg:

[ 8280.681213] EXT4-fs (loop1): previous I/O error to superblock detected
[ 8280.681579] Buffer I/O error on device loop1, logical block 0
[ 8280.682006] lost page write due to I/O error on loop1
[ 8280.682037] EXT4-fs error (device loop1): ext4_journal_start_sb:328: Detected aborted journal
[ 8280.682891] EXT4-fs (loop1): Remounting filesystem read-only
[ 8280.683135] EXT4-fs (loop1): previous I/O error to superblock detected
[ 8280.683593] Buffer I/O error on device loop1, logical block 0

I think the abowe is the reason of:

apt-get install linux-headers-`uname -r`

fails with:

Unpacking linux-headers-3.4.0-5-flo (3.4.0-5.19~15.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/linux-headers-3.4.0-5-flo_3.4.0-5.19~15.04.1_armhf.deb (--unpack):
 error creating symbolic link `./lib/modules/3.4.0-5-flo/build': Read-only file system
Errors were encountered while processing:
 /var/cache/apt/archives/linux-headers-3.4.0-5-flo_3.4.0-5.19~15.04.1_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

So, I got stuck on this, could please anybody help me?

Regards, Victor


Solution

  • Well, being not very experienced in ubuntu touch, android, linux, armhf stuff, I wasn't able to do it right and straightforward way. Perhaps hacking boot.img could help but I'm not ready for this.

    The only workaround I was able to imagine is mounting /lib/modules/3.4.0-5-flo to different new loop device. It works though.

    cd /userdata
    dd bs=1M count=100 if=/dev/zero of=build.img
    losetup /dev/loop2 build.img
    mkfs -t ext3 -m 1 -v /dev/loop2
    mkdir /eee
    mount -t ext3 /dev/loop2 /eee
    cp -r /lib/modules/3.4.0-5-flo/. /eee
    umount /eee
    mount /dev/loop2 /lib/modules/3.4.0-5-flo
    rmdir /eee
    

    From this point I got able to install linux headers and compile Moxa's drivers. I have discovered that drivers makefile aslo writes to /lib/modules/3.4.0-5-flo by the way.

    So, to make mount permanent, and failed to change /etc/fstab I had to add to rc.local:

    losetup /dev/loop2 /userdata/build.img
    mount /dev/loop2 /lib/modules/3.4.0-5-flo
    modprobe mxu11x0
    

    I know it's rather wierd solution, but worked for me :)