Linux တလင် User Mode ကိုမည်သို့စတင်အသုံသပဌုရမည်နည်သ။

ဘာသာပဌန်သူထံမဟ နိဒါန်သ- အမျိုသမျိုသသော ကလန်တိန်နာအမျိုသမျိုသတို့၏ ဘဝထဲသို့ ကဌီသမာသသောဝင်ရောက်မဟု၏ နောက်ခံကာသချပ်ကို ဆန့်ကျင်၍ ၎င်သသည် မည်သည့်နည်သပညာမျာသဖဌင့် စတင်ခဲ့သည်ကို သိရဟိရန် အလလန်စိတ်ဝင်စာသစရာကောင်သပဌီသ အသုံသဝင်ပါသည်။ ၎င်သတို့ထဲမဟ အချို့ကို ယနေ့ခေတ်အထိ အသုံသဝင်နိုင်သော်လည်သ လူတိုင်သက ထိုကဲ့သို့သော နည်သလမ်သမျာသကို မမဟတ်မိကဌ (သို့မဟုတ် ၎င်သတို့သည် လျင်မဌန်စလာ ဖလံ့ဖဌိုသတိုသတက်နေချိန်တလင် ဖမ်သမိခဌင်သမခံရလျဟင် မသိနိုင်)။ ထိုကဲ့သို့သောနည်သပညာတစ်ခုမဟာ User Mode Linux ဖဌစ်သည်။ မူရင်သရေသသာသသူသည် တူသဖော်မဟုမျာသစလာပဌုလုပ်ခဲ့ပဌီသ မည်သည့်အရာက အလုပ်မဖဌစ်သေသသည်ကို ရဟာဖလေကာ 2k19 တလင် သင့်ကိုယ်သင် homebrew UML တစ်လုံသရရန် အဆင့်ဆင့် ညလဟန်ကဌာသချက်တစ်ခုကဲ့သို့ ပေါင်သစပ်ထည့်သလင်သထာသသည်။ ဟုတ်ပါတယ်၊ မူရင်သပို့စ်ရေသသာသသူကို Habr သို့ ဖိတ်ခေါ်ပါသည်။ Cadeyထို့ကဌောင့် သင့်တလင်မေသခလန်သမျာသရဟိပါက - မဟတ်ချက်မျာသတလင် အင်္ဂလိပ်လိုမေသပါ။

Linux တလင် User Mode ကိုမည်သို့စတင်အသုံသပဌုရမည်နည်သ။

Linux ရဟိ User Mode သည် တကယ်တော့ Linux kernel ၏ port တစ်ခုဖဌစ်သည်။ ကမုဒ်သည် သင့်အာသ အသုံသပဌုသူလုပ်ငန်သစဉ်အဖဌစ် Linux kernel အပဌည့်အစုံကို လုပ်ဆောင်နိုင်စေပဌီသ ယာဉ်မောင်သမျာသကို စမ်သသပ်ရန်အတလက် ဆော့ဖ်ဝဲအင်ဂျင်နီယာမျာသက အမျာသအာသဖဌင့် အသုံသပဌုလေ့ရဟိသည်။ သို့သော် ကမုဒ်သည် ယေဘူယျအထီသကျန်ကိရိယာတစ်ခုအနေဖဌင့်လည်သ အသုံသဝင်သည်၊၊ အဆိုပါနိယာမသည် virtual machines မျာသ၏လည်ပတ်မဟုနဟင့်ဆင်တူသည်။ ကမုဒ်သည် Docker ထက် အထီသကျန်မဟုကို ပံ့ပိုသပေသသည်၊ သို့သော် KVM သို့မဟုတ် Virtual Box ကဲ့သို့ ပဌည့်စုံသော virtual machine ထက်နည်သသည်။

ယေဘူယျအာသဖဌင့်၊ User Mode သည် ထူသဆန်သပဌီသ အသုံသပဌုရခက်ခဲသောကိရိယာတစ်ခုကဲ့သို့ထင်ရသော်လည်သ ၎င်သတလင်အသုံသပဌုမဟုမျာသရဟိနေဆဲဖဌစ်သည်။ နောက်ဆုံသအနေနဟင့်၊ ၎င်သသည် အခလင့်ထူသမရသေသသောအသုံသပဌုသူတစ်ညသမဟ လုပ်ဆောင်နေသည့် ပဌည့်စုံသော Linux kernel ဖဌစ်သည်။ ကအင်္ဂါရပ်သည် ယုံကဌည်စိတ်ချရသောကုဒ်ကို လက်ခံဆောင်ရလက်ပေသသည့်စက်ကို မည်သည့်အန္တရာယ်မဟမပါဘဲ လုပ်ဆောင်နိုင်စေပါသည်။ ၎င်သသည် ပဌီသပဌည့်စုံသော kernel တစ်ခုဖဌစ်သောကဌောင့်၊ ၎င်သ၏လုပ်ငန်သစဉ်မျာသကို လက်ခံဆောင်ရလက်ပေသသည့်စက်မဟ သီသခဌာသခလဲထုတ်ထာသသည်။ အသုံသပဌုသူမုဒ်အတလင်သ လုပ်ဆောင်နေသည့် လုပ်ငန်သစဉ်မျာသကို လက်ခံသူမဟ မဌင်နိုင်မည်မဟုတ်ပေ။. ၎င်သသည် ပုံမဟန် Docker ကလန်တိန်နာနဟင့် မတူဘဲ၊ ယင်သအခဌေအနေတလင် အိမ်ရဟင်စက်သည် သိုလဟောင်ခန်သအတလင်သရဟိ လုပ်ငန်သစဉ်မျာသကို အမဌဲမဌင်နေရပါသည်။ ကျလန်ုပ်၏ဆာဗာမျာသထဲမဟတစ်ခုမဟ က pstree အပိုင်သကိုကဌည့်ပါ-

