Linux, configuration
(→Compiling modules directly into kernel: link) |
|||
(9 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
==Loading Linux modules== | ==Loading Linux modules== | ||
===Quick method=== | ===Quick method=== | ||
− | First add to | + | First add to {{file|/etc/rc.conf}}, to enable Linux/ELF binary emulation: |
linux_enable="YES" | linux_enable="YES" | ||
− | Then either edit | + | Then either edit {{file|/boot/loader.conf}} to include: |
linprocfs_load="YES" | linprocfs_load="YES" | ||
linsysfs="YES" | linsysfs="YES" | ||
Line 11: | Line 11: | ||
To load the module without rebooting type: | To load the module without rebooting type: | ||
− | kldload linux | + | % kldload linux |
+ | See: [[kldload]], [[kldstat]], and [[kldunload]]. | ||
===Compiling modules directly into kernel=== | ===Compiling modules directly into kernel=== | ||
− | Alternatively, [[Kernels, Custom|compile directly into the kernel]] by adding these options to your custom | + | Alternatively, [[Kernels, Custom|compile directly into the kernel]] by adding these options to your custom ''{{file|KERNCONF}}'' file in {{file|/usr/src/sys/*/conf/}}: |
options COMPAT_LINUX32 # This is used for 64bit processors | options COMPAT_LINUX32 # This is used for 64bit processors | ||
#options COMPAT_LINUX # This is used for 32bit processors; this option won't work on 64bit processors | #options COMPAT_LINUX # This is used for 32bit processors; this option won't work on 64bit processors | ||
Line 20: | Line 21: | ||
options LINSYSFS | options LINSYSFS | ||
device lindev | device lindev | ||
− | If this is done, comment out linux related lines in both | + | If this is done, comment out linux related lines in both {{file|rc.conf}} or {{file|loader.conf}} as mentioned in the previous section. |
==Linux filesystems== | ==Linux filesystems== | ||
− | Linux filesystems then need to be mounted via adding the following to | + | Linux filesystems then need to be mounted via adding the following to {{file|/etc/fstab}}: |
linproc /compat/linux/proc linprocfs rw 0 0 | linproc /compat/linux/proc linprocfs rw 0 0 | ||
linsys /compat/linux/sys linsysfs rw 0 0 | linsys /compat/linux/sys linsysfs rw 0 0 | ||
− | The mount command may also be used by reflecting what normally goes into | + | The mount command may also be used by reflecting what normally goes into {{file|fstab}}. |
− | ==More | + | To mount ext2, reiserfs and xfs filesystems, some which can only be mounted as read only: |
+ | |||
+ | Kernel compilation options: | ||
+ | options REISERFS | ||
+ | options EXT2FS #provides limited support for ext3 and ext4 | ||
+ | options XFS | ||
+ | |||
+ | Quick load of module options: | ||
+ | % kldload ext2fs | ||
+ | % kldload reiserfs | ||
+ | |||
+ | Mount options which can also be translated into {{file|fstab}}: | ||
+ | % mount -t reiserfs /dev/ada* /mnt* | ||
+ | % mount -t ext2fs /dev/ada* /mnt* | ||
+ | % mount -t xfs /dev/ada* /mnt* | ||
+ | |||
+ | ==More configurations== | ||
Most of the below is according to messages after compiling ports, or is from the FreeBSD Handbook, these instructions may change over time: | Most of the below is according to messages after compiling ports, or is from the FreeBSD Handbook, these instructions may change over time: | ||
− | + | ===/etc/=== | |
+ | {{file|/etc/devfs.conf}}: | ||
link /tmp shm | link /tmp shm | ||
− | + | {{file|/etc/sysctl.conf}}: | |
compat.linux.osrelease=2.6.18 # This or a similar line is only required if the linux emulated kernel is incompatible or outdated | compat.linux.osrelease=2.6.18 # This or a similar line is only required if the linux emulated kernel is incompatible or outdated | ||
− | + | ===/compat/linux/etc/=== | |
+ | {{file|/compat/linux/etc/yp.conf}} | ||
domainname mydomain.com # this is your network's domain-name without localhost | domainname mydomain.com # this is your network's domain-name without localhost | ||
ypserver localhost # my.yp.server | ypserver localhost # my.yp.server | ||
− | + | {{file|/compat/linux/etc/nsswitch.conf}} | |
passwd: files nis | passwd: files nis | ||
shadow: files nis | shadow: files nis | ||
Line 47: | Line 66: | ||
hosts: files nis dns | hosts: files nis dns | ||
− | + | {{file|/compat/linux/etc/host.conf}} should look similar to, with an adjustment for your network settings: | |
order hosts, bind | order hosts, bind | ||
multi on | multi on | ||
− | If the sub-directories don't exist yet, use | + | If the sub-directories don't exist yet, use {{cmd|mkdir -p}}. |
==Emulated files== | ==Emulated files== | ||
− | Use the command | + | Use the command {{cmd|ldd}} to find libraries. |
− | brandelf is used to label programs as linux files. | + | {{cmd|brandelf}} is used to label programs as linux files. |
− | brandelf -t Linux myfile | + | % brandelf -t Linux myfile |
==Ports== | ==Ports== | ||
Line 66: | Line 85: | ||
==References== | ==References== | ||
* Related manpages; and filesystem documentation | * Related manpages; and filesystem documentation | ||
− | * [https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/linuxemu-lbc-install.html | + | * FreeBSD Handbook: [https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/linuxemu-lbc-install.html Linux® Binary Compatibility], and [https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/filesystems-linux.html Linux® File Systems] |
[[Category:Common Tasks]] | [[Category:Common Tasks]] | ||
[[Category:Linux Equivalents]] | [[Category:Linux Equivalents]] | ||
[[Category:Configuring FreeBSD]] | [[Category:Configuring FreeBSD]] |
Latest revision as of 07:10, 30 October 2015
Contents |
[edit] Loading Linux modules
[edit] Quick method
First add to /etc/rc.conf, to enable Linux/ELF binary emulation:
linux_enable="YES"
Then either edit /boot/loader.conf to include:
linprocfs_load="YES" linsysfs="YES" linux_load="YES" lindev_load="YES"
To load the module without rebooting type:
% kldload linux
See: kldload, kldstat, and kldunload.
[edit] Compiling modules directly into kernel
Alternatively, compile directly into the kernel by adding these options to your custom KERNCONF file in /usr/src/sys/*/conf/:
options COMPAT_LINUX32 # This is used for 64bit processors #options COMPAT_LINUX # This is used for 32bit processors; this option won't work on 64bit processors options LINPROCFS options LINSYSFS device lindev
If this is done, comment out linux related lines in both rc.conf or loader.conf as mentioned in the previous section.
[edit] Linux filesystems
Linux filesystems then need to be mounted via adding the following to /etc/fstab:
linproc /compat/linux/proc linprocfs rw 0 0 linsys /compat/linux/sys linsysfs rw 0 0
The mount command may also be used by reflecting what normally goes into fstab.
To mount ext2, reiserfs and xfs filesystems, some which can only be mounted as read only:
Kernel compilation options:
options REISERFS options EXT2FS #provides limited support for ext3 and ext4 options XFS
Quick load of module options:
% kldload ext2fs % kldload reiserfs
Mount options which can also be translated into fstab:
% mount -t reiserfs /dev/ada* /mnt* % mount -t ext2fs /dev/ada* /mnt* % mount -t xfs /dev/ada* /mnt*
[edit] More configurations
Most of the below is according to messages after compiling ports, or is from the FreeBSD Handbook, these instructions may change over time:
[edit] /etc/
/etc/devfs.conf:
link /tmp shm
/etc/sysctl.conf:
compat.linux.osrelease=2.6.18 # This or a similar line is only required if the linux emulated kernel is incompatible or outdated
[edit] /compat/linux/etc/
/compat/linux/etc/yp.conf
domainname mydomain.com # this is your network's domain-name without localhost ypserver localhost # my.yp.server
/compat/linux/etc/nsswitch.conf
passwd: files nis shadow: files nis group: files nis hosts: files nis dns
/compat/linux/etc/host.conf should look similar to, with an adjustment for your network settings:
order hosts, bind multi on
If the sub-directories don't exist yet, use mkdir -p.
[edit] Emulated files
Use the command ldd to find libraries. brandelf is used to label programs as linux files.
% brandelf -t Linux myfile
[edit] Ports
Installing Linux Centos is a recommended way of adding to Linux compatibility :
% make distclean % cd /usr/ports/emulators/linux_base-c6 % make install distclean
[edit] References
- Related manpages; and filesystem documentation
- FreeBSD Handbook: Linux® Binary Compatibility, and Linux® File Systems