[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Network setup by installer



On Fri 19 Jan 2018 at 19:09:27 (+0000), Brian wrote:
> On Sat 20 Jan 2018 at 03:25:00 +0900, Mark Fletcher wrote:
> > On Fri, Jan 19, 2018 at 02:33:23PM +0000, Brian wrote:
> > > On Fri 19 Jan 2018 at 22:10:39 +0900, Mark Fletcher wrote:
> > > > So, I return to the essential question, which I led with in my original 
> > > > post, which is which method does the installer use to set up networking, 
> > > > and where can I find documentation on that so I can replicate it for my 
> > > > wireless connection?
> > > 
> > > The installer uses the netcfg udeb to configure networking; the files in
> > > the package are the documentation (AFAIK). For a wired connection netcfg
> > > produces a file /etc/network/interfaces for use with the installer which
> > > is something like
> > > 
> > >  allow-hotplug enp0s25
> > >  iface enp0s25 inet dhcp
> > > 
> > > This file is transferred to the new system (mounted on /target) just
> > > before d-i finishes and booting into the new system takes place.
> > > 
> > > If you had chosen to install over a wifi connection, interfaces would
> > > have looked like this:
> > > 
> > >  allow-hotplug wlx0060b3f580c4
> > >  iface wlx0060b3f580c4 inet dhcp
> > >        wpa-ssid <access_point>
> > >        wpa-psk  <secret>
> > > 
> > > I would preseed the installer to replace the interfaces file it puts on
> > > /target with this file. Any firmware for the wireless adaptor would also
> > > have to be transferred to /target/lib/firmware too.
> > > 
> > > A fly in the ointment is the desktop you install (if any). If it brings
> > > in network-manager (MATE does) there is a possibility that there is no
> > > network at first boot.
> > > 
> > 
> > Thank you Brian -- this is exactly the information I was after. Much 
> > appreciated, once again!
> > 
> > To get out of the situation I'm in on those two machines, I just need to 
> > hand-craft the interfaces file to something like what you have above, 
> > with appropriate device, ssid and WPA password values substituted. For 
> > these PARTICULAR systems, firmware doesn't seem to be a problem.
> 
> That's about it. The transferring of the interfaces file takes place in
> a late_command. I've not tried it myself but it should work and I intend
> to have a go tomorrow.

OK, I've revisited this problem because what I read here runs counter
to my observations, so I've double checked.

I installed netinst 9.3 amd64 through the wireless interface. I ran
the installer through the ssh interface, and in parallel I ran a shells
on both the installee (wren) and installer (west).
(Yes, I have all the best words.)

The installee has /etc/network/interfaces set up by the time you ask
to install remotely (obviously, or you couldn't do it). Nothing else
interesting there until the installation is complete. From the
installer, you can observe:

/target appears after the partitioning step. Its interfaces file
appears after the base system is installed:

--✄--------

~ # ls -l /target/etc/network/
drwxr-xr-x    2 root     root          4096 Jan 31 15:10 if-down.d
drwxr-xr-x    2 root     root          4096 Jan 31 15:10 if-post-down.d
drwxr-xr-x    2 root     root          4096 Jan 31 15:10 if-pre-up.d
drwxr-xr-x    2 root     root          4096 Jan 31 15:10 if-up.d
-rw-r--r--    1 root     root           361 Jan 31 15:10 interfaces
drwxr-xr-x    2 root     root          4096 Jan 30  2017 interfaces.d
~ # cat /target/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug wlp2s0
iface wlp2s0 inet dhcp
        wpa-ssid deleted
        wpa-psk  deleted
~ # # base system just installed
~ #

--✄--------

All is still in place before the last keystroke of installation:

--✄--------

~ # cat /target/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug wlp2s0
iface wlp2s0 inet dhcp
        wpa-ssid deleted
        wpa-psk  deleted
~ # # about to eject
~ # tail /var/log/syslog 
Jan 31 15:26:46 clock-setup: 1517412406.500000 is close enough to 1517412406.500000 (0.000000 < 0.001000)
Jan 31 15:26:46 clock-setup: Set RTC to 1517412406 (1517412406 + 0; refsystime = 1517412406.000000)
Jan 31 15:26:46 clock-setup: Setting Hardware Clock to 15:26:46 = 1517412406 seconds since 1969
Jan 31 15:26:46 clock-setup: ioctl(RTC_SET_TIME) was successful.
Jan 31 15:26:46 clock-setup: Not adjusting drift factor because the --update-drift option was not used.
Jan 31 15:26:46 finish-install: info: Running /usr/lib/finish-install.d/10open-iscsi
Jan 31 15:26:46 finish-install: info: Running /usr/lib/finish-install.d/10update-initramfs
Jan 31 15:26:47 finish-install: info: Running /usr/lib/finish-install.d/15cdrom-detect
Jan 31 15:26:47 cdrom-detect: Unmounting and ejecting '/dev/sdb1'
Jan 31 15:26:47 finish-install: info: Running /usr/lib/finish-install.d/20final-message
~ # Connection to wren closed by remote host.
Connection to wren closed.
255 west!david 09:27:43 ~ $ exit

Script done on Wed 31 Jan 2018 09:27:47 CST

--✄--------

So now I login on wren (sda6) and see what's been left in sda7 (installee):

--✄--------

$ cat /wrenbk/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback
$ ls -lR /wrenbk/etc/network/
/wrenbk/etc/network/:
total 24
drwxr-xr-x 2 root root 4096 Jan 31 09:18 if-down.d
drwxr-xr-x 2 root root 4096 Jan 31 09:16 if-post-down.d
drwxr-xr-x 2 root root 4096 Jan 31 09:10 if-pre-up.d
drwxr-xr-x 2 root root 4096 Jan 31 09:18 if-up.d
-rw-r--r-- 1 root root  240 Jan 31 09:27 interfaces
drwxr-xr-x 2 root root 4096 Jan 30  2017 interfaces.d

/wrenbk/etc/network/if-down.d:
total 8
-rwxr-xr-x 1 root root 1015 Jan 23  2017 avahi-autoipd
-rwxr-xr-x 1 root root  332 Jun  2  2015 upstart
lrwxrwxrwx 1 root root   32 Oct 14 07:18 wpasupplicant -> ../../wpa_supplicant/ifupdown.sh

/wrenbk/etc/network/if-post-down.d:
total 4
lrwxrwxrwx 1 root root   23 Jan 23  2017 avahi-daemon -> ../if-up.d/avahi-daemon
-rwxr-xr-x 1 root root 1409 Mar 24  2016 wireless-tools
lrwxrwxrwx 1 root root   32 Oct 14 07:18 wpasupplicant -> ../../wpa_supplicant/ifupdown.sh

/wrenbk/etc/network/if-pre-up.d:
total 8
-rwxr-xr-x 1 root root 4178 Mar 24  2016 wireless-tools
lrwxrwxrwx 1 root root   32 Oct 14 07:18 wpasupplicant -> ../../wpa_supplicant/ifupdown.sh

/wrenbk/etc/network/if-up.d:
total 16
-rwxr-xr-x 1 root root  923 Jan 23  2017 avahi-autoipd
-rwxr-xr-x 1 root root  484 Jan 23  2017 avahi-daemon
-rwxr-xr-x 1 root root  972 Oct 17 03:56 openssh-server
-rwxr-xr-x 1 root root 1483 Jun  2  2015 upstart
lrwxrwxrwx 1 root root   32 Oct 14 07:18 wpasupplicant -> ../../wpa_supplicant/ifupdown.sh

/wrenbk/etc/network/interfaces.d:
total 0
$ ls -l --full-time /wrenbk/etc/network/interfaces
-rw-r--r-- 1 root root 240 2018-01-31 09:27:42.141512647 -0600 /wrenbk/etc/network/interfaces
$ 

--✄--------

No sign of the wireless interface. The file was tampered with after
the hwclock was set (Jan 31 15:26:46 clock-setup) and moments before
the ssh shell disconnected (255 west!david 09:27:43 ~ $ ). Here's
the culprit, which seems to be excited about its dirty work:

--✄--------

Jan 31 15:26:47 finish-install: info: Running /usr/lib/finish-install.d/15cdrom-detect
Jan 31 15:26:47 cdrom-detect: Unmounting and ejecting '/dev/sdb1'
Jan 31 15:26:47 finish-install: info: Running /usr/lib/finish-install.d/20final-message
Jan 31 15:27:41 finish-install: info: Running /usr/lib/finish-install.d/30hw-detect
Jan 31 15:27:41 finish-install: info: Running /usr/lib/finish-install.d/50config-target-network
Jan 31 15:27:41 finish-install: info: Running /usr/lib/finish-install.d/55netcfg-copy-config
Jan 31 15:27:42 netcfg[30956]: INFO: Starting netcfg v.1.143
Jan 31 15:27:42 netcfg[30956]: DEBUG: No interface given; clearing /etc/network/interfaces
Jan 31 15:27:42 netcfg[30956]: DEBUG: Writing informative header
Jan 31 15:27:42 netcfg[30956]: DEBUG: Success!
Jan 31 15:27:42 netcfg[30956]: DEBUG: Writing loopback interface
Jan 31 15:27:42 netcfg[30956]: DEBUG: Success!
Jan 31 15:27:42 finish-install: info: Running /usr/lib/finish-install.d/60cleanup
Jan 31 15:27:42 finish-install: info: Running /usr/lib/finish-install.d/65partman-md
Jan 31 15:27:42 finish-install: info: Running /usr/lib/finish-install.d/70mtab
Jan 31 15:27:42 finish-install: info: Running /usr/lib/finish-install.d/90base-installer
Jan 31 15:27:42 finish-install: info: Running /usr/lib/finish-install.d/90console
Jan 31 15:27:42 finish-install: info: Running /usr/lib/finish-install.d/94random-seed
Jan 31 15:27:42 finish-install: info: Running /usr/lib/finish-install.d/94save-logs
/wrenbk/var/log/installer/syslog ll.5925-5961/5961 end

--✄--------

Cheers,
David.


Reply to: