无来

不管你来还是不来
我都在这里,夜夜点亮
不是为了守候
只是为了做好我自己

0%

548
down vote
yes, Brian, you are right: those are the steps, but if you want to end having back a vmdk hard disk (maybe you are interested in using the disk in vwmare too) you miss one more step. So the complete howto is:

1
2
3
4
VBoxManage clonehd "source.vmdk" "cloned.vdi" --format vdi
VBoxManage modifyhd "cloned.vdi" --resize 51200
VBoxManage clonehd "cloned.vdi" "resized.vmdk" --format vmdk
The above will resize the hard disk up to 50GB (50 * 1024MB).

To complete things you need to resize the drive too! To achieve this, you might want to download gparted iso and boot from that iso to resize your drive (select the iso from within the virtualbox settings).

P.S. If your new size is too small, you’ll get the same error even with your new vdi file.

1
down vote
In case it is a fixed drive and not a removable drive, you can add the entry permanently.

1
sudo vi /etc/fstab

Add an entry in the following format:

1
<file-system> <mount-point> <type> <options> <dump> <pass>

And then do:

1
mount -a

mount -o remount,rw /

0 Prepare

yum install pciutils -y

1 get PCI info:

1
2
3
4
5
6
[root@localhost ~] lspci | grep Ethernet   
05:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
06:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
07:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
08:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection

2 add config to cat /usr/lib/udev/rules.d/60-net.rules.

Notice: param KERNELS

1
2
3
4
5
6
[root@localhost ~]# cat /usr/lib/udev/rules.d/60-net.rules
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result"
SUBSYSTEMS=="pci", ACTION=="add", DRIVERS=="?*", KERNELS=="0000:00:05.0", NAME="vfnet0"
SUBSYSTEMS=="pci", ACTION=="add", DRIVERS=="?*", KERNELS=="0000:00:06.0", NAME="vfnet1"
SUBSYSTEMS=="pci", ACTION=="add", DRIVERS=="?*", KERNELS=="0000:00:07.0", NAME="vfnet2"
SUBSYSTEMS=="pci", ACTION=="add", DRIVERS=="?*", KERNELS=="0000:00:08.0", NAME="vfnet3"

3 reboot

4 check

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost ~]# cat /usr/lib/udev/rules.d/60-net.rules
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
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: vfnet0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether f2:d5:5d:21:4e:38 brd ff:ff:ff:ff:ff:ff
3: vfnet1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 3e:ec:21:1a:d2:86 brd ff:ff:ff:ff:ff:ff
4: vfnet2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether be:70:05:01:46:04 brd ff:ff:ff:ff:ff:ff
5: vfnet3: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether e6:de:61:c9:a8:d1 brd ff:ff:ff:ff:ff:ff

I’ve learned how to continue to use the ethX prefix. I’m still using the udev rules that I mentioned in post above. So at bootup udev will rename my interfaces netX. And then using /etc/rc.local I’ve included the following commands to rename them from netX back to ethX.

1
2
3
4
/sbin/ip link set net0 down
/sbin/ip link set net0 name eth0
/sbin/ip link set eth0 up
...

Using the ip command I can change the name of the interfaces after the initial bootup is completed.

1
2
3
4
5
6
7
8
9
$ networksetup -listallnetworkservices  
An asterisk (*) denotes that a network service is disabled.
SAMSUNG Modem
Bluetooth DUN
Thunderbolt Ethernet
Wi-Fi
Bluetooth PAN
Thunderbolt Bridge
$ networksetup -setv6off Wi-Fi

1
2
3
Author: Dude
Date: 01-Jun-2013
Version: B
1
2
Last updates:
23-Jul-2013, changes required due to forum upgrade

https://community.oracle.com/thread/2546040

What is Linux network interface bonding? Simply put, the Linux system provides a kernel driver, which can create a logical network device (bond) using 2 or more Network Interface Controllers (NIC) to accomplish link-aggregation and adapter fault-tolerance. For more information, please see the Deployment Guide at https://linux.oracle.com/documentation/

The channel bonding interface supports several modes of operation. In a typical active-backup set up for fault-tolerance, the system performs MII-based health monitoring of the network interface slaves (eth0, eth1) and assigns them according to bond options and interface availability. In active-backup mode (mode 1), only the current active network device is seen externally.

Linux bonding for fault-tolerance under Oracle VM VirtualBox does not seem to function as advertised. Searching the Internet for more information shows that other people have tried to set up Linux bonding using various virtualization products, virtual host network adapter and bonding options, but without success.

It appears the management of Media Access Control addresses (MAC) interferes with internal routing methods between the host and the virtual machine guest. Using the modinfo bonding command (fig. 1) shows a listing of available parameters for the bonding kernel module. The fail_over_mac parameter addresses the Mac address issue in VirtualBox.

