| Both sides previous revision Previous revision | |
| devd [2022/09/24 13:21] – Add reference to sh(1) to clarify the use of dollar-single quotes used in devd DtxdF | devd [2022/09/26 22:19] (current) – Copyediting (4th and final installment for this run) PauAmma |
|---|
| </code> | </code> |
| |
| To understand what ''%%devd(8)%%'' does, we need to run it in the foreground instead of the background. Likewise, it is highly recommended to read ''%%/var/log/message%%'' and the output of ''%%dmesg(8)%%'' while writing and testing rules. | To understand what ''%%devd(8)%%'' does, we need to run it in the foreground instead of the background. Likewise, it is highly recommended to read ''%%/var/log/messages%%'' and the output of ''%%dmesg(8)%%'' while writing and testing rules. |
| |
| <code> | <code> |
| </code> | </code> |
| |
| The output is very descriptive. We see what ''%%devd(8)%%'' parses, which we can use for troubleshooting. It is highly recommended to run ''%%devd -d%%'' when we are creating a rule. | The output is very descriptive. We see what ''%%devd(8)%%'' parses, which we can use for troubleshooting. |
| |
| As mentioned, ''%%dmesg(8)%%'' and ''%%/var/log/messages%%'' can be our best friends. This is the output of ''%%dmesg(8)%%'' when a USB is connected: | As mentioned, ''%%dmesg(8)%%'' and ''%%/var/log/messages%%'' can be our best friends. This is the output of ''%%dmesg(8)%%'' when a USB key is connected: |
| |
| <code> | <code> |
| </code> | </code> |
| |
| When a devices matches ''%%umass0%%'', its name is printed using ''%%logger(1)%%''. We can see the message in ''%%/var/log/message%%'': | When a device matches ''%%umass0%%'', its name is printed using ''%%logger(1)%%''. We can see the message in ''%%/var/log/messages%%'': |
| |
| <code> | <code> |
| </code> | </code> |
| |
| We are already to partition: | We are ready to partition: |
| |
| <code> | <code> |
| </code> | </code> |
| |
| Here the ''%%da0%%'' device with GPT is used and unique partition is added. That partition was formatted and mounted on ''%%/mnt%%'' to write a file called ''%%hello.txt%%''. Last, the partition is unmounted. | Here the ''%%da0%%'' device with GPT is used and a single partition is added. That partition is formatted and mounted on ''%%/mnt%%'' to write a file called ''%%hello.txt%%''. Last, the partition is unmounted. |
| |
| Unplug the device and plug in it again. The label is also useful for debugging, as it will print to the ''%%devd(8)%%'' output. | Unplug the device and plug it back in. The label is also useful for debugging, as it will be printed in the ''%%devd(8)%%'' output. |
| |
| <code> | <code> |
| </code> | </code> |
| |
| When we plug in our USB, the output of ''%%devd(8)%%'' is overwhelmingly large, so using a tool like ''%%screen(1)%%'' or ''%%tmux(1)%%'' is highly recommended, as either of them have a feature called //Copy Mode// that is useful for searching the output buffer. However, traditional tools like ''%%script(1)%%'' with a pager like ''%%less(1)%%'' or ''%%more(1)%%'' can be used for this purpose. | When we plug in our USB key, ''%%devd(8)%%'' output is very large, so using a tool like ''%%screen(1)%%'' or ''%%tmux(1)%%'' is highly recommended, as both of them have a feature called //Copy Mode// that is useful for searching the output buffer. However, traditional tools like ''%%script(1)%%'' with a pager like ''%%less(1)%%'' or ''%%more(1)%%'' can be used for this purpose. |
| |
| The idea is to search in the output of ''%%devd(8)%%'' to get the exact point of the event we need. When we've done that, we need to know if the parameters that ''%%devd(8)%%'' is using are the required ones. In this example, the following parameters are relevant: | The idea is to search ''%%devd(8)%%'' output to get the exact point of the event we need. When we've done that, we need to check whether the parameters that ''%%devd(8)%%'' is using are the required ones. In this example, the following parameters are relevant: |
| |
| <code> | <code> |
| </code> | </code> |
| |
| See the "[[#Variables_and_the_notify_event|Variables and the notify event]]" for more details on those parameters. | See "[[#Variables_and_the_notify_event|Variables and the notify event]]" for more details on those parameters. |
| |
| We need to modify ''%%usb_attach.conf%%'' with the parameters described above: | We need to modify ''%%usb_attach.conf%%'' with the parameters described above: |
| </code> | </code> |
| |
| We must increase the priority and add the subsystem for ''%%urndis(4)%%''. We also set ''%%dhclient(8)%%'' to ''%%action%%'' and when our device is plugged in, we should have Internet connection automatically. | We must increase the priority and add the subsystem for ''%%urndis(4)%%''. We also set ''%%dhclient(8)%%'' to ''%%action%%'' and when our device is plugged in, we should have an Internet connection automatically. |
| |
| <code> | <code> |