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 and run init:

ifconfig lo up # for portmap
# configure Ethernet or such
portmap # for lockd (implicitly started by mount)
mount -o ro /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 *