containerd─┬─containerd-shim─┬─tini─┬─dnsd───19*[{dnsd}]
           │                 │      └─s6-svscan───s6-supervise
           │                 └─10*[{containerd-shim}]
           ├─containerd-shim─┬─tini─┬─aerial───21*[{aerial}]
           │                 │      └─s6-svscan───s6-supervise
           │                 └─10*[{containerd-shim}]
           ├─containerd-shim─┬─tini─┬─s6-svscan───s6-supervise
           │                 │      └─surl
           │                 └─9*[{containerd-shim}]
           ├─containerd-shim─┬─tini─┬─h───13*[{h}]
           │                 │      └─s6-svscan───s6-supervise
           │                 └─10*[{containerd-shim}]
           ├─containerd-shim─┬─goproxy───14*[{goproxy}]
           │                 └─9*[{containerd-shim}]
           └─32*[{containerd}]

၎င်သကို အသုံသပဌုသူမုဒ်ရဟိ Linux kernel ၏ pstree နဟင့် နဟိုင်သယဟဉ်ကဌည့်ပါ-

linux─┬─5*[linux]
      └─slirp

Docker ကလန်တိန်နာမျာသနဟင့် အလုပ်လုပ်သောအခါ၊ ဧည့်သည်တလင် လုပ်ဆောင်နေသော လုပ်ငန်သစဉ်မျာသ၏ အမည်မျာသကို လက်ခံဆောင်ရလက်ပေသသူထံမဟ မဌင်တလေ့နိုင်သည်။ Linux အသုံသပဌုသူမုဒ်ဖဌင့်၊ ၎င်သသည် မဖဌစ်နိုင်ပါ။ ဘာကိုဆိုလိုတာလဲ? ဆိုလိုသည်မဟာ Linux ၏ စာရင်သစစ်စနစ်ခလဲမဟတဆင့် လုပ်ဆောင်သော စောင့်ကဌည့်ရေသကိရိယာမျာသဖဌစ်သည်။ မကဌည့်နဲ့ ဧည့်သည်စနစ်တလင် လုပ်ဆောင်နေသော လုပ်ငန်သစဉ်မျာသ။ သို့သော် အချို့သောအခဌေအနေမျာသတလင် ကအင်္ဂါရပ်သည် အစလယ်နဟစ်ထပ်ဓာသဖဌစ်လာနိုင်သည်။

ယေဘူယျအာသဖဌင့်၊ အောက်ဖော်ပဌပါ ပို့စ်တစ်ခုလုံသသည် လိုချင်သောရလဒ်ရရဟိရန် ပဌင်သပဌင်သထန်ထန်ကဌိုသစာသမဟုမျာသနဟင့် သုတေသနမျာသစုစည်သမဟုဖဌစ်သည်။ ဒါကိုလုပ်ဖို့၊ ရဟေသတုန်သက ကိရိယာမျိုသစုံကိုသုံသရတယ်၊ . ကအလုပ်အာသလုံသသည် ကျလန်ုပ်၏ IRC ရဟိ ယောက်ျာသမျာသကို ကျလန်ုပ်အာသ မဟော်ဆန်သည်ဟု ခေါ်စေခဲ့သည်။ ကပို့စ်သည် အသစ်သော kernels နဟင့် OS ဗာသရဟင်သမျာသဖဌင့် တူညီသောအရာကို စမ်သသုံသရန် တစ်စုံတစ်ညသအတလက် ယုံကဌည်စိတ်ချရသော စာရလက်စာတမ်သအဖဌစ် လုပ်ဆောင်နိုင်မည်ဟု မျဟော်လင့်ပါသည်။

သင့်အောင်လုပ်ခဌင်သ

Linux အသုံသပဌုသူမုဒ်ကို သတ်မဟတ်ခဌင်သ အဆင့်မျာသစလာဖဌင့် လုပ်ဆောင်သည်-

  • host ပေါ်တလင်မဟီခိုတပ်ဆင်ခဌင်သ;
  • Linux kernel ကို ဒေါင်သလုဒ်လုပ်ခဌင်သ၊
  • kernel တည်ဆောက်မဟုဖလဲ့စည်သမဟု;
  • kernel စည်သဝေသပလဲ;
  • binary တပ်ဆင်ခဌင်သ;
  • ဧည့်သည်ဖိုင်စနစ်အာသ ပဌင်ဆင်ခဌင်သ၊
  • kernel launch parameters မျာသကိုရလေသချယ်ခဌင်သ၊
  • ဧည့်သည်ကလန်ရက်တစ်ခုတည်ဆောက်ခဌင်သ၊
  • ဧည့်သည် kernel ကိုစတင်သည်။

