0

I wanted to remove a symlink from /sbin/ directory. The link is swapon which is linked to busybox binary on the same directory.

While trying to remove first-time, it said "Read only filesystem". So, I remounted / with read-write using this command

mount -o remount,rw /

Then I was able to remove it. I checked with which swapon as well as using ls. All fine. Now, when I rebooted the phone, the link appeared in the same location magically!

Am I missing something? What's happening here? How do I remove this link?

Here is the output of mount in case it is required

~ # mount
rootfs on / type rootfs (ro,relatime)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
none on /acct type cgroup (rw,relatime,cpuacct)
none on /sys/fs/cgroup type tmpfs (rw,relatime,mode=750,gid=1000)
none on /sys/fs/cgroup/memory type cgroup (rw,relatime,memory)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,relatime,mode=755,gid=1000)
none on /dev/cpuctl type cgroup (rw,relatime,cpu)
tmpfs on /dev/shm type tmpfs (rw,relatime,mode=755,gid=1000)
/dev/block/mmcblk0p6 on /modemfs type ext4 (rw,nosuid,nodev,noatime,errors=panic,user_xattr,acl,barrier=1,nomblk_io_submit,data=ordered)
/dev/block/mmcblk0p10 on /system type ext4 (ro,relatime,errors=panic,user_xattr,acl,barrier=1,data=ordered)
/dev/block/mmcblk0p11 on /data type ext4 (rw,nosuid,nodev,noatime,errors=panic,user_xattr,acl,barrier=1,journal_async_commit,nomblk_io_submit,data=ordered,noauto_da_alloc)
/dev/block/mmcblk0p12 on /cache type ext4 (rw,nosuid,nodev,noatime,errors=panic,user_xattr,acl,barrier=1,nomblk_io_submit,data=ordered)
/dev/block/vold/179:97 on /mnt/media_rw/sdcard1 type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/fuse on /storage/sdcard1 type fuse (rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/block/vold/179:14 on /mnt/media_rw/sdcard0 type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:14 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/fuse on /storage/sdcard0 type fuse (rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/block/dm-0 on /mnt/asec/com.zodinplex.naturesound-1 type ext4 (ro,dirsync,nosuid,nodev,noatime,user_xattr,acl,barrier=1)
1
  • you can give Root Explorer/Total Commander a try.
    – user186920
    Commented Dec 10, 2016 at 13:14

1 Answer 1

2

Android devices have a unique way of booting, using a binary blob called boot.img that contains the kernel, and a ramdisk. This ramdisk will contain the /sbin symlink you want to remove.

To remove this, you will probably need either an upgrade image, or you will have to extract boot.img from your device. I can look for or put together instructions for this if you wish.

Once you have the extracted boot.img, you have to then extract the ramdisk image from it, make your changes, and put everything back together.

Then comes the dangerous part, unless you know you cannot brick your phone. You will need to flash this (hopefully working!) boot.img so that Android will use the new ramdisk.

So, for now, it might be better to figure out if there is an init script in the /system directory that you could remove your symlink in each time your phone starts.

Update: or, like you did, you could just change the init script that calls swapon to call a different one.

1
  • Thanks for bringing this. I wasn't aware of this. I might try changing these, but I solved the problem by explicitly calling another symlink /system/bin/swapon without relying on env's default swapon (which was in /sbin). I think, I'll try it later and inform you
    – Anwar
    Commented Dec 10, 2016 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .