Connect via USB Networking in the Initramfs

From postmarketOS
(Redirected from Boot process)
Jump to: navigation, search

Power on your device and connect it to your USB port. pmOS uses the USB interface as a network interface and runs a DHCP server on it and dmesg will show something like

[ 6284.442088] usb 1-1: new high-speed USB device number 36 using xhci_hcd
[ 6284.627106] usb 1-1: New USB device found, idVendor=18d1, idProduct=d001
[ 6284.627123] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 6284.627134] usb 1-1: Product: Android
[ 6284.627143] usb 1-1: Manufacturer: Android
[ 6284.627151] usb 1-1: SerialNumber: 0123456789ABCDEF
[ 6284.632322] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:00:14.0-1, RNDIS device, b2:c4:1e:03:64:b9
[ 6285.239048] rndis_host 1-1:1.0 enp0s20f0u1: renamed from usb0
[ 6285.287058] IPv6: ADDRCONF(NETDEV_UP): enp0s20f0u1: link is not ready

And you'll have a new interface with IP in the range 172.16.42.0/24

$ ifconfig enp0s20f0u1
enp0s20f0u1 Link encap:Ethernet  HWaddr b2:c4:1e:03:64:b9  
          inet addr:172.16.42.107  Bcast:172.16.42.255  Mask:255.255.255.0
          inet6 addr: fe80::dbd2:4531:89f2:d2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1226 (1.2 KB)  TX bytes:8375 (8.3 KB)

It the interface doesn't automatically get an IP address on your system (for example on systems without NetworkManager) you need to start a dhcp client to get one.

# Replace the interface name with the one on your machine
# Some Linux distributions have "dhcpcd" installed instead of "dhclient"
$ dhclient -v enp0s20f0u1

If this fails, you may need to first assign an ethernet address to it:

# ip l set enp0s20f0u1 address 12:12:12:12:12:12

Then you can try the above dhclient command.

When your device is still in the initramfs (that's where it shows the keyboard to unlock the device when full disk encryption is enabled), you can connect via telnet now (make sure the last segment of the IP address is a "1" and not what is shown in the output of ifconfig!).

telnet 172.16.42.1 24
Trying 172.16.42.1...
Connected to 172.16.42.1.
Escape character is '^]'.

If you are already past the initramfs, you should be able to connect via ssh and the password you set during the install phase:

$ ssh user@172.16.42.1
user@172.16.42.1's password: 
Welcome to postmarketOS!

This distribution is based on Alpine Linux.
Read both our wikis to find a large amount of how-to guides and
general information about administrating and development.
See <https://postmarketos.org/wiki> and <https://wiki.alpinelinux.org>.

You may change this message by editing /etc/motd.

localhost:~$

Use sudo to run commands as root, it is configured.

See also