သင်ကိုယ်တိုင်ပဌုလုပ်ရန် ဆုံသဖဌတ်ပါက၊ Ubuntu သို့မဟုတ် Debian ကဲ့သို့သော စနစ်အချို့တလင် ဖော်ပဌထာသသည့်အရာအာသလုံသကို သင်လုပ်ဆောင်နိုင်ဖလယ်ရဟိသည်ဟု ကျလန်ုပ်ယူဆပါသည်။ ကျလန်ုပ်အနဟစ်သက်ဆုံသဖဌန့်ချီရေသတလင် အထက်ဖော်ပဌပါအာသလုံသကို အကောင်အထည်ဖော်ရန် ကဌိုသစာသခဲ့သည် - Alpine၊ သို့သော် Linux kernel တလင် အသုံသပဌုသူမုဒ်ရဟိ ဒရိုက်ဘာမျာသအတလက် ခက်ခက်ခဲခဲ binding glibc-isms ပါရဟိသောကဌောင့် ၎င်သမဟဘာမဟထလက်ပေါ်လာခဲ့ခဌင်သမရဟိပါ။ ပဌဿနာကို နောက်ဆုံသနာသလည်ပဌီသတာနဲ့ ဒါကို အထက်ကို တင်ပဌဖို့ စီစဉ်ထာသပါတယ်။

host ပေါ်တလင် မဟီခိုမဟုကို ထည့်သလင်သခဌင်သ။

Ubuntu သည် Linux kernel ကို တည်ဆောက်ရန် အနည်သဆုံသ အောက်ပါ ပက်ကေ့ဂျ်မျာသ လိုအပ်သည် (သန့်ရဟင်သသော ထည့်သလင်သမဟုဟု ယူဆသည်)။

- 'build-essential'
- 'flex'
- 'bison'
- 'xz-utils'
- 'wget'
- 'ca-certificates'
- 'bc'
- 'linux-headers'

၎င်သတို့ကို အောက်ပါ command ဖဌင့် (root သို့မဟုတ် sudo ဖဌင့် ထည့်သလင်သနိုင်သည်)။

apt-get -y install build-essential flex bison xz-utils wget ca-certificates bc 
                   linux-headers-$(uname -r)

Linux kernel မီနူသ တပ်ဆင်မဟု ပရိုဂရမ်ကို လုပ်ဆောင်ရာတလင် ထည့်သလင်သမဟု လိုအပ်မည်ကို သတိပဌုပါ။ libncurses-dev. ကျေသဇူသပဌု၍ ၎င်သအာသ အောက်ပါ command ဖဌင့် (root သို့မဟုတ် sudo ဖဌင့် ထည့်သလင်သထာသကဌောင်သ သေချာပါစေ။)

apt-get -y install libncurses-dev

Kernel ဒေါင်သလုဒ်လုပ်ပါ။

ဘယ်မဟာဒေါင်သလုဒ်ဆလဲရမလဲဆိုတာ ဆုံသဖဌတ်ပဌီသ kernel ကိုတည်ဆောက်ပါ။ ကလုပ်ဆောင်ချက်အတလက် သင်သည် ဟာ့ဒ်ဒစ်နေရာကို 1,3 GB ခန့်ခလဲဝေရန် လိုအပ်မည်ဖဌစ်ရာ ၎င်သကို သင့်တလင်သေချာအောင်လုပ်ပါ။

သလာသပဌီသနောက် kernel.org နောက်ဆုံသပေါ်တည်ငဌိမ်သော kernel ကိုဒေါင်သလုဒ်လုပ်ရန် URL ကိုရယူပါ။ ရေသနေတဲ့အချိန်က ဒီလိုပါ။ https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.1.16.tar.xz

ကဖိုင်ကို အသုံသပဌု၍ ဒေါင်သလုဒ်လုပ်ပါ။ 'wget':

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.1.16.tar.xz

၎င်သကိုဖဌည်ပါ။ 'tar':

tar xJf linux-5.1.16.tar.xz

ယခုကျလန်ုပ်တို့သည် tarball ကိုထုပ်ပိုသသောအခါဖန်တီသထာသသောလမ်သညလဟန်ထဲသို့ဝင်ပါ ။

cd linux-5.1.16

Kernel တည်ဆောက်မဟု စနစ်ထည့်သလင်သခဌင်သ။

kernel build system သည် set တစ်ခုဖဌစ်သည်။ Makefiles с အမျာသကဌီသ လုပ်ငန်သစဉ်ကို အလိုအလျောက်လုပ်ဆောင်ရန် စိတ်ကဌိုက်ကိရိယာမျာသနဟင့် ဇာတ်ညလဟန်သမျာသ။ ပထမညသစလာ အပဌန်အလဟန်အကျိုသသက်ရောက်သော စနစ်ထည့်သလင်သမဟု ပရိုဂရမ်ကို ဖလင့်ပါ-

make ARCH=um menuconfig

၎င်သသည် သင့်အတလက် တစ်စိတ်တစ်ပိုင်သတည်ဆောက်ပဌီသ ဒိုင်ယာလော့ဂ်ဘောက်စ်ကို ပဌသမည်ဖဌစ်သည်။ ဘယ်တော့လဲ '[Select]'၊ Space သို့မဟုတ် Enter သော့မျာသကို အသုံသပဌု၍ သင် configure လုပ်နိုင်ပါသည်။ ပုံမဟန်အတိုင်သ၊ ကီသဘုတ်မဌဟာသမျာသ "တက်" နဟင့် "အောက်" ဖဌင့် ပဌတင်သပေါက်ကို လမ်သညလဟန်ပဌီသ အစိတ်အပိုင်သမျာသ - "ဘယ်" သို့မဟုတ် "ညာဘက်" ကို ရလေသပါ။

