ProHoster > Blog > Tsamaiso > Mokhoa oa ho qala ho sebelisa Mokhoa oa Mosebelisi ho Linux
Mokhoa oa ho qala ho sebelisa Mokhoa oa Mosebelisi ho Linux
Selelekela ho tsoa ho mofetoleli: Khahlanong le semelo sa ho kena ka bongata maphelong a rona a mefuta e fapaneng ea lijana, e ka ba ntho e khahlisang haholo ho tseba hore na e qalile ka mahlale afe hang. Tse ling tsa tsona li ka sebelisoa hantle ho fihlela kajeno, empa hase bohle ba hopolang mekhoa e joalo (kapa ba tseba hore ha baa ka ba tšoaroa nakong ea tsoelo-pele ea bona e potlakileng). E 'ngoe ea thekenoloji e joalo ke User Mode Linux. Mongoli oa pele o ile a cheka haholo, a fumana hore na ke life tsa khale tse ntseng li sebetsa le tse sa sebetseng, mme a kopanya ntho e kang taelo ea mohato ka mohato ea ho iphumanela UML ea lapeng ka 2k19. E, re memile mongoli oa poso ea mantlha ho Habr Cadey, kahoo haeba u na le lipotso - botsa ka Senyesemane ho litlhaloso.
Mokhoa oa mosebelisi ho Linux, ha e le hantle, ke kou ea kernel ea Linux ho eona. Mokhoa ona o u lumella ho tsamaisa kernel e felletseng ea Linux joalo ka ts'ebetso ea mosebelisi mme hangata e sebelisoa ke bahlahisi ho leka bakhanni. Empa mokhoa ona o boetse o na le thuso e le sesebelisoa sa ho itšehla thajana ka kakaretso, molao-motheo oa oona o ts'oanang le ts'ebetso ea mechine ea sebele. Mokhoa ona o fana ka ho itšehla thajana ho feta Docker, empa ka tlase ho mochini o felletseng o felletseng joalo ka KVM kapa Virtual Box.
Ka kakaretso, Mokhoa oa Mosebelisi o ka bonahala e le sesebelisoa se makatsang le se thata ho se sebelisa, empa se ntse se na le ts'ebeliso ea sona. Ntle le moo, ena ke kernel e felletseng ea Linux e tsoang ho mosebelisi ea se nang tokelo. Karolo ena e lumella khoutu e sa tšepahaleng ho sebetsa ntle le tšokelo ho mochini o amohelang. 'Me kaha ena ke kernel e feletseng, lits'ebetso tsa eona li arohane le mochine o amohelang, ke hore lits'ebetso tse sebetsang ka har'a Mokhoa oa Mosebelisi li ke ke tsa bonahala ho moamoheli. Sena ha se tšoane le sejana se tloaelehileng sa Docker, moo mochini o amohelang o lulang o bona lits'ebetso kahare ho polokelo. Sheba sengoathoana sena sa pstree ho tsoa ho e 'ngoe ea li-server tsa ka:
'Me u bapise sena le pstree ea kernel ea Linux ho Mokhoa oa Mosebelisi:
linux─┬─5*[linux]
└─slirp
Ha ke sebetsa le lijana tsa Docker, ke bona ho tsoa ho moamoheli mabitso a lits'ebetso tse ntseng li sebetsa ho moeti. Sena ha se khonehe ka Linux User Mode. E bolelang? Sena se bolela hore lisebelisoa tsa ho beha leihlo li sebetsa ka har'a sistimi ea tlhahlobo ea Linux ha ke bone mekhoa e sebetsang tsamaisong ea baeti. Empa maemong a mang, tšobotsi ena e ka fetoha sabole e sehang ka nģa tse peli.
Ka kakaretso, poso eohle e ka tlase ke pokello ea lipatlisiso le boiteko bo matla ba ho fumana sephetho se lakatsehang. Ho etsa sena, ke ne ke tlameha ho sebelisa lisebelisoa tse fapaneng tsa khale, ho bala mehloli ea kernel, ho kenella ka mokhoa o matla oa ho lokisa khoutu e ngotsoeng ha ke ntse ke le sekolong sa mathomo, hape ke tinker le Heroku e haha ka ho sebelisa binary e khethehileng ho batla lisebelisoa tseo ke neng ke li hloka. Mosebetsi ona kaofela o ile oa etsa hore bahlankana ba IRC ea ka ba mpitse moloi. Ke tšepa hore poso ena e tla sebetsa e le litokomane tse ka tšeptjoang hore motho a etse ntho e tšoanang, empa ka li-kernel tse ncha le mefuta ea OS.
phetoho
Ho theha Mokhoa oa Mosebelisi oa Linux ho etsoa ka mehato e mengata:
ho kenya litšepe ho moamoheli;
ho jarolla kernel ea Linux;
tlhophiso ea kernel build;
kopano ea kernel;
ho kenya binary;
ho hlophisa sistimi ea faele ea moeti;
khetho ea liparamente tsa ho qala kernel;
ho theha marang-rang a baeti;
ho qala thollo ea moeti.
Ke nahana hore haeba u etsa qeto ea ho e etsa u le mong, u tla khona ho etsa ntho e 'ngoe le e' ngoe e hlalositsoeng ho Ubuntu kapa Debian-like system. Ke lekile ho kenya ts'ebetsong tsohle tse ka holimo kabong eo ke e ratang ka ho fetesisa - Alpine, empa ha ho letho le ileng la hlaha, ho bonahala ka lebaka la hore Linux kernel e na le li-glibc-isms tse tlamang ka thata bakeng sa bakhanni ba Mosebelisi. Ke rerile ho tlaleha sena ho ea holimo ka mor'a hore ke utloisise bothata.
Ho kenya litšepeho ho moamoheli
Botho bo hloka bonyane liphutheloana tse latelang ho haha Linux kernel (ho nka ho kenya e hloekileng):
Hlokomela hore ho tsamaisa lenaneo la ho seta menu ea Linux kernel ho tla hloka ho kenya libncurses-dev. Ka kopo etsa bonnete ba hore e kentsoe ka taelo e latelang (joalo ka motso kapa ka sudo):
apt-get -y install libncurses-dev
Kernel download
Etsa qeto ea hore na u ka khoasolla hokae ebe u haha kernel. Bakeng sa ts'ebetso ena, o tla hloka ho fana ka hoo e ka bang 1,3 GB ea sebaka sa hard disk, kahoo etsa bonnete ba hore u na le sona.
Joale re kenya bukana e entsoeng ha re notlolla tarball:
cd linux-5.1.16
Ho theha sebopeho sa kernel
Sistimi ea ho aha kernel ke sete Makefiles с tse ngata lisebelisoa tse tloahelehileng le mengolo ho iketsetsa ts'ebetso. Ntlha ea pele, bula lenaneo la ho seta le sebetsanang:
make ARCH=um menuconfig
E tla u hahela ka mokhoa o itseng le ho u bontša lebokose la puisano. Neng '[Select]', o tla khona ho hlophisa o sebelisa linotlolo tsa Space kapa Enter. Tsamaea ka fensetere, joalo ka tloaelo, ka metsu ea keyboard "holimo" le "down", 'me u khethe likarolo - "ka ho le letšehali" kapa "ka ho le letona".
Sesupo sa pono —> se bolela hore o ho menu e nyane, e fihlellehang ka konopo ea Enter. Ho hlakile hore tsela ea ho tsoa ho eona ke ka '[Exit]'.
Kenyelletsa likhetho tse latelang ho '[Select]' 'me u netefatse hore ho na le letšoao la '[*]' haufi le bona:
UML-specific Options:
- Host filesystem
Networking support (enable this to get the submenu to show up):
- Networking options:
- TCP/IP Networking
UML Network devices:
- Virtual network device
- SLiRP transport
Ke eona, o ka tsoa fensetereng ena ka ho khetha ka tatellano '[Exit]'. Etsa bonnete ba hore u susumelletseha ho boloka tlhophiso qetellong ebe u khetha '[Yes]'.
Ke khothaletsa hore o bapale hohle ka likhetho tsa kernel build kamora ho bala poso ena. Ka liteko tsena, u ka ithuta ho hongata mabapi le ho utloisisa mosebetsi oa kernel mechanics ea boemo bo tlase le phello ea lifolakha tse fapaneng kopanong ea eona.
Ho haha koro
Linux kernel ke lenaneo le leholo le etsang lintho tse ngata. Leha o na le tlhophiso e nyane joalo ea lisebelisoa tsa khale, ho ka nka nako e telele ho aha. Kahoo haha kernel ka taelo e latelang:
make ARCH=um -j$(nproc)
Molelmong oa eng? Taelo ena e tla bolella sehahi sa rona ho sebelisa li-cores tsohle tse teng tsa CPU le likhoele ts'ebetsong ea kaho. Sehlopha $(nproc) qetellong ea Build substitutes tlhahiso ea taelo nproc, e leng karolo coreutils ka sebopeho se tloaelehileng sa Ubuntu.
Kamora nako e itseng, kernel ea rona e tla bokelloa hore e be faele e sebetsang ./linux.
Ho kenya binary
Kaha Mokhoa oa Mosebelisi ho Linux o theha binary e tloaelehileng, o ka e kenya joalo ka lisebelisoa tse ling. Mona ke kamoo ke e entseng:
mkdir -p ~/bin
cp linux ~/bin/linux
Hape ke habohlokoa ho etsa bonnete ba hore ~/bin e ho hao $PATH:
export PATH=$PATH:$HOME/bin
Ho theha sistimi ea faele ea moeti
Theha lethathamo bakeng sa sistimi ea faele ea moeti:
mkdir -p $HOME/prefix/uml-demo
cd $HOME/prefix
Bula alpinelinux.org le ho kena download karolo fumana sehokelo sa 'nete sa ho jarolla MINI ROOT FILESYSTEM. Nakong ea ho ngola sena e ne e le:
Joale kenya bukana ea sistimi ea faele ea moeti 'me u ntše li-archive:
cd uml-demo
tar xf ../alpine-rootfs.tgz
Liketso tse hlalositsoeng li tla etsa template e nyenyane ea tsamaiso ea lifaele. Ka lebaka la sebopeho sa sistimi, ho tla ba thata haholo ho kenya liphutheloana ka mookameli oa apk oa Alpine. Empa FS ena e tla lekana ho lekola mohopolo o akaretsang.
Re boetse re hloka sesebelisoa e nyane ho thibela tshebediso ya mohopolo mekhoa ea zombie kernel ea rona ea moeti.
wget -O tini https://github.com/krallin/tini/releases/download/v0.18.0/tini-static
chmod +x tini
Ho theha Kernel Command Line
Linux kernel, joalo ka mananeo a mang a mangata, e na le likhang tsa mola oa taelo tse ka fihlellehang ka ho hlakisa senotlolo --help.
Ka boeena—thuso
linux --help
User Mode Linux v5.1.16
available at http://user-mode-linux.sourceforge.net/
--showconfig
Prints the config file that this UML binary was generated from.
iomem=<name>,<file>
Configure <file> as an IO memory region named <name>.
mem=<Amount of desired ram>
This controls how much "physical" memory the kernel allocates
for the system. The size is specified as a number followed by
one of 'k', 'K', 'm', 'M', which have the obvious meanings.
This is not related to the amount of memory in the host. It can
be more, and the excess, if it's ever used, will just be swapped out.
Example: mem=64M
--help
Prints this message.
debug
this flag is not needed to run gdb on UML in skas mode
root=<file containing the root fs>
This is actually used by the generic kernel in exactly the same
way as in any other kernel. If you configure a number of block
devices and want to boot off something other than ubd0, you
would use something like:
root=/dev/ubd5
--version
Prints the version number of the kernel.
umid=<name>
This is used to assign a unique identity to this UML machine and
is used for naming the pid file and management console socket.
con[0-9]*=<channel description>
Attach a console or serial line to a host channel. See
http://user-mode-linux.sourceforge.net/old/input.html for a complete
description of this switch.
eth[0-9]+=<transport>,<options>
Configure a network device.
aio=2.4
This is used to force UML to use 2.4-style AIO even when 2.6 AIO is
available. 2.4 AIO is a single thread that handles one request at a
time, synchronously. 2.6 AIO is a thread which uses the 2.6 AIO
interface to handle an arbitrary number of pending requests. 2.6 AIO
is not available in tt mode, on 2.4 hosts, or when UML is built with
/usr/include/linux/aio_abi.h not available. Many distributions don't
include aio_abi.h, so you will need to copy it from a kernel tree to
your /usr/include/linux in order to build an AIO-capable UML
nosysemu
Turns off syscall emulation patch for ptrace (SYSEMU).
SYSEMU is a performance-patch introduced by Laurent Vivier. It changes
behaviour of ptrace() and helps reduce host context switch rates.
To make it work, you need a kernel patch for your host, too.
See http://perso.wanadoo.fr/laurent.vivier/UML/ for further
information.
uml_dir=<directory>
The location to place the pid and umid files.
quiet
Turns off information messages during boot.
hostfs=<root dir>,<flags>,...
This is used to set hostfs parameters. The root directory argument
is used to confine all hostfs mounts to within the specified directory
tree on the host. If this isn't specified, then a user inside UML can
mount anything on the host that's accessible to the user that's running
it.
The only flag currently supported is 'append', which specifies that all
files opened by hostfs will be opened in append mode.
Phanele ena e totobatsa lintlha tse kholo tsa ho qala. Ha re tsamaise kernel ka likhetho tse fokolang tse hlokahalang:
linux
root=/dev/root
rootfstype=hostfs
rootflags=$HOME/prefix/uml-demo
rw
mem=64M
init=/bin/sh
Mela e ka holimo e bolella kernel ea rona tse latelang:
Nka hore metso ea lifaele ke sesebelisoa sa pseudo /dev/root.
Khetha hostfs joalo ka mokhanni oa tsamaiso ea metso.
Kenya sistimi ea baeti eo re e entseng sesebelisoa sa motso.
'Me e, ka mokhoa oa ho bala-ngola.
Sebelisa feela 64 MB ea RAM (o ka sebelisa e fokolang haholo ho latela seo u rerileng ho se etsa, empa 64 MB e bonahala e le chelete e lekaneng).
Kernel e qala ka bo eona /bin/sh kamoo init- mokhoa.
Matha taelo ena 'me u lokela ho fumana ntho e kang e latelang:
Letlapa le leng hape
Core dump limits :
soft - 0
hard - NONE
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking environment variables for a tempdir...none found
Checking if /dev/shm is on tmpfs...OK
Checking PROT_EXEC mmap in /dev/shm...OK
Adding 32137216 bytes to physical memory to account for exec-shield gap
Linux version 5.1.16 (cadey@kahless) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #30 Sun Jul 7 18:57:19 UTC 2019
Built 1 zonelists, mobility grouping on. Total pages: 23898
Kernel command line: root=/dev/root rootflags=/home/cadey/dl/uml/alpine rootfstype=hostfs rw mem=64M init=/bin/sh
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode-cache hash table entries: 8192 (order: 4, 65536 bytes)
Memory: 59584K/96920K available (2692K kernel code, 708K rwdata, 588K rodata, 104K init, 244K bss, 37336K reserved, 0K cma-reserved)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS: 15
clocksource: timer: mask: 0xffffffffffffffff max_cycles: 0x1cd42e205, max_idle_ns: 881590404426 ns
Calibrating delay loop... 7479.29 BogoMIPS (lpj=37396480)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes)
Checking that host ptys support output SIGIO...Yes
Checking that host ptys support SIGIO on close...No, enabling workaround
devtmpfs: initialized
random: get_random_bytes called from setup_net+0x48/0x1e0 with crng_init=0
Using 2.6 host AIO
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 256 (order: 0, 6144 bytes)
NET: Registered protocol family 16
clocksource: Switched to clocksource timer
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
console [stderr0] disabled
mconsole (version 2) initialized on /home/cadey/.uml/tEwIjm/mconsole
Checking host MADV_REMOVE support...OK
workingset: timestamp_bits=62 max_order=14 bucket_order=0
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered (default)
io scheduler bfq registered
loop: module loaded
NET: Registered protocol family 17
Initialized stdio console driver
Using a channel type which is configured out of UML
setup_one_line failed for device 1 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 2 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 3 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 4 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 5 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 6 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 7 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 8 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 9 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 10 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 11 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 12 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 13 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 14 : Configuration failed
Using a channel type which is configured out of UML
setup_one_line failed for device 15 : Configuration failed
Console initialized on /dev/tty0
console [tty0] enabled
console [mc-1] enabled
Failed to initialize ubd device 0 :Couldn't determine size of device's file
VFS: Mounted root (hostfs filesystem) on device 0:11.
devtmpfs: mounted
This architecture does not have kernel memory protection.
Run /bin/sh as init process
/bin/sh: can't access tty; job control turned off
random: fast init done
/ #
Liphetoho tse ka holimo li tla re fa tsamaiso ea baeti bonyane, ntle le lintho tse kang /proc kapa lebitso la moamoheli le abetsoeng. Ka mohlala, leka litaelo tse latelang:
- uname -av
- cat /proc/self/pid
- hostname
Ho tsoa ho moeti, thaepa exit kapa tobetsa control-d. Sena se tla bolaea khetla e lateloang ke kernel panic:
/ # exit
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
fish: “./linux root=/dev/root rootflag…” terminated by signal SIGABRT (Abort)
Re na le tšabo ena ea kernel hobane kernel ea Linux e nahana hore ts'ebetso ea ho qala e lula e sebetsa. Ntle le eona, sistimi e ke ke ea hlola e sebetsa le ho senyeha. Empa kaha sena ke ts'ebetso ea mosebelisi, sephetho se itlhahisa ho SIGABRT, e lebisang ho tsoa.
Tlhophiso ea marang-rang ea baeti
'Me mona ke moo lintho li qalang ho senyeha. Networking in User Mode Linux ke moo mohopolo o felletseng oa "mosebelisi" o lekanyelitsoeng o qalang ho putlama. Etsoe, hangata boemong ba tsamaiso, marang-rang a lekanyelitsoe lehlohonolo mekhoa ea ho bolaoa ka mabaka a utloahalang kaofela ha rona.
Hlokomela. ka.: U ka bala haholoanyane ka likhetho tse fapaneng tsa ho sebetsa le marang-rang ho UML mona.
Leeto la ho Slirp
Leha ho le joalo, ho na le sesebelisoa sa khale se batlang se sa tšehetsoe se bitsoang Slirp, eo Linux Mode ea Mosebelisi e ka sebelisanang le marang-rang. E sebetsa ka mokhoa o batlang o tšoana le sethala sa TCP/IP sa mosebelisi mme ha e hloke tumello ea sistimi ho sebetsa. Sesebelisoa sena se ne se e lokollotsoe ka 1995, 'me ntlafatso ea ho qetela e ngotsoe ka nako 2006. Slirp o tsofetse haholo. Nakong eo ntle le ts'ehetso le lisebelisoa, bahlophisi ba tsamaile ho fihlela joale sesebelisoa sena se ka hlalosoa feela e le ho bola ha khoutu.
Kahoo ha re khoasolle Slirp ho tsoa polokelong ea Ubuntu 'me re leke ho e tsamaisa:
sudo apt-get install slirp
/usr/bin/slirp
Slirp v1.0.17 (BETA)
Copyright (c) 1995,1996 Danny Gasparovski and others.
All rights reserved.
This program is copyrighted, free software.
Please read the file COPYRIGHT that came with the Slirp
package for the terms and conditions of the copyright.
IP address of Slirp host: 127.0.0.1
IP address of your DNS(s): 1.1.1.1, 10.77.0.7
Your address is 10.0.2.15
(or anything else you want)
Type five zeroes (0) to exit.
[autodetect SLIP/CSLIP, MTU 1500, MRU 1500, 115200 baud]
SLiRP Ready ...
fish: “/usr/bin/slirp” terminated by signal SIGSEGV (Address boundary error)
Oho melimo. Ha re kenyeng debugger ea Slirp 'me re bone hore na re ka tseba se etsahalang mona:
sudo apt-get install gdb slirp-dbgsym
gdb /usr/bin/slirp
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/slirp...Reading symbols from /usr/lib/debug/.build-id/c6/2e75b69581a1ad85f72ac32c0d7af913d4861f.debug...done.
done.
(gdb) run
Starting program: /usr/bin/slirp
Slirp v1.0.17 (BETA)
Copyright (c) 1995,1996 Danny Gasparovski and others.
All rights reserved.
This program is copyrighted, free software.
Please read the file COPYRIGHT that came with the Slirp
package for the terms and conditions of the copyright.
IP address of Slirp host: 127.0.0.1
IP address of your DNS(s): 1.1.1.1, 10.77.0.7
Your address is 10.0.2.15
(or anything else you want)
Type five zeroes (0) to exit.
[autodetect SLIP/CSLIP, MTU 1500, MRU 1500, 115200 baud]
SLiRP Ready ...
Program received signal SIGSEGV, Segmentation fault.
ip_slowtimo () at ip_input.c:457
457 ip_input.c: No such file or directory.
Phoso e ntse e re otla mola ona. Ha re shebeng stacktrace, mohlomong ho na le ho tla re thusa moo:
(gdb) bt full
#0 ip_slowtimo () at ip_input.c:457
fp = 0x55784a40
#1 0x000055555556a57c in main_loop () at ./main.c:980
so = <optimized out>
so_next = <optimized out>
timeout = {tv_sec = 0, tv_usec = 0}
ret = 0
nfds = 0
ttyp = <optimized out>
ttyp2 = <optimized out>
best_time = <optimized out>
tmp_time = <optimized out>
#2 0x000055555555b116 in main (argc=1, argv=0x7fffffffdc58) at ./main.c:95
No locals.
Mona re bona hore ho oa ho etsahala nakong ea ho qala ha loop e kholo, ha slirp e leka ho hlahloba nako ea ho fela. Ke nakong ena moo ke ileng ka tlameha ho tlohela ho leka ho lokisa bothata. Empa ha re boneng hore na Slirp, e hahiloeng ka mefuta, e sebetsa. Ke ile ka khoasolla polokelo ea litaba ka kotloloho sebakeng sa marang-rang Mohloli oa matlafatso, hobane ho hula ntho ho tloha moo ka mohala oa taelo ho bohloko:
cd ~/dl
wget https://xena.greedo.xeserv.us/files/slirp-1.0.16.tar.gz
tar xf slirp-1.0.16.tar.gz
cd slirp-1.0.16/src
./configure --prefix=$HOME/prefix/slirp
make
Mona re bona litlhokomeliso mabapi le mesebetsi e hahelletsoeng e sa hlalosoang, ke hore, mabapi le ho se khone ho hokahanya faele ea binary e hlahisitsoeng. Ho bonahala eka pakeng tsa 2006 le ntlha ena, gcc e emisitse ho hlahisa matšoao a sebelisoang mesebetsing e hahelletsoeng ea lifaele tse kopaneng tse mahareng. Ha re leke ho fetola lebitso la sehlooho inline ka maikutlo a se nang letho 'me u shebe sephetho:
vi slirp.h
:6
a
<enter>
#define inline /**/
<escape>
:wq
make
Che. Sena le sona ha se sebetse. E ntse e sa fumane matšoao bakeng sa mesebetsi ena.
Ka nako ena, ke ile ka tela mme ka qala ho sheba Github Heroku haha liphutheloana. Khopolo ea ka e ne e le hore sephutheloana se seng sa Heroku se tla ba le li-binary tseo ke li hlokang. Qetellong, phuputso e ile ea ntsamaisa mona. Ke ile ka khoasolla le ho phutha uml.tar.gz mme o fumane tse latelang:
total 6136
-rwxr-xr-x 1 cadey cadey 79744 Dec 10 2017 ifconfig*
-rwxr-xr-x 1 cadey cadey 373 Dec 13 2017 init*
-rwxr-xr-x 1 cadey cadey 149688 Dec 10 2017 insmod*
-rwxr-xr-x 1 cadey cadey 66600 Dec 10 2017 route*
-rwxr-xr-x 1 cadey cadey 181056 Jun 26 2015 slirp*
-rwxr-xr-x 1 cadey cadey 5786592 Dec 15 2017 uml*
-rwxr-xr-x 1 cadey cadey 211 Dec 13 2017 uml_run*
Ena ke binary e thellang! Na oa sebetsa?
./slirp
Slirp v1.0.17 (BETA) FULL_BOLT
Copyright (c) 1995,1996 Danny Gasparovski and others.
All rights reserved.
This program is copyrighted, free software.
Please read the file COPYRIGHT that came with the Slirp
package for the terms and conditions of the copyright.
IP address of Slirp host: 127.0.0.1
IP address of your DNS(s): 1.1.1.1, 10.77.0.7
Your address is 10.0.2.15
(or anything else you want)
Type five zeroes (0) to exit.
[autodetect SLIP/CSLIP, MTU 1500, MRU 1500]
SLiRP Ready ...
Ha e senyehe - kahoo e lokela ho sebetsa! Ha re leme binary ena ho ~/bin/slirp:
Litaelo tse peli tsa pele tsa tlhophiso /proc и /sys e hlokahalang bakeng sa mosebetsi ifconfig, e behang sebopeho sa marang-rang ho buisana le Slirp. Sehlopha route e seta tafole ea ho tsamaisa kernel ho qobella sephethephethe sohle ho romelloa ka kotopo ea Slirp. Ha re hlahlobeng sena ka potso ea DNS:
Tlhokomeliso ka.: Kamoo ho bonahalang kateng, poso ea pele e ne e ngotsoe k'homphieutheng e nang le karete ea marang-rang e nang le mohala, kapa tlhophiso e 'ngoe e sa hlokeng bakhanni ba eketsehileng. Ho laptop e nang le WiFi 8265 ho tloha Intel, phoso e etsahala ha ho phahamisa marang-rang
/ # ifconfig eth0 10.0.2.14 netmask 255.255.255.240 broadcast 10.0.2.15
slirp_tramp failed - errno = 2
ifconfig: ioctl 0x8914 failed: No such file or directory
/ #
Kamoo ho bonahalang kateng, kernel ha e khone ho buisana le mokhanni oa karete ea marang-rang. Boiteko ba ho bokella firmware ka kernel, ka bomalimabe, ha boa ka ba lokisa boemo. Nakong ea phatlalatso, ho ne ho sa khonehe ho fumana tharollo tlhophisong ena. Ho li-configs tse bonolo (mohlala, ho Virtualbox), sebopeho se nyoloha ka nepo.
Ha re ikemisetseng ho tsamaisa hape ka mongolo o latelang oa khetla:
'Me joale re tla etsa liphetoho moleng oa taelo oa kernel:
linux
root=/dev/root
rootfstype=hostfs
rootflags=$HOME/prefix/uml-demo
rw
mem=64M
eth0=slirp,,$HOME/bin/slirp
init=/init.sh
Mme ha re pheteng:
SLiRP Ready ...
networking set up
/bin/sh: can't access tty; job control turned off
nslookup google.com 8.8.8.8
Server: 8.8.8.8
Address 1: 8.8.8.8 dns.google
Name: google.com
Address 1: 172.217.12.206 lga25s63-in-f14.1e100.net
Address 2: 2607:f8b0:4004:800::200e iad30s09-in-x0e.1e100.net
Marang-rang a tsitsitse!
faele ea docker
Ho etsa hore ho be bonolo ho uena ho hlahloba tsena tsohle, ke bokelletse dockerfile, e iketsetsang boholo ba mehato e hlalositsoeng mme e lokela ho u fa tlhophiso ea ho sebetsa. Le 'na ke na le kernel e hlophisitsoeng esale pele, e nang le ntho e 'ngoe le e' ngoe e hlalositsoeng posong. Empa ke habohlokoa ho utloisisa hore mona ke hlalositse feela boemo bo fokolang.
Ke tšepa hore poso ena e u thusitse ho utloisisa mokhoa oa ho hōlisa kernel ea baeti. E ile ea bonahala e le mofuta o mong oa monster, empa khatiso e ile ea nkoa e le tataiso e pharaletseng mabapi le ho aha, ho kenya le ho hlophisa Mokhoa oa Mosebelisi ho Linux tlas'a mefuta ea morao-rao ea tsamaiso ea lelapa lena. Mehato e latelang e lokela ho kenyelletsa ho kenya lits'ebeletso le software e 'ngoe e seng e ntse e le ka har'a sistimi ea baeti. Kaha litšoantšo tsa setshelo sa Docker ke li-tarball tse phatlalalitsoeng feela, u lokela ho khona ho ntša setšoantšo ka docker export, ebe u khetha tsela ea ho e kenya motso oa sistimi ea faele ea moeti. Joale, tsamaisa script ea khetla.
Liteboho tse khethehileng ho Rkeene ho tsoa ho #lobster ho Freenode. Ntle le thuso ea hae ea ho lokisa Slirp, nka be ke sa fihla mona. Ha ke tsebe hore na sistimi ea hae ea Slackware e sebetsa ka nepo joang ka slirp, empa lits'ebetso tsa ka tsa Ubuntu le Alpine ha lia ka tsa amohela slirp mme binary Rkeene e ile ea nkhothalletsa. Empa ho ntekane hore bonyane ho na le ntho e sebetsang bakeng sa ka.