# What to do after changing the root directory (chroot).



## valsorym (Nov 14, 2011)

Hi all,

Using a USB Flash device installation, I mark the my HDD.
For example, I have identified one large slice.

```
/dev/gpt/f9boot    freebsd-boot
/dev/gpt/f9swap    freebsd-swap
/dev/gpt/f9root    freebsd-ufs
```

Now, I format and I connect the root partition.

```
# newfs -j /dev/gpt/f9root
# mkdir -p /mnt/f9
# mount /dev/gpt/f9root /mnt/f9
```

Now I install the OS.

```
# cd /usr/freebsd-dist/
# cat base.txz | tar --unlink -xpJf - -C /mnt/f9/
# cat kernel.txz | tar --unlink -xpJf - -C /mnt/f9/
```

Create /mnt/f9/etc/fstab.
Now, if I will restart my computer, my OS will  work!

But I do not want to restart the computer. I want to continue to settings my Os.

In Linux Gentoo I've done this:

```
# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
```

Now I'm trying to do with FreeBSD.

```
# chroot /mnt/f9 /bin/sh
```

I check the result.

```
# vi /etc/fstab
```
- yes opened my fstab that I wrote earlier how /mnt/f9/etc/fstab. The root directory changed successfully!

In Gentoo, we update the environment variables, and began to work with the new root directory.

```
# env-update
```

I'm trying to do this:

```
# rehash
rehash: not found
```

This means that I have not started the new OS. How to fix it?
How to continue to work without restarting my computer? Is it possible?


----------



## valsorym (Nov 14, 2011)

In principle,  I can work and so (though limited, although it is said in the textbooks: "chroot(8) allows you to run applications in a limited environment").
I recommend another plug /dev slice,

```
# mount -t devfs /dev /mnt/f9/dev
# chroot /mnt/f9 /bin/sh
```

- After, I spend my internet settings and install programs (now successfully setting the Internet, but the program has not yet set. I should first install the ports collection).

In this matter I have considered: env, printenv, set, setenv. But analog Gentoo env-update and have not found.


----------



## wblock@ (Nov 14, 2011)

doorways said:
			
		

> ```
> # chroot /mnt/f9 /bin/sh
> ```
> 
> ...



rehash is for csh(1), but you ran sh(1).



> This means that I have not started the new OS.



chroot(8) does not start the new OS, it merely changes how the currently running OS sees directories.


----------



## valsorym (Nov 14, 2011)

Oh, thank you. I realized what my mistake. Thank you!


----------



## valsorym (Nov 14, 2011)

wblock @, I'm sorry that is not on the subject. I see that you have written under the nick-name "FreeBSD Developer" - perhaps you can help me with this topic.


----------



## wblock@ (Nov 14, 2011)

Sorry, I have no experience with "software design" software.


----------



## valsorym (Nov 14, 2011)

Okay, thank you!


----------



## nORKy (Nov 24, 2011)

doorways said:
			
		

> ```
> # mount -t devfs /dev /mnt/f9/dev
> # chroot /mnt/f9 /bin/sh
> ```



And I think /bin/tcsh is more easy as an interactive shell than sh.
Sh I good for scripting.


----------



## valsorym (Nov 25, 2011)

Yes, I know - now I use /bin/csh.


----------