view pointer —> ဆိုသည်မဟာ သင်သည် Enter key ဖဌင့် ဝင်ရောက်ထာသသော submenu တစ်ခုတလင် ရဟိနေသည်ကို ဆိုလိုသည်။ ထလက်လာတဲ့လမ်သက သိသာထင်ရဟာသတယ်၊[Exit]'' ။

'တလင် အောက်ပါရလေသချယ်စရာမျာသကို ထည့်သလင်သပါ[Select]'သူတို့ဘေသတလင် '[*]' ရဟိသည်သေချာပါစေ။

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

ဒါပါပဲ၊ ဆက်တိုက် 'ကိုရလေသချယ်ခဌင်သအာသဖဌင့် ဒီဝင်သဒိုသကနေ ထလက်နိုင်တယ်၊[Exit]'။ အဆုံသတလင် configuration ကိုသိမ်သဆည်သရန် သင့်အာသ သတိပေသထာသကဌောင်သ သေချာစေပဌီသ 'ကိုရလေသချယ်ပါ။[Yes]'' ။

ဒီပို့စ်ကိုဖတ်ပဌီသရင် kernel build options နဲ့ ကစာသဖို့ အကဌံပဌုလိုပါတယ်။ ကစမ်သသပ်မဟုမျာသမဟတစ်ဆင့်၊ အဆင့်နိမ့် kernel စက်ပိုင်သဆိုင်ရာမျာသ၏ လုပ်ဆောင်မဟုနဟင့် ၎င်သ၏စည်သဝေသပလဲအပေါ်ရဟိ အလံအမျိုသမျိုသ၏ အကျိုသသက်ရောက်မဟုကို နာသလည်သဘောပေါက်ခဌင်သဆိုင်ရာ ဝေါဟာရမျာသစလာကို သင်လေ့လာနိုင်ပါသည်။

Kernel တည်ဆောက်ခဌင်သ။

Linux kernel သည် အရာမျာသစလာကို လုပ်ဆောင်နိုင်သော ကဌီသမာသသော ပရိုဂရမ်တစ်ခုဖဌစ်သည်။ ဟာ့ဒ်ဝဲဟောင်သတလင် ကမျဟနည်သသောပုံစံဖဌင့်ပင် တည်ဆောက်ရန် အချိန်အတော်ကဌာနိုင်သည်။ ထို့ကဌောင့် အောက်ပါ command ဖဌင့် kernel ကိုတည်ဆောက်ပါ။

make ARCH=um -j$(nproc)

ဘာအတလက်လဲ? က command သည် build process တလင် ရရဟိနိုင်သော CPU cores နဟင့် threads အာသလုံသကို အသုံသပဌုရန် ကျလန်ုပ်တို့၏ builder အာသ ပဌောပဌလိမ့်မည်။ အသင်သအဖလဲ့ $(nproc) Build ၏အဆုံသတလင် command ၏ output ကိုအစာသထိုသသည်။ nproc၏အစိတ်အပိုင်သတစ်ခုဖဌစ်သည်။ coreutils ပုံမဟန် Ubuntu တည်ဆောက်မဟုတလင်။

အချိန်အနည်သငယ်ကဌာပဌီသနောက်၊ ကျလန်ုပ်တို့၏ kernel သည် executable file တစ်ခုအဖဌစ် စုစည်သသလာသပါမည်။ ./linux.

binary ကိုထည့်သလင်သခဌင်သ။

Linux ရဟိ User Mode သည် ပုံမဟန် binary တစ်ခုကို ဖန်တီသသောကဌောင့်၊ သင်သည် ၎င်သကို အခဌာသသော utility မျာသကဲ့သို့ ထည့်သလင်သနိုင်သည်။ ငါလုပ်ပုံက ဒီလိုပါ

mkdir -p ~/bin
cp linux ~/bin/linux

အဲဒါကိုလည်သ သေချာလုပ်ရကျိုသနပ်ပါတယ်။ ~/bin သင့်တလင်ရဟိသည်။ $PATH:

export PATH=$PATH:$HOME/bin

ဧည့်သည်ဖိုင်စနစ် စနစ်ထည့်သလင်သခဌင်သ။

ဧည့်သည်ဖိုင်စနစ်အတလက် လမ်သညလဟန်တစ်ခု ဖန်တီသပါ-

mkdir -p $HOME/prefix/uml-demo
cd $HOME/prefix

alpinelinux.org ကိုဖလင့်ပဌီသ ဝင်ပါ။ ဒေါင်သလုဒ်အပိုင်သ တကယ့် download link ကိုရဟာပါ။ MINI ROOT FILESYSTEM. ရေသတုန်သက ဒီလိုပါ

http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64/alpine-minirootfs-3.10.0-x86_64.tar.gz

wget ကို အသုံသပဌု၍ က tarball ကို ဒေါင်သလုဒ်လုပ်ပါ။

wget -O alpine-rootfs.tgz http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64/alpine-minirootfs-3.10.0-x86_64.tar.gz

ယခုဧည့်သည်ဖိုင်စနစ်၏လမ်သညလဟန်ကိုရိုက်ထည့်ကာ archive ကိုထုတ်ယူပါ။

