Template:ChooseADevice
<onlyinclude>{{#ifeq:{{SanitiseBoolean|{{{Header|1}}}}}|1| Typing the wrong device name can destroy all information on your hard disk, so follow these instructions to select the right device name: }} {{#ifeq:{{SanitiseBoolean|{{{Body|1}}}}}|1|{{#ifeq:{{SanitiseBoolean|{{{Script|1}}}}}|1| <syntaxhighlight lang="shell"> # Make sure your device is disconnected or turned off, then do: ls /dev/disk/by-id/* | grep -v -- '-part[0-9]*$' | tee /tmp/disks.txt # Make sure your device is connected and powered up, then do: ls /dev/disk/by-id/* | grep -v -- '-part[0-9]*$' | diff /tmp/disks.txt - # You should see something like: # 10a11 # > /dev/disk/by-id/<identifier-of-your-disk> # Make a variable with the device from the previous command: TARGET_DEVICE=/dev/disk/by-id/<identifier-of-your-disk> # Check you typed it correctly by reading one byte from the disk: sudo head -c1 "$TARGET_DEVICE" > /dev/null # Disconnect your device, then try again: sudo head -c1 "$TARGET_DEVICE" > /dev/null </syntaxhighlight> }} {{#ifeq:{{SanitiseBoolean|{{{Explanation|1}}}}}|1| If you did everything right, the <kbd>head</kbd> command should only work when the device is plugged in. You can now use <kbd>$TARGET_DEVICE</kbd> instead of the name of your device in future commands. }} }} {{#ifeq:{{SanitiseBoolean|{{{Footer|1}}}}}|1| The instructions below often refer to <kbd>$TARGET_DEVICE</kbd>. If you create a variable as described above, you can paste those exact instructions. Otherwise, change <kbd>$TARGET_DEVICE</kbd> to your actual device name. }}</onlyinclude>
A fairly safe procedure to select a disk, intended for use in HOWTO guides
Parameter | Description | Type | Status | |
---|---|---|---|---|
Header | Header | Whether to include the header section
| Boolean | optional |
Body | Body | Whether to include the body section
| Boolean | optional |
Script | Script | Whether to include the script subsection (top half of the body section)
| Boolean | optional |
Explanation | Explanation | Whether to include the explanation subsection (bottom half of the body section)
| Boolean | optional |
Footer | Footer | Whether to include the footer section
| Boolean | optional |
Pages sometimes need to ask the user to specify the filename for a physical device, e.g. to reformat that device. Getting this wrong can corrupt the user's hard disk, so this page provides a fairly safe procedure to select the disk.
This template instructs the user to create a variable called $TARGET_DEVICE. If you change the rest of your page to say e.g. some-command $TARGET_DEVICE instead of e.g. some-command /path/to/your/device, readers will be able to directly copy/paste your instructions.