# Migrating Linux VM from vSphere to NCS

NIPA Cloud Space หรือ NCS เป็น pubilc cloud ที่คุณสามารถย้ายระบบของคุณมาใช้บน NCS ได้ด้วยตนเอง คุณสามารถศึกษาวิธีการย้ายระบบจาก Linux VM บน vSphere มาสู่ NIPA Cloud Space และการติดตั้ง instance ได้จากเอกสารนี้ &#x20;

**ระบบ Linux VM ที่สามารถย้ายสู่ NIPA Cloud Space ได้ มีดังนี้** &#x20;

* centos8&#x20;
* centos7&#x20;
* ubuntu18.04&#x20;
* ubuntu20.04&#x20;
* non LVM partition (all Linux Distro)&#x20;

การย้ายระบบสู่ NIPA Cloud Space สามารถทำได้ตามขั้นตอนต่อไปนี้ &#x20;

1. [เตรียมระบบให้พร้อม](#step-1)
2. [ลบ VMware tool บน Linux VM ออก](#step-2-vmware-tool-linux)
3. [Convert ไฟล์ vmdk ให้เป็น qcow2 เพื่อ Import สู่ NCS](#step-3-convert-vmdk-qcow2-import-ncs)
4. [อัปโหลดขึ้น NIPA Cloud Space](#step-4-nipa-cloud-space-ncs)
5. [สร้าง instance จากไฟล์ที่อัปโหลดแล้ว](#step-5-instance)

### Step 1: เตรียมระบบของคุณให้พร้อม

***กรณีที่ใช้ระบบ centos7 หรือ ตระกูล redhat***

1. Disable NetworkManager service และ enable network service

```
systemctl disable NetoworkManager
```

<figure><img src="/files/4wKnMd1vJHompTdKk8C9" alt=""><figcaption></figcaption></figure>

```
systemctl enable network
```

<figure><img src="/files/TpWWVDCA1IY5cn3BHDy0" alt=""><figcaption></figcaption></figure>

```
systemctl restart network
systemctl status network
systemctl status NetworkManager
```

<figure><img src="/files/5rxWrSg5Vm6csM5zqKQA" alt=""><figcaption></figcaption></figure>

2\. แก้ไข fstab file เพื่อทำการปิด swap

```
vim /etc/fstab
```

<figure><img src="/files/GMRoI43v65PuTE8NhAMU" alt=""><figcaption></figcaption></figure>

3\. ติดตั้ง cloud-init สำหรับ centos7

```
yum install cloud-utils-growpart cloud-init cloud-utils
rpm -qa | grep cloud
```

<figure><img src="/files/LeyG1RQN0D7SaCtWVrMO" alt=""><figcaption></figcaption></figure>

4\. ลบ interface configuration จากนั้นจึงลบ VMware tool ต่อในขั้นตอนถัดไป

<figure><img src="/files/R9Uas05FNV5p4KJ4OxWW" alt=""><figcaption></figcaption></figure>

```
rm -rf /etc/sysconfig/network-scripts/ifcfg-ens192
```

```
poweroff
```

***กรณีที่ใช้ ubuntu18.04 ขึ้นไป หรือตระกูล debian***

1. แก้ไข fstab file

```
vim /etc/fstab
```

<figure><img src="/files/u7kHXB18CLSS7IBhlqey" alt=""><figcaption></figcaption></figure>

2\. Clear configuration file ของ cloud-init (เฉพาะ ubuntu20.04 ขึ้นไป)

```
rm -rf  /var/lib/cloud/instances/*
```

```
rm -rf /etc/netplan/00-installer-config.yaml
```

```
touch /etc/netplan/50-cloud-init.yaml
```

###

### Step 2: ลบ VMware tool บน Linux ของคุณ

1. ลบ vmware-tools โดยการ mount iso ของ vmware-tools

<figure><img src="/files/NZiXZ3jDNn60uoBe9mLe" alt=""><figcaption></figcaption></figure>

2\. Run command การลบ VMware tool ดังกล่าว

```
./vmware-uninstall-tools.pl
```

<figure><img src="/files/J17YubYQemZoNzlxXot1" alt=""><figcaption></figcaption></figure>

### Step 3: Convert ไฟล์ vmdk ให้เป็น qcow2 เพื่อ Import สู่ NCS

1\. ดาวน์โหลด Disk FIle จาก vCenter

<figure><img src="/files/cVWqWxvtStFlEQUFXRoh" alt=""><figcaption></figcaption></figure>

2\. ไฟล์ที่ดาวน์โหลดแล้วจะเป็นไฟล์ zip ให้ extract ไฟล์

<img src="/files/jWOXeSkWSM9etZaIhNLj" alt="" data-size="original">

3\. เมื่อ extract ไฟล์ดังกล่าวแล้ว จะได้ไฟล์ดังภาพ

<figure><img src="/files/5qdjxUlML1fGSr8GyE0g" alt=""><figcaption></figcaption></figure>

4\. Convert vmdk file ไปยัง qcow2&#x20;

```
qemu-img convert -O qcow2 centos7-migrate1.vmdk centos7-migrate1.qcow2
```

<figure><img src="/files/gszTZTWXoaFaBYnSSaJa" alt=""><figcaption></figcaption></figure>

### Step 4: อัปโหลดขึ้น NIPA Cloud Space (NCS)

1. ฝากไฟล์ qcow2 ที่ได้ บนแพลตฟอร์มออนไลน์ใดก็ได้ ในที่นี้ จะใช้ Onedrive

<figure><img src="/files/AvVH8T7Shz61YmmUTuFD" alt=""><figcaption></figcaption></figure>

2\. ล็อกอินเข้า NIPA Cloud Space แล้วคลิกที่ Image ดังภาพ

<figure><img src="/files/qeYQYtRmcnjKJ0s1a3sN" alt=""><figcaption></figcaption></figure>

3\. ตั้งชื่อ image และ URL ของ image file

![](/files/0ErcyovUkGtQfnTJ3U3i)

4\. คลิกที่ Advance settings แล้วตั้งค่าดังนี้&#x20;

* Operating System Type: Windows
* Min Disk: 40
* คลิกเลือก Cloud-Init Agent&#x20;
* คลิกเลือก QEMU Agent

![](/files/fFXsM0SpqfaphB8gWqAT)

### STEP 5: สร้าง instance จากไฟล์ที่อัปโหลดแล้ว

1\. ไปที่หน้า instance เพื่อสร้าง instance จาก image ที่อัปโหลดขึ้นไป เพียงเท่านี้ก็สามารถสร้าง instance บน NCS จากระบบที่ย้ายมาได้แล้ว&#x20;

<figure><img src="/files/J5SoTamV4IeE8adE9FMw" alt=""><figcaption></figcaption></figure>

2\. ไปที่ Images เพื่อเลือก Image ที่ import เข้ามา

<figure><img src="/files/rCix54CJFMC1MhEFSImk" alt=""><figcaption></figcaption></figure>

3\. เลือก Machine Type

<figure><img src="/files/3HHzsKzBIZcLVOgiybpw" alt=""><figcaption></figcaption></figure>

4\. ตั้งชื่อ Instance&#x20;

<figure><img src="/files/lPDHmanpjKSvIEucaIIV" alt=""><figcaption></figcaption></figure>

5\. เลือก storage type สำหรับ volume

<figure><img src="/files/VP5wuJBvxUoisuEM3Dys" alt=""><figcaption></figcaption></figure>

6\. ตั้งค่า IP address

<figure><img src="/files/ALxlpHP8OsLp8GaBwu8A" alt=""><figcaption></figcaption></figure>

7\. เลือก security group

<figure><img src="/files/cRO3HQZZHu60HPMPCY7C" alt=""><figcaption></figcaption></figure>

8\. เริ่มสร้าง instance คลิก LAUNCH

<figure><img src="/files/B4xhSmeNkMUmX9uz0ES6" alt=""><figcaption></figcaption></figure>

9\. เมื่อสร้างเสร็จแล้วจะปรากฏสถานะดังภาพ ให้คลิกที่ชื่อ instance นั้น&#x20;

<figure><img src="/files/F1lyFICGIZPm47wzAEH4" alt=""><figcaption></figcaption></figure>

10\. คลิก CONSOLE

<figure><img src="/files/AbPqyYitHKG8J84r9yjg" alt=""><figcaption></figcaption></figure>

11\. Migrate Linux VM ได้สำเร็จ&#x20;

<figure><img src="/files/LaHlJzMByOLKDokVVb8p" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-epc.gitbook.io/ncs-documents/migration/migrating-linux-vm-from-vsphere-to-ncs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