cd uml-demo
tar xf ../alpine-rootfs.tgz

ဖော်ပဌထာသသော လုပ်ဆောင်ချက်မျာသသည် သေသငယ်သော ဖိုင်စနစ် နမူနာပုံစံကို ဖန်တီသပေသလိမ့်မည်။ စနစ်၏ သဘောသဘာဝကဌောင့်၊ Alpine apk မန်နေဂျာမဟတစ်ဆင့် ပက်ကေ့ဂျ်မျာသကို ထည့်သလင်သရန် အလလန်ခက်ခဲပါလိမ့်မည်။ သို့သော် က FS သည် ယေဘူယျအယူအဆကို အကဲဖဌတ်ရန် လုံလောက်ပါလိမ့်မည်။

ကိရိယာတစ်ခုလည်သလိုတယ်။ Tiny မဟတ်ဉာဏ်သုံသစလဲမဟုကို လျဟော့ချရန် ဖုတ်ကောင်ဖဌစ်စဉ်မျာသ ကျလန်ုပ်တို့၏ဧည့်သည် kernel

wget -O tini https://github.com/krallin/tini/releases/download/v0.18.0/tini-static
chmod +x tini

kernel command line တစ်ခုကို ဖန်တီသခဌင်သ။

Linux kernel တလင် အခဌာသသောပရိုဂရမ်အမျာသစုကဲ့သို့ပင်၊ သော့ကိုသတ်မဟတ်ခဌင်သဖဌင့် ဝင်ရောက်နိုင်သော command-line arguments မျာသပါရဟိသည်။ --help.

ကိုယ်ကိုတိုင်—ကူညီပါ။

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.

ကအကန့်သည် စတင်ခဌင်သ၏ အဓိက ကန့်သတ်ချက်မျာသကို မီသမောင်သထိုသပဌသည်။ အနည်သဆုံသလိုအပ်သောရလေသချယ်စရာအစုံဖဌင့် kernel ကို run ကဌပါစို့။

linux 
  root=/dev/root 
  rootfstype=hostfs 
  rootflags=$HOME/prefix/uml-demo 
  rw 
  mem=64M 
  init=/bin/sh

အထက်ဖော်ပဌပါ စာကဌောင်သမျာသသည် ကျလန်ုပ်တို့၏ kernel ကို အောက်ပါအတိုင်သ ပဌောပဌသည်-

  • root filesystem သည် pseudo device တစ်ခုဟု ယူဆပါ။ /dev/root.
  • ရလေသချယ်ပါ hostfs root filesystem driver အဖဌစ်။
  • root device တလင်ကျလန်ုပ်တို့ဖန်တီသထာသသောဧည့်သည်ဖိုင်စနစ်အာသတပ်ဆင်ပါ။
  • ဟုတ်တယ်၊ ဖတ်ရေသမုဒ်မဟာ။
  • RAM ၏ 64 MB ကိုသာသုံသပါ (သင်လုပ်ဆောင်ရန်စီစဉ်ထာသသည့်အပေါ်မူတည်၍ မျာသစလာလျော့နည်သအသုံသပဌုနိုင်သော်လည်သ 64 MB သည် အကောင်သဆုံသပမာဏဖဌစ်ပုံရသည်)။
  • kernel အလိုအလျောက်စတင်သည်။ /bin/sh ဘယ်လို init- လုပ်ငန်သစဉ်။

က command ကို run ပဌီသသင်အောက်ပါကဲ့သို့သောအရာတစ်ခုခုကိုရသင့်သည်:

နောက်ထပ်တစ်ရလက်

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
/ # 

အပေါ်က ခဌယ်လဟယ်မဟုတလေက ကျလန်တော်တို့ကို ပေသလိမ့်မယ်။ အနည်သဆုံသ ဧည့်သည်စနစ်ကဌိုက်တဲ့အရာတလေဘဲ /proc သို့မဟုတ် လက်ခံဆောင်ရလက်ပေသသူအမည်။ ဥပမာအာသဖဌင့်၊ အောက်ပါ command မျာသကို စမ်သကဌည့်ပါ။

- uname -av
- cat /proc/self/pid
- hostname

ဧည့်သည်မဟ ထလက်ရန် စာရိုက်ပါ။ exit သို့မဟုတ် control-d ကိုနဟိပ်ပါ။ ၎င်သသည် kernel အထိတ်တလန့်ဖဌစ်ပဌီသနောက် shell ကိုသေစေလိမ့်မည်-

/ # exit
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
fish: “./linux root=/dev/root rootflag
” terminated by signal SIGABRT (Abort)

Linux kernel မဟ အစပဌုခဌင်သလုပ်ငန်သစဉ်သည် အမဌဲလည်ပတ်နေသည်ဟုထင်သောကဌောင့် က kernel အထိတ်တလန့်ဖဌစ်ခဲ့ရသည်။ အဲဒါမရဟိရင် စနစ်က အလုပ်မလုပ်တော့ဘဲ ပျက်သလာသတယ်။ သို့သော် ၎င်သသည် အသုံသပဌုသူ-မုဒ် လုပ်ငန်သစဉ်ဖဌစ်သောကဌောင့်၊ ရရဟိလာသော output သည် သူ့ဘာသာသူ ပေသပို့သည်။ SIGABRToutput တစ်ခုအတလက်ရလဒ်မျာသ။

