ubuntu-ssh-reinstall/README.md

93 lines
2.9 KiB
Markdown
Raw Normal View History

2016-11-13 14:18:01 +00:00
# Ubuntu Overssh Reinstallation
If your ISP/Datacenter dosn't provide standard or trusted iso for your server. Get ugly server from it with installed version of Ubuntu server.
I have same situation installed ubuntu has bad partition table or huge list of stupid package installed. Datacenter network is my primary concern or it's really cheap price but administrators dosn't care. What should i do? That's my way to solve this issue easily.
Ask them to install ubuntu server what ever is it. re install it over ssh.
Create your own netiso and reinstall it over ssh. You can partion yor server as you desire. And set more configuration using [ubuntu preseed](https://help.ubuntu.com/lts/installation-guide/armhf/apbs02.html) just over ssh; no kvm/ipmi/vnc required.
### Requirement
1. Installed ubuntu version on server via ssh access
2. Clone this repo to your server
3. Copy `config.sample` to `config` file and edit field by field exactly:
2016-11-13 14:36:09 +00:00
```
# country
COUNTRY='IR'
2016-11-13 14:18:01 +00:00
2016-11-13 14:36:09 +00:00
# network: check network before create iso file
INTERFACE_DEV='eth0'
INTERFACE_IP='10.1.1.100'
INTERFACE_NETMASK='255.255.255.0'
INTERFACE_GATEWAY='10.1.1.1'
INTERFACE_NAMESERVERS='4.2.2.4'
2016-11-13 14:18:01 +00:00
2016-11-13 14:36:09 +00:00
# preseed file: upload created preseed.cfg to your own host before reboot system
2016-11-14 17:40:52 +00:00
PRESEED_URL="http://yourserver.tld/preseed.cfg"
2016-11-13 14:18:01 +00:00
2016-11-13 14:36:09 +00:00
# ssh installer password
PASSWORD="tHISiSpASSWORD"
2016-11-13 14:18:01 +00:00
2016-11-13 14:36:09 +00:00
# hostname and domain
2016-11-14 17:40:52 +00:00
HOSTNAME="${INTERFACE_IP//\./\-}"
DOMAIN="servers.domain.org"
2016-11-13 14:18:01 +00:00
2016-11-13 14:36:09 +00:00
# lowercase of country code dont change it
COUNTRY_LOWER="${COUNTRY,,}"
```
2016-11-13 14:18:01 +00:00
4. Upload your `preseed.cfg` file to your own host.
#### Clone repository
```
cd /tmp
git clone https://github.com/mhf-ir/ubuntu-overssh-reinstallation.git
cd ubuntu-overssh-reinstallation
```
#### Config
See `config.sample` and change it. Carefull about your network settings. It's can hold your server until get new kvm/ipmi/vnc to restore the ssh again.
```
cp config.sample config
vim config
```
#### Download network mini iso from ubuntu website
```
wget http://archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/current/images/netboot/mini.iso
```
#### Build iso
Remember you must do as root user
```
./create-iso.sh
...
2016-11-13 14:36:09 +00:00
Your network iso is ready '/tmp/ubuntu-overssh-reinstallation/ubuntu-overssh-reinstall.iso'
2016-11-13 14:18:01 +00:00
```
#### Update grub imageboot
Remember you must do as root user also
```
./grub.sh
...
Your password is tHISiSpASSWORD
```
2016-11-14 17:40:52 +00:00
#### Upload your preseed file
Upload your preseed.cfg file to configured location `PRESEED_URL`.
You can test it. We must get 200 response as we expected
```
curl -o /dev/null --silent --head --write-out '%{http_code}\n' http://yourserver.tld/preseed.cfg
200
```
2016-11-13 14:18:01 +00:00
#### Reboot
```
reboot
```
#### Get ssh
Wait it until boot to iso complete and install require packages then
```
ssh installer@10.1.1.100
```
#### Continue installation of ubuntu
---
This script test on Ubuntu 16.04 Server.