<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>The Disparate Musings of Pixie</title>
  <link>https://pinterface.dreamwidth.org/</link>
  <description>The Disparate Musings of Pixie - Dreamwidth Studios</description>
  <lastBuildDate>Mon, 17 Jun 2013 04:43:39 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>pinterface</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
<item>
  <guid isPermaLink='true'>https://pinterface.dreamwidth.org/1447.html</guid>
  <pubDate>Mon, 17 Jun 2013 04:43:39 GMT</pubDate>
  <title>Making a Bootable USB Drive for Linux</title>
  <link>https://pinterface.dreamwidth.org/1447.html</link>
  <description>&lt;p&gt;Conveniently timed to &lt;a href=&quot;http://pinterface.dreamwidth.org/1276.html&quot;&gt;my previous entry&lt;/a&gt; I recently upgraded my laptop to Debian Wheezy.  This involved redoing my backup boot drive to contain bootloader updates, so I can detail the process I used.&lt;/p&gt;

&lt;h3&gt;Partition the USB drive&lt;/h3&gt;

&lt;p&gt;Use whatever partition manager you&apos;re comfortable with.  cfdisk, fdisk, gparted, whatever.&lt;/p&gt;
&lt;pre&gt;# cfdisk /dev/sdb&lt;/pre&gt;

&lt;p&gt;If you want to use the USB stick on Windows normally, note that Windows will only see the first partition of a thumbdrive.  This is great for hiding the fact it&apos;s a bootable drive!&lt;/p&gt;

&lt;pre&gt;# fdisk -lu /dev/sdb
...
Sector size (logical/physical): 512 bytes / 512 bytes
...
&lt;/pre&gt;
&lt;table border=&quot;2&quot; cellspacing=&quot;0&quot; cellpadding=&quot;6&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Device&lt;/th&gt;&lt;th&gt;Boot&lt;/th&gt;&lt;th&gt;Start&lt;/th&gt;&lt;th&gt;End&lt;/th&gt;&lt;th&gt;Blocks&lt;/th&gt;&lt;th&gt;Id&lt;/th&gt;&lt;th&gt;System&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;/dev/sdb1&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;8064&lt;/td&gt;&lt;td&gt;14259815&lt;/td&gt;&lt;td&gt;7125876&lt;/td&gt;&lt;td&gt;b&lt;/td&gt;&lt;td&gt;W95 FAT32&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;/dev/sdb2&lt;/td&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;14259816&lt;/td&gt;&lt;td&gt;15240575&lt;/td&gt;&lt;td&gt;490380&lt;/td&gt;&lt;td&gt;83&lt;/td&gt;&lt;td&gt;Linux&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Don&apos;t start the first partition at the very beginning.  Here I&apos;ve got it started about 4k in.  This gap is important: grub will install itself into the gap--if there isn&apos;t enough room, grub won&apos;t install.&lt;/p&gt;

&lt;p&gt;You&apos;ll also notice that I&apos;ve allocated 512MB to what will become /boot (sdb2).  This is serious overkill, but also means I don&apos;t have to be particularly cautious about uninstalling old kernel versions to avoid running out of room.&lt;/p&gt;

&lt;h3&gt;Format the Partitions&lt;/h3&gt;


&lt;p&gt;Naturally, we should format these partitions:&lt;/p&gt;
&lt;pre&gt;# mkfs -t vfat /dev/sdb1
# mkfs -t ext3 /dev/sdb2&lt;/pre&gt;

&lt;h3&gt;Install grub&lt;/h3&gt;

&lt;p&gt;Then mount our soon-to-be /boot drive into /boot (if you&apos;re familiar with grub-install, you can mount it elsewhere):&lt;/p&gt;

&lt;pre&gt;# mount /dev/sdb2 /boot&lt;/pre&gt;

&lt;p&gt;And install grub:&lt;/p&gt;

&lt;pre&gt;# grub-install /dev/sdb&lt;/pre&gt;

&lt;p&gt;Naturally, your next step should be to &lt;em&gt;test&lt;/em&gt; that it boots.  And maybe even test that it appears as a normal thumbdrive on a Windows computer.&lt;/p&gt;

&lt;h3&gt;When Doing a Fresh Install&lt;/h3&gt;

&lt;p&gt;NB: This is from-memory.  I have not done this recently.&lt;/p&gt;

&lt;p&gt;If you&apos;re doing a fresh install, partition the USB drive from another computer.  Make sure the thumbdrive is plugged in during the install process, and when configuring drive partitions and directory locations, simply select /dev/sdb2 (or whichever is appropriate for the USB drive&apos;s second partition) as the device on to which to put /boot.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=pinterface&amp;ditemid=1447&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://pinterface.dreamwidth.org/1447.html</comments>
  <category>infrequent processes</category>
  <category>linux</category>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://pinterface.dreamwidth.org/1276.html</guid>
  <pubDate>Sat, 11 May 2013 04:03:46 GMT</pubDate>
  <title>Upgrading the Linux Kernel when Using a USB Boot Disk</title>
  <link>https://pinterface.dreamwidth.org/1276.html</link>
  <description>&lt;p&gt;In order to protect any sensitive data on my work laptop, I use full-drive encryption.  To aid recovery in case of theft, it normally boots to a honeypot installation of Windows with Prey installed.  To boot into Linux, one must use a USB boot disk&lt;a href=&quot;#kernel-update-usb-disk-footnote-1&quot;&gt;[1]&lt;/a&gt; which contains the contents of /boot.&lt;/p&gt;

&lt;p&gt;Once in a while, it is necessary to upgrade the kernel.  I don&apos;t do this very often, so it seems like the sort of process which should be documented.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mount /boot read-write: &lt;code&gt;`mount -o rw /boot`&lt;/code&gt;&lt;br&gt;
I generally have /boot mounted read-only, in part because I don&apos;t usually
have the thumbdrive plugged in (I don&apos;t boot very often, after all), and
to ensure I don&apos;t accidentally make changes to it without being prepared
to undergo this full process.&lt;/li&gt;
&lt;li&gt;Install kernel updates: &lt;code&gt;`sudo aptitude full-upgrade`&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Reboot.  Pray it works.&lt;/li&gt;
&lt;li&gt;Insert backup boot disk.  (Just in case the thumbdrive on my keychain goes bad or gets lost.)&lt;/li&gt;
&lt;li&gt;Copy files from the updated boot disk to the backup: &lt;code&gt;`rsync -av /boot /media/usb2`&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Remove the original boot disk.  This will help prevent unfortunate mistakes.&lt;/li&gt;
&lt;li&gt;Alter grub.cfg of backup boot disk to refer to the proper UUID:
&lt;code&gt;`sudo sed -i s/$UUID_OF_BOOT/$UUID_OF_BACKUP/ grub/grub.cfg`&lt;/code&gt;&lt;br&gt;
&lt;code&gt;`blkid`&lt;/code&gt; comes in handy for finding the relevant UUIDs.&lt;/li&gt;
&lt;li&gt;Reboot.  Pray it works.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Assuming both boot disks successfully boot the machine with the updated kernel, congratulations!  You have successfully updated the kernel!&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;kernel-update-usb-disk-footnote-1&quot;&gt;&lt;/a&gt;[1] It&apos;s not quite as much a waste of a thumbdrive as you might think.  The sticks have a FAT partition of ~90% or so of the advertised capacity, so they can still be used to transfer files between computers or for data storage.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=pinterface&amp;ditemid=1276&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://pinterface.dreamwidth.org/1276.html</comments>
  <category>work</category>
  <category>infrequent processes</category>
  <category>linux</category>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
</channel>
</rss>