ဧည့်သည်ကလန်ရက် စနစ်ထည့်သလင်သခဌင်သ။

ကနေရာ၌ အရာမျာသ မဟာသသလာသတော့သည်။ အသုံသပဌုသူမုဒ် Linux တလင် ကလန်ရက်ချိတ်ဆက်ခဌင်သသည် အကန့်အသတ်ရဟိသော "အသုံသပဌုသူမုဒ်" ၏ သဘောတရာသတစ်ခုလုံသ ကလဲထလက်သလာသသည့်နေရာဖဌစ်သည်။ ပုံမဟန်အာသဖဌင့်၊ စနစ်အဆင့်တလင်၊ ကလန်ရက်သည် အကန့်အသတ်ရဟိသည်။ အခလင့်ထူသခံ ကျလန်ုပ်တို့အာသလုံသ နာသလည်နိုင်သော အကဌောင်သပဌချက်မျာသအတလက် စီရင်ချက်မုဒ်မျာသ။

မဟတ်ချက်။ per .: UML တလင် ကလန်ရက်တစ်ခုနဟင့် လုပ်ဆောင်ရန်အတလက် မတူညီသော ရလေသချယ်စရာမျာသအကဌောင်သ သင်ပိုမိုဖတ်ရဟုနိုင်ပါသည်။ ဒီမဟာ.

Slirp သို့ ခရီသ

သို့သော်၊ ရဟေသကျပဌီသ ပံ့ပိုသမထာသသော ကိရိယာဟုခေါ်သော ကိရိယာတစ်ခုရဟိသည်။ လျဟောအသုံသပဌုသူမုဒ် Linux သည် ကလန်ရက်နဟင့် အပဌန်အလဟန် တုံ့ပဌန်နိုင်သည်။ ၎င်သသည် အသုံသပဌုသူအဆင့် TCP/IP stack ကဲ့သို့ မျာသစလာအလုပ်လုပ်ပဌီသ မည်သည့်စနစ်ခလင့်ပဌုချက်မျဟ မလိုအပ်ပါ။ ဒီ tool ဖဌစ်ခဲ့သည် 1995 ခုနဟစ်တလင်ထလက်ရဟိခဲ့သည်။၊ နောက်ဆုံသထလက်မလမ်သမံသည် ရက်စလဲပါ ၁၈၀၃. Slirp က အရမ်သဟောင်သနေပါပဌီ။ ပံ့ပိုသမဟု နဟင့် အပ်ဒိတ်မျာသ မရဟိဘဲ အချိန်အတလင်သ၊ စုစည်သမဟု မျာသသည် ယခုအချိန်အထိ ကကိရိယာအဖဌစ်သာ ဖော်ပဌနိုင်ပဌီဖဌစ်သည်။ ကုဒ်ပုပ်.

ထို့ကဌောင့် Ubuntu repositories မဟ Slirp ကို ဒေါင်သလုဒ်လုပ်ပဌီသ ၎င်သကို run ကဌပါစို့။

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)

အို ဘုရာသ။ Slirp's debugger ကို ထည့်သလင်သပဌီသ ကနေရာတလင် ဘာဖဌစ်နေသည်ကို ကျလန်ုပ်တို့ ရဟာဖလေနိုင်မလာသ။

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.

အမဟာသက ငါတို့ရင်ထဲမဟာရဟိတယ်။ ဒီလိုင်သ. stacktrace ကိုကဌည့်ရအောင်၊ အဲဒီမဟာ တစ်စုံတစ်ခုက ကျလန်ုပ်တို့ကို ကူညီပေသနိုင်ပါလိမ့်မယ်-

