pivot_root command examples

pivot_root command examples

pivot_root – change the root filesystem

Change the root file system to /dev/hda1 from an interactive shell:

mount /dev/hda1 /new-root
cd /new-root
pivot_root . old-root
exec chroot . sh dev/console 2>&1
umount /old-root

Mount the new root file system over NFS from 10.0.0.1:/my_root and run init:

ifconfig lo 127.0.0.1 up # for portmap
# configure Ethernet or such
portmap # for lockd (implicitly started by mount)
mount -o ro 10.0.0.1:/my_root /mnt
killall portmap # portmap keeps old root busy
cd /mnt
pivot_root . old_root
exec chroot . sh -c 'umount /old_root; exec /sbin/init' \
dev/console 2>&1

 

Leave a Reply

Your email address will not be published. Required fields are marked *