# Documentaion error in ramfs-rootfs-initramfs.txt states?

## dman777

I was learning the details of initramfs and had a question. http://www.mjmwired.net/kernel/Documentation/filesystems/ramfs-rootfs-initramfs.txt states "....overmount rootfs with the new root (cd /newmount; mount --move . /; chroot .). 

I looked up the man page on mount and it states:

"Since Linux 2.5.1 it is possible to atomically move a mounted tree to another place. The call is 

mount --move olddir newdir"

So with initramfs, isn't 'cd /newmount; mount --move . /'. wrong? To me it saids cd into the new mount root point dir.../newmount...move the tree of the current directory '.' to the new dir /. But the parent '.' is not the olddir(which should be the old rootfs parent of /newmount before rootfs is wiped) but the new directory since we cd /newmount before we issued the mount command. So, we're not moving the mounted rootfs tree but only moving the tree starting at /newmount(which is empty dir).

----------

## x22

This commands have to be executed after something (i.e. the real root fs) is already mounted on /newmount.

----------

## dman777

but /newmount hasn't been mounted yet and 'cd /newmount; mount --move . /' is the actual over mounting of rootfs, right?

----------

## salahx

IThe sequence of events goes something like this:

```

mkdir newroot

chdir newroot

mount /dev/newroot /newroot

find / -xdev -delete

mount --move /newroot /

chroot .

chdir /

```

----------

## Hu

As salahx says, at that point in the documentation file, /newroot is assumed to be a mount point representing the root of your regular filesystem.  The commands salahx shows are how it would be done if you had to do it by hand, but fortunately, switch_root can do it all for you.  In most initramfs scripts, once you have /dev/mapper/root created and pointed at your regular filesystem, mount -o ro /dev/mapper/root /newroot && cd /newroot && /bin/busybox switch_root /newroot /sbin/init should be sufficient.

----------

