# /dev question



## Alain De Vos (May 30, 2021)

How is /dev populated ?
Is this done by the kernel or a script.
Must I copy /dev to a newly install ?


----------



## mer (May 30, 2021)

/dev it typically populated by the kernel, basically when hardware is found and a device driver is loaded for it, one or more entries are created in /dev, devd is related (man devd).    /etc/devd has config files, /etc/devfs.conf and /etc/devd.conf are related, don't forget /usr/local/etc/devd for more config files.

No, you should not have to copy /dev to a new install.


----------



## fbsd_ (May 30, 2021)

/dev contains symbolic files to your hardwares. NO you dont need to copy them. They are being generated by kernel and removed by kernel. I dont think copying /dev files will affect anything on new system. Like copying /dev/da0a or /dev/mem to new system? Why to do something like that? Copying memory? maybe lol


----------



## George (May 30, 2021)

I think init() loads/starts/mounts a devfs(5) file system at boot. Then a call to make_dev_s(9), or its legacy version make_dev(9) creates a /dev entry. 



> Must I copy /dev to a newly install?


No. The devfs is not meant to survive a reboot.


----------



## mer (May 30, 2021)

make_dev stuff is usually called from within a device driver, devfs usually reacts to the creation of a device node and then applies rules.  The most common operation is on a device node from devfs or devd is change permissions or group ownership.

It's a maze of twisty passages, all alike but is much better than the original "mknod" and static devices you used to do.


----------



## Alain De Vos (May 31, 2021)

It's interesting to see the difference with linux,


			6.8. Populating /dev


----------



## SirDice (May 31, 2021)

That seems to be specific to Linux-from-scratch. A modern Linux version has a similar devfs(5) construction as we do and has done so for many years.


----------



## memreflect (May 31, 2021)

Alain De Vos said:


> It's interesting to see the difference with linux,
> 
> 
> 6.8. Populating /dev


Those lines are necessary to create a working chroot environment since the udev software isn't built prior to entering the chroot.  Otherwise you'll be missing all sorts of things in your /dev directory when you enter the chroot.  The `mount --bind` lines for Linux are similar to using mount_nullfs(8) on FreeBSD, so similar lines might also be used on FreeBSD if you're not using a jail for whatever reason.

Aside: The LFS 6.1 book you linked hasn't been updated in 15+ years.  Unless you have a need to rely on such an old version of the book, 10.1 and 10.1-systemd are the latest stable releases and should be preferred.


----------



## ralphbsz (May 31, 2021)

In the old days, /dev was just a directory, usually part of the root file system. The "files" in that directory were all device special files (which are a type of file system entry, as are real files, directories, soft links, and a few other bizarre things). And the system administrator had to manually create entries in there, using the `mknod` command. Which in turn required knowing the major/minor numbers for all possible devices. Obviously, this was tedious, error prone, and required expertise. It also has problems during installation on new hardware (what if the only physical console is connected via serial port /dev/ttyX0, but the root file system image was built for /dev/ttya0).

Fortunately, with automated device file systems, this is all a thing of the past.


----------



## Alain De Vos (May 31, 2021)

I see a more recent version of lfs lists eudev,sysfs and udevd.


----------



## covacat (May 31, 2021)

__





						System Administration
					





					docs.freebsd.org


----------

