So in my last post I had a server crash and mounted my raided disk to /mnt/
I made a backup of all data, but really need my mysql database with structure and datas.
I wanted to run sql and so I had to find a way how to run it from the mounted drive.
So here came into play the nice command chroot. On Unix-like operating systems is an operation that changes the apparent root directory for the current running process and its children. Basically, you change from your current running OS, to that of the mounted drive.
So how do we do this? Assuming you have your drive mounted simply use the following commands:
What is chroot?
Chroot is an operation that changes the apparent root directory for the current running process and their children. It creates a virtualized environment in a Unix and Unix-like operating systems, separating it from the main operating system and directory structure. A program that is run in such a modified environment cannot name (and therefore normally not access) files outside the designated directory tree. This confined virtual environment is often called a “chroot jail“. Only a privileged process and root user can use chroot command. Chroot has also been used by POSIX systems for their FTP servers, to isolate untrusted FTP clients.
When it is used?
A chroot environment can be used to create and host a separate virtualized copy of the software system. This can be useful for:
- Privilege separation for unprivileged process such as Web-server or DNS server.
- Setting up a test environment.
- Run old programs or ABI in-compatibility programs without crashing application or system.
- System recovery.
- Reinstall the bootloader such as Grub or Lilo.
- Password recovery – Reset a forgotten password and more.
published by Alberto J. Matus