AnsweredAssumed Answered

How to use pivot_root to change new root and umount old root?

Question asked by victor Wang on Jun 26, 2018
Latest reply on Jun 27, 2018 by Bio_TICFSL

Hi community,

 

Recently I had tried to change root with pivot_root.

 

But I cannot umount the old root.

 

After some googling I summarize following steps.

 

  1. mount  /dev/mmcblk3p2 /newroot
  2. cd /newroot
  3. unshare -m
  4. pivot_root . mnt
  5. exec chroot . sh -c "umount /old_root; exec /sbin/init" <dev/console >dev/console 2>&1

But I was stuck in the fifth steps, it will show there is no console under /dev.

 

When I "ll /dev" I get all this things like below.

total 16 
drwxr-xr-x 4 root root 4096 Jan 1 1970 ./ 
drwxr-xr-x 22 root root 4096 Jun 26 08:05 ../ 
lrwxrwxrwx 1 root root 11 Jan 1 1970 core -> /proc/kcore 
lrwxrwxrwx 1 root root 13 Jan 1 1970 fd -> /proc/self/fd/ 
lrwxrwxrwx 1 root root 8 Jan 1 1970 ptmx -> pts/ptmx 
drwxr-xr-x 2 root root 4096 Apr 21 2017 pts/ 
lrwxrwxrwx 1 root root 4 Jan 1 1970 ram -> ram1 
drwxr-xr-x 2 root root 4096 Apr 21 2017 shm/ 
lrwxrwxrwx 1 root root 4 Jan 1 1970 stderr -> fd/2 
lrwxrwxrwx 1 root root 4 Jan 1 1970 stdin -> fd/0 
lrwxrwxrwx 1 root root 4 Jan 1 1970 stdout -> fd/1

 

How to solve this question?

 

Or my steps are wrong or has any problem?

 

Thanks in Advanced!

Outcomes