1
2
3
4
5
6
7
# modinfo bonding
filename: /lib/modules/2.6.39-400.17.1.el6uek.x86_64
/kernel/drivers/net/bonding/bonding.ko
parm: fail_over_mac:For active-backup,
do not set all slaves to the same MAC;
0 for none (default), 1 for active, 2 for follow (charp)

Configuration Example

1
2
Virtualization Product: Oracle VM VirtualBox 4.2.10
VM Guest OS: Oracle Linux 6.4 (x64)

VM adapter settings: Bridged Adapter, Paravirtualized Network (virtio-net)

1
2
Adapter1 (eth0): 080027436617, en0, Ethernet 1
Adapter2 (eth1): 08002708F36A, en0, Ethernet 1

Note: If you wish to reset the network adapter names and MAC addresses used by the Oracle Linux guest system, erase the content of /etc/udev/rules.d/70-persistent-net.rules and restart the virtual machine.

1. Create or modify the following configuration files:

/etc/modprobe.d/bonding-eth0_eth1.conf

alias bond0 bonding

/etc/sysconfig/network-scripts/ifcfg-bond0

1
2
3
4
5
6
7
8
9
10
DEVICE=bond0
IPADDR=10.0.2.12
NETMASK=255.0.0.0
GATEWAY=10.0.0.138
DNS1=10.0.0.138
DNS2=8.8.8.8
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
BONDING_OPTS="mode=1 miimon=100 fail_over_mac=1"

/etc/sysconfig/network-scripts/ifcfg-eth0

1
2
3
4
5
6
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

/etc/sysconfig/network-scripts/ifcfg-eth1

1
2
3
4
5
6
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

2. Restart the system or network services (root):

# service network restart

Configuration Test

Enter the following commands as user root to verify proper operation of NIC bonding:

1
2
3
4
5
6
7
8
9
10
11
# tail /var/log/messages
bond0: setting mode to active-backup (1).
bond0: Setting MII monitoring interval to 100.
bond0: Setting fail_over_mac to active (1).
bond0: Adding slave eth0.
bond0: making interface eth0 the new active one.
bond0: first active interface up!
bond0: enslaving eth0 as an active interface with an up link.
bond0: Adding slave eth1.
bond0: enslaving eth1 as a backup interface with an up link.

1
2
3
4
5
6
7
8
9
10
11
12
# ifconfig
bond0 Link encap:Ethernet HWaddr 08:00:27:43:66:17
inet addr:10.0.2.12 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::a00:27ff:fe43:6617/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1

eth0 Link encap:Ethernet HWaddr 08:00:27:43:66:17
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

eth1 Link encap:Ethernet HWaddr 08:00:27:08:F3:6A
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

1
2
3
4
5
6
7
# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.0.0.138 0.0.0.0 UG 0 0 0 bond0
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 bond0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 bond0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# ifconfig eth0 down

# tail /var/log/messages
bond0: link status definitely down for interface eth0, disabling it
bond0: making interface eth1 the new active one.

# ifconfig
bond0 Link encap:Ethernet HWaddr 08:00:27:08:F3:6A
inet addr:10.0.2.12 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::a00:27ff:fe43:6617/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1

eth1 Link encap:Ethernet HWaddr 08:00:27:08:F3:6A
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# ifconfig eth0 up

# ifconfig eth1 down

# tail /var/log/messages
bond0: link status definitely up for interface eth0, 4294967295 Mbps full duplex.
bond0: link status definitely down for interface eth1, disabling it
bond0: making interface eth0 the new active one.

# ifconfig
bond0 Link encap:Ethernet HWaddr 08:00:27:43:66:17
inet addr:10.0.2.12 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::a00:27ff:fe43:6617/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1

eth0 Link encap:Ethernet HWaddr 08:00:27:43:66:17
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

During the above test, the client network connection from host 10.0.0.1 (ssh) was maintained without any noticeable interruption. As it can be seen from the syslog and ifconfig command output, the bond0 interface was automatically assigned either the MAC address of eth0 or eth1 and the fail-over worked as advertised.

错误提示

Restarting network (via systemctl): Job for network.service failed. See ‘systemctl status network.service’ and ‘journalctl -xn’ for details.

解决方法

查找原因

systemctl status network.service

 cat /var/log/message |grep network
  1. Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo’
    This is generated by command ‘nmcli con load /etc/sysconfig/network-scripts/ifcfg-lo’ executed by ‘ifup’

Tadding the line “TYPE=loopback” to the file /etc/sysconfig/network-scripts/ifcfg-lo

  1. 如果是网卡
    • ip addr get mac address
    • add to /etc/sysconfig/network-scripts/ifcfg-XXXX HWADDR=XXXXXXXXXXX