<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2012-03-19:1579314</id>
  <title>The Disparate Musings of Pixie</title>
  <subtitle>pinterface</subtitle>
  <author>
    <name>pinterface</name>
  </author>
  <link rel="alternate" type="text/html" href="https://pinterface.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://pinterface.dreamwidth.org/data/atom"/>
  <updated>2013-06-17T04:43:39Z</updated>
  <dw:journal username="pinterface" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2012-03-19:1579314:1447</id>
    <link rel="alternate" type="text/html" href="https://pinterface.dreamwidth.org/1447.html"/>
    <link rel="self" type="text/xml" href="https://pinterface.dreamwidth.org/data/atom/?itemid=1447"/>
    <title>Making a Bootable USB Drive for Linux</title>
    <published>2013-06-17T04:43:39Z</published>
    <updated>2013-06-17T04:43:39Z</updated>
    <category term="linux"/>
    <category term="infrequent processes"/>
    <dw:security>public</dw:security>
    <dw:reply-count>2</dw:reply-count>
    <content type="html">&lt;p&gt;Conveniently timed to &lt;a href="http://pinterface.dreamwidth.org/1276.html"&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'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'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="2" cellspacing="0" cellpadding="6"&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't start the first partition at the very beginning.  Here I've got it started about 4k in.  This gap is important: grub will install itself into the gap--if there isn't enough room, grub won't install.&lt;/p&gt;

&lt;p&gt;You'll also notice that I've allocated 512MB to what will become /boot (sdb2).  This is serious overkill, but also means I don'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'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'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's second partition) as the device on to which to put /boot.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=pinterface&amp;ditemid=1447" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2012-03-19:1579314:1276</id>
    <link rel="alternate" type="text/html" href="https://pinterface.dreamwidth.org/1276.html"/>
    <link rel="self" type="text/xml" href="https://pinterface.dreamwidth.org/data/atom/?itemid=1276"/>
    <title>Upgrading the Linux Kernel when Using a USB Boot Disk</title>
    <published>2013-05-11T04:03:46Z</published>
    <updated>2013-05-11T04:03:46Z</updated>
    <category term="work"/>
    <category term="linux"/>
    <category term="infrequent processes"/>
    <dw:security>public</dw:security>
    <dw:reply-count>3</dw:reply-count>
    <content type="html">&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="#kernel-update-usb-disk-footnote-1"&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'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't usually
have the thumbdrive plugged in (I don't boot very often, after all), and
to ensure I don'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="kernel-update-usb-disk-footnote-1"&gt;&lt;/a&gt;[1] It'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="https://www.dreamwidth.org/tools/commentcount?user=pinterface&amp;ditemid=1276" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
