Ubuntu 18.04 sever without network after move SSD from PC1 to PC2

I tested on Ubuntu 18.04 desktop it is OK. But I tested Ubuntu 18.04 server or 20.04 server , I move SSD from PC1 to PC2 then PC2 without network, without too from Hyper-V to PC1 (by dd & balena etcher) I wanna distribution to many PC without monitor (coin mining), It need auto command in bash file to fix this error. Help me, please! I'm not found in similar questions.

PS:

cmd ip a result:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether f0:79:59:6a:6f:88 brd ff:ff:ff:ff:ff:ff

cmd ip r result: empty string ('')

cmd cat /etc/netplan/*.yaml result:

# This is the network config written by 'subiquity'
network: ethernets: eth0: dhcp4: true version: 2
2

2 Answers

Please notice that the relevant ethernet interface is enp3s0; however, the netplan file refers to eth0. Please edit your netplan yaml file to replace eth0 with enp3s0. Follow with:

sudo netplan generate
sudo netplan apply

Is there any improvement?

1

Thankyou chili555. I success fix this error, below is file bash auto fix:

#!/usr/bin/env bash eth0=`ip a | grep "state DOWN" | cut -d ' ' -f 2 | cut -d ':' -f 1` if [[ ! -z "$eth0" ]] ; then echo "Internet isn't present" filelist=(/etc/netplan/*.yaml) for ((i0=0; i0 < ${#filelist[@]}; i0++)); do #echo changing file: ${filelist[$i0]} eth1=`cat ${filelist[$i0]} | grep ' ' | cut -d ' ' -f 5 | cut -d ':' -f 1` #echo eth1 = $eth1, eth0 = $eth0 sed -i "s/$eth1/$eth0/g" ${filelist[$i0]} done sudo netplan generate sudo netplan apply else echo "Internet is present" fi

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like