# Installing FreeBSD on a disk from a running Live system



## Sabbasth (Feb 3, 2011)

Hi,

I have a box running a Live (bit customed) mfsBSD (the filesystem is in memory), and I connect to it through ssh.
I wish to install a standard FreeBSD on the disk.

- Fdisk did the partitioning w/o problem (through sysinstall).
- DiskLabel can't create the labels on the running system as they are yet assigned to the running system.

I understand the problem, but don't know how to write labels in another place, and where.
I must admit that I'm a bit lost in the handbook to search and find the answer to this problem.

Any advice, explanations, or directions to the documentation are welcome.

Thx,
Bastien Semene


----------



## wblock@ (Feb 3, 2011)

Disk Setup On FreeBSD shows how to do this with fdisk(8) and bsdlabel(8) (or gpart(8)).  Avoid sysinstall from a running system, particularly for setting up disks, because it will happily overwrite your /etc/fstab.


----------



## Sabbasth (Feb 3, 2011)

Thx, there is exactly what I want.


----------



## Sabbasth (Feb 4, 2011)

Hi,

I set up the base system on the disk.

After the disk was correctly set up, I launched sysinstall and modified the configuration to change the root dir to /mnt (where I mounted /, /var, /usr and so on).
The installation of the base system seems correct, except that configuration was made on the running system as I thought.

So I did the following things :
- create a correct rc.conf file with the hostname, defaultrouter, ifconfig, sshd enabled.
- copy the resolv.conf file
- create a correct fstab file
- change the root passwd with "*pw -V /mnt/etc*"
- adding users with "*pw -V*"
- modified sshd_config file

I read the Post-installation and boot stages chapters in the handbook and everything seems set up correctly.
Am I missing something ?


----------



## Sabbasth (Feb 4, 2011)

Sorry for the double post but I can't edit.

The goal of the whole thing is to setup a ready to boot disk, so a non-admin person will can change the BIOS launch order to HDD first, and I will can access to the fresh installed system without him to do anything else.


----------



## wblock@ (Feb 4, 2011)

Sorry, I don't understand.  What is the problem?


----------



## Sabbasth (Feb 4, 2011)

My question is to know if I missed something that forbid for the system to boot properly.

Currently the system is booted on a mfsBSD (LiveCD).


----------



## wblock@ (Feb 4, 2011)

It's not clear whether you are having a problem, or just asking for confirmation.

Something that is often a problem is disk device numbering.  The boot drive is not always ad0.  You can label the filesystems and use those labels in /etc/fstab to avoid the disk numbers entirely.  Moving A FreeBSD System To AHCI And Labeled Filesystems describes that, just don't load achi unless all of the systems you use support it.


----------



## Sabbasth (Feb 4, 2011)

Yes I'm asking for confirmation.
It is the first time I'm trying to do such a thing, and I can't make errors often, as the person on-site is not an admin and I can't ask him much.

I'll take a look at the doc.

Thank you


----------



## wblock@ (Feb 4, 2011)

Testing on a variety of systems is a good way to start.  emulators/virtualbox-ose is one way to test, but actual hardware is better.

Oh, another thing that is frequently different between systems is the network card.  You can have multiple ifconfig statements in /etc/rc.conf to cover that:

```
ifconfig_bge0="SYNCDHCP"
ifconfig_em0="SYNCDHCP"
ifconfig_fxp0="SYNCDHCP"
ifconfig_xl0="SYNCDHCP"
```
Whichever of those four cards is present will be used.  Make sure to include all the possible cards that might be used.  This could be scripted with ifconfig(8), too.


----------



## Christopher (Feb 8, 2011)

wblock said:
			
		

> Oh, another thing that is frequently different between systems is the network card.  You can have multiple ifconfig statements in /etc/rc.conf to cover that:
> 
> ```
> ifconfig_bge0="SYNCDHCP"
> ...



Not to threadjack, but you might fight this useful.  You can also just put:


```
ifconfig_DEFAULT="SYNCDHCP"
```

In rc.conf, and that will run dhcp on all interfaces that have a link. See rc.conf(5) for the details.


----------



## Sabbasth (Feb 8, 2011)

Ok it works, thank you !

For people who are searching how to do this, here is my procedure (there probably are shortcuts are missed) :


boot on a live system (I did it with mfsBSD)
make slices/partitions on the disk (I had problems with fdisk command line utility, so I used sysinstall to do this)
mount every partition correctly on /mnt
install base system through sysinstall. Don't forget to change the root to /mnt in the options.
mount your var & usr disk partitions to /usr & /var on the memory fs root filesystem (i.e. : mount /dev/mfid0s1d /var)
compile new world/kernel with DESTDIR=/mnt (necessary with the mount change ? I didn't take time to test)
configure your system,
create a correct rc.conf file with the :
hostname
defaultrouter
ifconfig
sshd enabled
configure/create : resolv.conf, fstab, root passwd & users creation (pw -V /mnt/etc ...), sshd_config file.
reboot

You know have a fresh GENERIC system. I did it with 8.1-RELEASE.
Don't forget to watch the previously linked web pages if you have problems, this is how I managed to do it.

Thank you wblock for your time and christopher for the tip !


----------

