0

Linux embedded file system run entirely on raw NAND flash, use Full Image's RootFS. Linux v. 2.6.26.5, U-boot 2009.03 bootloader. After the Kernel is fully loaded, when I try to submit command, the device show the console login prompt. So I need reset a root password on device. I tried do this with U-boot by adding single and init=/bin/sh arguments at the end of kernel boot parameters:

setenv bootargs ${bootargs} single init=/bin/sh

Then I've been dropped into the Busybox shell command line with root privileges, from here I tried to run passwd command to reset the root password.

BusyBox v1.10.2 (2015-09-06 10:58:05 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/bin/sh: can't access tty; job control turned off
# help

Built-in commands:
-------------------
    . : [ [[ alias bg break cd chdir continue echo eval exec exit
    export false fg hash help jobs let local pwd read readonly return
    set shift source test times trap true type ulimit umask unalias
    unset wait

# passwd
passwd: unknown uid 0
# cd etc
# cat passwd
cat: can't open 'passwd': No such file or directory
# ls -l
...
lrwxrwxrwx    1 1014     1014           11 Oct 26  2015 passwd -> /tmp/passwd

How to reset the root password?

Edit: from log

# df
Filesystem           1k-blocks      Used Available Use% Mounted on
df: /proc/mounts: No such file or directory


# cd dev
# ls -l
crw-r--r--    1 0        0          5,   1 Jan  1 00:05 console
crw-r--r--    1 0        0          2,   0 Oct 26  2015 nfs
1

You're in a busybox emergency shell and your actual root partition is obviously not mounted yet.

You can list the available devices via ls /dev and mount your respecive root partition via mount /dev/<root_device> /<mount_point>.

After that you can edit the passwd under the respective mount point.

  • In my case rootfs is squashfs which is read-only file system, so password can not be in root partition. – triwo Dec 17 '17 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.