You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
11 KiB
HTML

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tasks of the Contingent Librarian</title>
<link rel="stylesheet" type="text/css" href="tasks.css">
<script src="tasks.js"></script>
</head>
<body>
<div class="cardback"><DOCUMENT_FRAGMENT><div class="mw-parser-output"><div class="thumb tright"><div class="thumbinner" style="width:152px;"><a class="image" href="https://pzwiki.wdka.nl/mw-mediadesign/images/thumb/0/03/USB_drives_as_libraries.jpeg/960px-USB_drives_as_libraries.jpeg"><img alt="" class="thumbimage" decoding="async" src="https://pzwiki.wdka.nl/mw-mediadesign/images/thumb/0/03/USB_drives_as_libraries.jpeg/320px-USB_drives_as_libraries.jpeg"></a> <div class="thumbcaption"><div class="magnify"><a class="internal" href="File:USB_drives_as_libraries.jpeg.html" title="Enlarge"></a></div>USB drives as libraries</div></div></div>
<div class="toc" id="toc"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"><div class="toctitle" dir="ltr" lang="en"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
<ul>
<li class="toclevel-1"><a href="#Auto-mount_an_external_drive_on_boot"><span class="tocnumber">1</span> <span class="toctext">Auto-mount an external drive on boot</span></a>
<ul>
<li class="toclevel-2"><a href="#Step_1_.E2.80.93_Plug_In_The_Device"><span class="tocnumber">1.1</span> <span class="toctext">Step 1 Plug In The Device</span></a></li>
<li class="toclevel-2"><a href="#Step_2_.E2.80.93_Identify_The_Device.27s_Unique_ID"><span class="tocnumber">1.2</span> <span class="toctext">Step 2 Identify The Device's Unique ID</span></a></li>
<li class="toclevel-2"><a href="#Step_3_.E2.80.93_Create_a_Mount_Point"><span class="tocnumber">1.3</span> <span class="toctext">Step 3 Create a Mount Point</span></a></li>
<li class="toclevel-2"><a href="#Step_4_.E2.80.93_Manually_Mount_The_Drive"><span class="tocnumber">1.4</span> <span class="toctext">Step 4 Manually Mount The Drive</span></a></li>
<li class="toclevel-2"><a href="#Step_5_.E2.80.93_Un-mounting_The_Drive"><span class="tocnumber">1.5</span> <span class="toctext">Step 5 Un-mounting The Drive</span></a></li>
<li class="toclevel-2"><a href="#Step_6_.E2.80.93_Auto_Mount"><span class="tocnumber">1.6</span> <span class="toctext">Step 6 Auto Mount</span></a></li>
<li class="toclevel-2"><a href="#An_Extra_Note_About_File_Systems"><span class="tocnumber">1.7</span> <span class="toctext">An Extra Note About File Systems</span></a></li>
<li class="toclevel-2"><a href="#Final_Thoughts"><span class="tocnumber">1.8</span> <span class="toctext">Final Thoughts</span></a></li>
</ul>
</li>
</ul>
</div>
<h3><span class="mw-headline" id="Auto-mount_an_external_drive_on_boot">Auto-mount an external drive on boot</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-1" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<h4><span id="Step_1__Plug_In_The_Device"></span><span class="mw-headline" id="Step_1_.E2.80.93_Plug_In_The_Device">Step 1 Plug In The Device</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-2" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<h4><span id="Step_2__Identify_The_Device's_Unique_ID"></span><span class="mw-headline" id="Step_2_.E2.80.93_Identify_The_Device.27s_Unique_ID">Step 2 Identify The Device's Unique ID</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-3" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<p>In order to find the unique reference (UUID) for your drive run the following command in the terminal :
</p><p><code>ls -l /dev/disk/by-uuid/</code>
</p><p>This will give you an output that should list your drive :
</p><p><a class="image" href="https://pzwiki.wdka.nl/mw-mediadesign/images/thumb/a/ae/Bootleg_uuid.png/960px-Bootleg_uuid.png"><img alt="Bootleg uuid.png" decoding="async" src="https://pzwiki.wdka.nl/mw-mediadesign/images/thumb/a/ae/Bootleg_uuid.png/320px-Bootleg_uuid.png"></a>
</p><p>The line will usually refer to “/sda” and in this example it is “sda1”. My ID is “989B-E900”. Note down yours.
You would need to repeat this step if you wanted to use a different device as the UUID would be different.
</p>
<h4><span id="Step_3__Create_a_Mount_Point"></span><span class="mw-headline" id="Step_3_.E2.80.93_Create_a_Mount_Point">Step 3 Create a Mount Point</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-4" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<p>A mount point is a directory that will point to the contents of your flash drive. Create a suitable folder :
</p><p><code>sudo mkdir /media/usb</code>
</p><p>Im using “usb” but you can give it whatever name you like. Keep it short as it saves typing later on. Now we need to make sure the Pi user owns this folder :
</p><p><code>sudo chown -R pi:pi /media/usb</code>
</p><p>You will only need to do this step once.
</p>
<h4><span id="Step_4__Manually_Mount_The_Drive"></span><span class="mw-headline" id="Step_4_.E2.80.93_Manually_Mount_The_Drive">Step 4 Manually Mount The Drive</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-5" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<p>To manually mount the drive use the following command :
</p><p><code>sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi</code>
</p><p><br>
This will mount the drive so that the ordinary Pi user can write to it. Omitting the “-o uid=pi,gid=pi” would mean you could only write to it using “sudo”.
Now you can read, write and delete files using “/media/usb” as a destination or source without needing to use sudo.
</p>
<h4><span id="Step_5__Un-mounting_The_Drive"></span><span class="mw-headline" id="Step_5_.E2.80.93_Un-mounting_The_Drive">Step 5 Un-mounting The Drive</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-6" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<p>You dont need to manually un-mount if you shutdown your Pi but if you need to remove the drive at any other time you should un-mount it first. Only the user that mounted the drive can un-mount it.
</p><p><code>umount /media/usb</code>
</p><p>If you used the fstab file to auto-mount it you will need to use :
</p><p><code>sudo umount /media/usb</code>
</p><p>If you are paying attention you will notice the command is “<i>u</i>mount” NOT “<i>un</i>mount”!
</p>
<h4><span id="Step_6__Auto_Mount"></span><span class="mw-headline" id="Step_6_.E2.80.93_Auto_Mount">Step 6 Auto Mount</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-7" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<p>When you restart your Pi your mounts will be lost and you will need to repeat Step 4. If you want your USB drive to be mounted when the system starts you can edit the fstab file :
</p><p><code>sudo nano /etc/fstab</code>
</p><p>Then add the following line at the end :
</p><p><code>UUID=989B-E900 /media/usb vfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0</code>
</p><p>The “nofail” option allows the boot process to proceed if the drive is not plugged in. The “noatime” option stops the file access time being updated every time a file is read from the USB stick. This helps improve performance.
This is what my fstab file looks like:
</p><p><a class="image" href="https://pzwiki.wdka.nl/mw-mediadesign/images/thumb/7/70/Bootleg_fstab.png/960px-Bootleg_fstab.png"><img alt="Bootleg fstab.png" decoding="async" src="https://pzwiki.wdka.nl/mw-mediadesign/images/thumb/7/70/Bootleg_fstab.png/320px-Bootleg_fstab.png"></a>
</p><p>Make sure you set the correct UUID. Use CTRL-X followed by Y to save and exit the nano editor.
</p><p>Now reboot :
</p><p><code>sudo reboot</code>
</p><p>Your USB drive should be auto-mounted and available as “/media/usb”.
</p>
<h4><span class="mw-headline" id="An_Extra_Note_About_File_Systems">An Extra Note About File Systems</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-8" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<p>In the examples above I specified “vfat” as the file system of the device as it was formatted as FAT32. If you need to change the file system replace references of “vfat” with “ntfs-3g”, “ext3” or “ext4”.
If you are using NTFS you will also need to install the following package :
</p><p><code>sudo apt-get install ntfs-3g</code>
</p>
<h4><span class="mw-headline" id="Final_Thoughts">Final Thoughts</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&amp;action=edit&amp;section=T-9" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<p>This technique suits my applications but the main disadvantage is that it is specific to a known USB device given we are using the device ID. However if you created a few mount points in advance you could manually mount a new device to a spare mount point without worrying about updating the fstab file.
</p>
<!--
NewPP limit report
Cached time: 20200620130725
Cache expiry: 86400
Dynamic content: false
CPU time usage: 0.013 seconds
Real time usage: 0.015 seconds
Preprocessor visited node count: 12/1000000
Preprocessor generated node count: 32/1000000
Postexpand include size: 3863/2097152 bytes
Template argument size: 0/2097152 bytes
Highest expansion depth: 2/40
Expensive parser function count: 0/100
Unstrip recursion depth: 0/20
Unstrip postexpand size: 0/5000000 bytes
-->
<!--
Transclusion expansion time report (%,ms,calls,template)
100.00% 1.709 1 User:Simon/Trim4/prototypes/automount_a_drive_on_boot
100.00% 1.709 1 -total
-->
<!-- Saved in parser cache with key wdka_mw_mediadesign-mw_:pcache:idhash:31738-0!canonical and timestamp 20200620130725 and revision id 175125
-->
</div></DOCUMENT_FRAGMENT></div>
</body>
</html>