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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

2,254 Views
wangvictor
Contributor III

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!

0 Kudos
1 Reply

1,495 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Victor,

You have to change it in host, then backup you memory.

Regards

0 Kudos