在运行 ubuntu touch 的 nexus 7 2013 上安装 linux-headers

在运行 ubuntu touch 的 nexus 7 2013 上安装 linux-headers

我最近在 nexus 7 2013 上安装了 ubuntu touch,在安装 Moxa Uport usb 适配器驱动程序时遇到了问题。实际上,驱动程序需要编译,这就是我需要安装 linux 标头的原因。我发现:

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

需要将某些内容写入 /lib/modules,并且此路径属于以只读方式挂载的 /dev/loop1。我可以将其重新挂载为 rw,但在尝试写入一次时,它又恢复为只读。

/etc/fstab 中没有关于 loop1 或 /lib/modules 的内容

命令:

mount | grep loop1

输出:

/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)

命令:

blockdev --report |grep loop1

输出:

ro   256   512  4096          0       126427136   /dev/loop1

然后:

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

输出:

rw   256   512  4096          0       126427136   /dev/loop1

命令:

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

输出:

/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)

奇怪,只有 /var/lib/lxc/android/rootfs/system 被设置为 rw

所以:

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

输出:

/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)

但:

mkdir /lib/modules/rrr

输出:

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

我认为以上是原因:

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

失败:

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)

所以,我被这个问题难住了,有人能帮助我吗?

问候,维克多

答案1

好吧,由于我对 ubuntu touch、android、linux、armhf 等东西不是很有经验,所以我无法正确直接地做到这一点。也许破解 boot.img 可能会有帮助,但我还没有准备好。

我能想到的唯一解决方法是将 /lib/modules/3.4.0-5-flo 安装到不同的新循环设备上。不过这可行。

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

从此,我能够安装 Linux 头文件并编译 Moxa 的驱动程序。顺便说一句,我发现驱动程序 makefile 也会写入 /lib/modules/3.4.0-5-flo。

因此,为了使挂载永久生效,并且无法更改 /etc/fstab,我必须将其添加到 rc.local:

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

我知道这是一个相当奇怪的解决方案,但对我来说很有效:)

相关内容