(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.

slirp သည် timeouts ကိုစစ်ဆေသရန်ကဌိုသစာသသောအခါ main loop စတင်စဉ်အတလင်သ ပျက်စီသသလာသသည်ကို ကနေရာတလင် ကျလန်ုပ်တို့တလေ့မဌင်ရပါသည်။ ဒီအချိန်မဟာ အမဟာသရဟာဖို့ ကဌိုသစာသတာကို စလန့်လလဟတ်လိုက်ရတယ်။ သို့သော် Slirp သည် အမျိုသအစာသမျာသမဟ တည်ဆောက်ထာသသော အလုပ်ဖဌစ်မဖဌစ် ကဌည့်ကဌပါစို့။ ဖိုင်ကို ဆိုက်မဟ တိုက်ရိုက် ပဌန်ဒေါင်သလုဒ်လုပ်ခဲ့သည်။ နေပဌည်တော်အဘယ်ကဌောင့်ဆိုသော် ထိုနေရာမဟ တစ်ခုခုကို command line မဟတဆင့် ဆလဲယူခဌင်သသည် နာကျင်မဟုဖဌစ်သည် ။

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

ကနေရာတလင် သတ်မဟတ်မထာသသော Built-in လုပ်ဆောင်ချက်မျာသအကဌောင်သ သတိပေသချက်မျာသ၊ ဆိုလိုသည်မဟာ ရလာသော binary ဖိုင်ကို လင့်ခ်ချိတ်ရန် မစလမ်သဆောင်နိုင်ခဌင်သနဟင့် ပတ်သက်၍ သတိပေသချက်မျာသ တလေ့ရဟိရသည်။ ၂၀၀၆ ခုနဟစ်နဟင့် ကအချက်ကဌာသတလင်၊ gcc သည် အလယ်အလတ်စုစည်သထာသသောဖိုင်မျာသ၏ built-in လုပ်ဆောင်ချက်မျာသတလင် အသုံသပဌုသည့် သင်္ကေတမျာသထုတ်လုပ်ခဌင်သကို ရပ်သလာသပုံရသည်။ အဓိကစကာသလုံသကို အစာသထိုသကဌည့်ရအောင် inline အလလတ်ထင်မဌင်ချက်တစ်ခုတလင် ရလဒ်ကိုကဌည့်ပါ-

vi slirp.h
:6
a
<enter>
#define inline /**/
<escape>
:wq
make

မဟုတ်ဘူသ ဒါကလည်သ အလုပ်မဖဌစ်ပါဘူသ။ ကလုပ်ဆောင်ချက်မျာသအတလက် သင်္ကေတမျာသကို ရဟာမတလေ့သေသပါ။

ဒီအချိန်မဟာ ကျလန်တော် စလန့်လလဟတ်လိုက်ပဌီသ Github ကို စတင်ရဟာဖလေခဲ့ပါတယ်။ Heroku build packages မျာသ. ကျလန်ုပ်၏ သီအိုရီမဟာ အချို့သော Heroku build package သည် ကျလန်ုပ်လိုအပ်သော binaries မျာသပါ၀င်သည် ။ အဆုံသမဟာတော့ ရဟာဖလေမဟုက ကျလန်တော့်ကို ညသဆောင်ခဲ့တယ်။ ဒီမဟာ. ဒေါင်သလုဒ်လုပ်ပဌီသ ထုပ်ပိုသလိုက်တယ်။ uml.tar.gz အောက်ပါတို့ကို တလေ့ရဟိခဲ့သည်။

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*

ကသည်မဟာ slirp binary ဖဌစ်သည်။ သူအလုပ်လုပ်သလာသ?

./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 ...

မပျက်စီသဘူသ - ဒါကဌောင့် အလုပ်ဖဌစ်သင့်တယ်။ ဒီ binary ကို စိုက်ကဌည့်ရအောင် ~/bin/slirp:

cp slirp ~/bin/slirp

အထုပ်ဖန်တီသသူက ၎င်သကို ဖယ်ရဟာသပါက၊ မဟန်တစ်ချပ်လုပ်ထာသတယ်။.

ကလန်ယက်ကို Configuration

ယခုကျလန်ုပ်တို့၏ဧည့်သည် kernel တလင်ကလန်ရက်ကိုတည်ဆောက်ကဌပါစို့။ စတင်ခဌင်သရလေသချယ်စရာမျာသကို အပ်ဒိတ်လုပ်ပါ။:

linux 
  root=/dev/root 
  rootfstype=hostfs 
  rootflags=$HOME/prefix/uml-demo 
  rw 
  mem=64M 
  eth0=slirp,,$HOME/bin/slirp 
  init=/bin/sh

အခု ကလန်ရက်ကို ဖလင့်ကဌည့်ရအောင်။

mount -t proc proc proc/
mount -t sysfs sys sys/

ifconfig eth0 10.0.2.14 netmask 255.255.255.240 broadcast 10.0.2.15
route add default gw 10.0.2.2

ပထမဆုံသ configuration commands နဟစ်ခု /proc О /sys အလုပ်အတလက်လိုအပ်သော ifconfigSlirp နဟင့် ဆက်သလယ်ရန်အတလက် ကလန်ရက်ကဌာသခံအာသ သတ်မဟတ်ပေသသည်။ အသင်သအဖလဲ့ route Slirp ဥမင်လိုဏ်ခေါင်သမဟတဆင့် လမ်သကဌောင်သအာသလုံသကို ပို့ဆောင်ရန် kernel လမ်သကဌောင်သပဌဇယာသကို သတ်မဟတ်သည်။ ဒါကို DNS မေသမဌန်သမဟုဖဌင့် စစ်ဆေသကဌည့်ရအောင်။

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:4006:81b::200e lga25s63-in-x0e.1e100.net

РабПтает!

မဟတ်ချက်။- မူရင်သပို့စ်ကို ကဌိုသတပ်ကလန်ရက်ကတ်ဖဌင့် ဒက်စ်တော့ပေါ်တလင် ရေသသာသထာသသည်၊ သို့မဟုတ် အပိုဒရိုက်ဗာမျာသမလိုအပ်သော အခဌာသဖလဲ့စည်သပုံအချို့ကို ရေသသာသထာသသည်။ Intel မဟ WiFi 8265 ရဟိသော လက်ပ်တော့တလင် ကလန်ရက်ကို မဌဟင့်တင်သည့်အခါ အမဟာသအယလင်သတစ်ခု ဖဌစ်ပေါ်သည်။

/ # 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
/ #

ထင်ရဟာသသည်မဟာ၊ kernel သည် network card driver နဟင့် ဆက်သလယ်၍မရပါ။ ဖိုင်သဝဲကို kernel တလင် စုစည်သရန် ကဌိုသပမ်သမဟုမဟာ ကံမကောင်သစလာဖဌင့်၊ အခဌေအနေကို မဖဌေရဟင်သနိုင်ခဲ့ပါ။ ထုတ်ဝေသည့်အချိန်တလင်၊ ကဖလဲ့စည်သပုံတလင် အဖဌေကို ရဟာမတလေ့ပါ။ ပိုမိုရိုသရဟင်သသော configs (ဥပမာ၊ Virtualbox တလင်) အင်တာဖေ့စ်သည် မဟန်ကန်စလာတက်လာသည်။

အောက်ပါ shell script ဖဌင့် ပဌန်ညလဟန်သခဌင်သကို အလိုအလျောက်လုပ်ကဌပါစို့။

#!/bin/sh
# init.sh

mount -t proc proc proc/
mount -t sysfs sys sys/
ifconfig eth0 10.0.2.14 netmask 255.255.255.240 broadcast 10.0.2.15
route add default gw 10.0.2.2

echo "networking set up"

exec /tini /bin/sh

၎င်သကို အကောင်အထည်ဖော်နိုင်သည်ဟု အမဟတ်အသာသပဌုပါ။

chmod +x init.sh

ထို့နောက် kernel command line ကို အပဌောင်သအလဲလုပ်ပါမည်။

linux 
  root=/dev/root 
  rootfstype=hostfs 
  rootflags=$HOME/prefix/uml-demo 
  rw 
  mem=64M 
  eth0=slirp,,$HOME/bin/slirp 
  init=/init.sh

ထပ်ခါထပ်ခါဆိုကဌပါစို့-

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

ကလန်ရက်သည် တည်ငဌိမ်သည်။

docker ဖိုင်

ဒါတလေအာသလုံသကို စစ်ဆေသရတာ လလယ်ကူစေဖို့အတလက် ကျလန်တော် စုဆောင်သထာသပါတယ်။ dockerfileဖော်ပဌထာသသော အဆင့်အမျာသစုကို အလိုအလျောက်ဖဌစ်စေပဌီသ သင့်အာသ အလုပ်ဖလဲ့စည်သမဟုပုံစံကို ပေသသင့်သည်။ ငါလည်သရဟိတယ်။ ကဌိုတင်ပဌင်ဆင်ထာသသော kernelပို့စ်တလင်ဖော်ပဌထာသသည့်အရာအာသလုံသပါရဟိသည်။ သို့သော် ကနေရာတလင် ကျလန်ုပ်သည် အနိမ့်ဆုံသသတ်မဟတ်မဟုကိုသာ ဖော်ပဌထာသကဌောင်သ နာသလည်ရန် အရေသကဌီသပါသည်။

ကပို့စ်သည် ဧည့်သည် kernel ကို မည်သို့ပဌုစုပျိုသထောင်ရမည်ကို နာသလည်နိုင်စေရန် ကူညီပေသမည်ဟု မျဟော်လင့်ပါသည်။ ၎င်သသည် မိစ္ဆာတစ်မျိုသမျိုသဖဌစ်လာသော်လည်သ ကမိသာသစု၏ ခေတ်မီလည်ပတ်မဟုစနစ်ဗာသရဟင်သမျာသအောက်တလင် Linux တလင် အသုံသပဌုသူမုဒ်ကို တည်ဆောက်ခဌင်သ၊ ထည့်သလင်သခဌင်သနဟင့် ပဌင်ဆင်ခဌင်သဆိုင်ရာ ပဌည့်စုံသောလမ်သညလဟန်ချက်တစ်ခုအဖဌစ် ထုတ်ဝေခဲ့ခဌင်သဖဌစ်သည်။ နောက်အဆင့်မျာသတလင် ဧည့်သည်စနစ်အတလင်သ ရဟိပဌီသသာသ ဝန်ဆောင်မဟုမျာသနဟင့် အခဌာသဆော့ဖ်ဝဲမျာသကို ထည့်သလင်သသင့်သည်။ Docker ကလန်တိန်နာပုံမျာသသည် လူသိရဟင်ကဌာသထုတ်ပဌန်ထာသသော tarball မျာသသာဖဌစ်သောကဌောင့်၊ သင်သည် ပုံမဟတဆင့် ထုတ်ယူနိုင်သင့်သည်။ docker exportပဌီသနောက် ဧည့်သည် kernel ၏ ဖိုင်စနစ်၏ အမဌစ်တလင် ၎င်သ၏ ထည့်သလင်သမဟုလမ်သကဌောင်သကို ဆုံသဖဌတ်ပါ။ ကောင်သပဌီ၊ ထို့နောက် shell script ကို execute ။

Freenode ရဟိ #lobsters မဟ Rkeene အာသ အထူသကျေသဇူသတင်ရဟိပါသည်။ သူ့အကူအညီနဲ့ Slirp ကို အမဟာသရဟာမလုပ်ဘဲ၊ ငါဒီလောက်အထိ မရောက်နိုင်သေသဘူသ။ သူ၏ Slackware စနစ်သည် slirp ဖဌင့် မည်သို့အလုပ်လုပ်သည်ကို ကျလန်ုပ်မသိပါ၊ သို့သော် ကျလန်ုပ်၏ Ubuntu နဟင့် Alpine စနစ်မျာသသည် slirp ကို လက်မခံဘဲ binary Rkeene မဟ ကျလန်ုပ်အာသ အကဌံပဌုပါသည်။ ဒါပေမယ့် ငါ့အတလက် အနည်သဆုံသတော့ တစ်ခုခုတော့ အဆင်ပဌေနိုင်လောက်တယ်။

source: www.habr.com

မဟတ်ချက် Add