{"id":564,"date":"2016-01-20T22:59:03","date_gmt":"2016-01-20T22:59:03","guid":{"rendered":"http:\/\/blog.paranoidprofessor.com\/?p=564"},"modified":"2016-01-20T22:59:52","modified_gmt":"2016-01-20T22:59:52","slug":"booting-linux-from-a-usb-stick","status":"publish","type":"post","link":"https:\/\/blog.paranoidprofessor.com\/index.php\/2016\/01\/20\/booting-linux-from-a-usb-stick\/","title":{"rendered":"booting Linux from a USB stick"},"content":{"rendered":"<p>Most of the Linux distributions are downloadable as a ISO image which can be burned to a CD or DVD.\u00a0 This is pretty convenient, download the distribution and create your own disks.<\/p>\n<p>In the beginning floppy disks were used by everyone to transport data or install software.\u00a0 Once the software was too big to fit, the floppy disks started to disappear and everyone moved to CD&#8217;s and DVD&#8217;s.\u00a0 The same thing is now happening to the once so familiar CD and DVD drives.<\/p>\n<p>They haven&#8217;t really been replaced by the much larger blue ray discs but have instead been replaced by fast network connections and USB sticks as USB sticks are small, fast, have no moving parts, and fit into your pocket.<\/p>\n<p>In order to retain all of the same functionality, it became important to be able to use the USB sticks in the same way as the DVD.\u00a0 USB sticks exceed the size of the disc&#8217;s without breaking a sweat.\u00a0 The only missing piece was bootable USB sticks.<\/p>\n<p>This was solved with the introduction of the isohybrid feature.\u00a0 This is a reasonably small modification to the boot record, that allows USB sticks to be booted from BIOS just like a CD or DVD.\u00a0\u00a0 A few years ago if you wanted to get a Linux distribution to boot from the USB stick you had to run programs to make the conversion to your distribution and then copy it to the USB stick.<\/p>\n<p>Now it is pretty common that a lot of Linux distributions when they create their ISO images already have this isohybrid format, especially the live discs.<\/p>\n<p>There is virtually no effort involved to take one of these images and get it to boot off of a USB stick.\u00a0 A single command will transfer the image.<\/p>\n<p><em><strong>dd if=myimage.iso of=\/dev\/sdX bs=1mb<\/strong><\/em><\/p>\n<p>This command will copy the image byte for byte over to the device \/dev\/sdX.<\/p>\n<p>It is really important to make sure you give the proper device otherwise, you may be overwriting your main hard disk with the ISO image.\u00a0 There are probably a lot of methods to determine what the device is, I either look at the logs with the dmesg command or the devices connected with the lsblk.<\/p>\n<p><strong>Log messages<\/strong><\/p>\n<pre><code>&gt; dmesg\r\n [ 5624.106378] usb 3-2: new high-speed USB device number 3 using xhci_hcd\r\n [ 5624.234666] usb 3-2: New USB device found, idVendor=05dc, idProduct=0300\r\n [ 5624.234672] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3\r\n [ 5624.234675] usb 3-2: Product: JUMPDRIVE GEYSR\r\n [ 5624.234678] usb 3-2: Manufacturer:<strong> LEXAR MEDIA<\/strong>\r\n [ 5624.234680] usb 3-2: SerialNumber: 0A4EEC090022451\r\n [ 5625.037188] usb-storage 3-2:1.0: <strong>USB Mass Storage device detected<\/strong>\r\n [ 5625.037382] scsi6 : usb-storage 3-2:1.0\r\n [ 5625.037549] usbcore: registered new interface driver usb-storage\r\n [ 5626.033751] scsi 6:0:0:0: Direct-Access\u00a0\u00a0\u00a0\u00a0 LEXAR\u00a0\u00a0\u00a0 GEYSER JUMPDRIVE 1.00 PQ: 0 ANSI: 1 CCS\r\n [ 5626.034308] sd 6:0:0:0: Attached scsi generic sg3 type 0\r\n [ 5626.034387] sd 6:0:0:0: [<strong>sdc<\/strong>] 2014992 512-byte logical blocks: (1.03 GB\/983 MiB)\r\n [ 5626.034935] sd 6:0:0:0: [<strong>sdc<\/strong>] Write Protect is off\r\n [ 5626.034952] sd 6:0:0:0: [<strong>sdc<\/strong>] Mode Sense: 23 00 00 00\r\n [ 5626.035486] sd 6:0:0:0: [<strong>sdc<\/strong>] No Caching mode page found\r\n [ 5626.035491] sd 6:0:0:0: [<strong>sdc<\/strong>] Assuming drive cache: write through\r\n [ 5626.038184]\u00a0 <strong>sdc: sdc1<\/strong>\r\n [ 5626.039933] sd 6:0:0:0: [<strong>sdc<\/strong>] Attached SCSI removable disk\r\n [ 5629.732887] FAT-fs (sdc1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!\r\n [ 5629.743731] FAT-fs (sdc1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.\r\n<\/code><\/pre>\n<p>Simply run the dmesg command and then do it again after plugging in the USB stick.<\/p>\n<p><strong>List of block devices<\/strong><\/p>\n<pre><code>&gt; lsblk\r\n NAME\u00a0\u00a0 MAJ:MIN RM\u00a0\u00a0 SIZE RO TYPE MOUNTPOINT\r\n sda\u00a0\u00a0\u00a0\u00a0\u00a0 8:0\u00a0\u00a0\u00a0 0 698.7G\u00a0 0 disk\r\n \u251c\u2500sda1\u00a0\u00a0 8:1\u00a0\u00a0\u00a0 0\u00a0\u00a0 200M\u00a0 0 part \/boot\/efi\r\n \u251c\u2500sda2\u00a0\u00a0 8:2\u00a0\u00a0\u00a0 0\u00a0\u00a0 128M\u00a0 0 part\r\n \u251c\u2500sda3\u00a0\u00a0 8:3\u00a0\u00a0\u00a0 0 279.5G\u00a0 0 part\r\n \u251c\u2500sda4\u00a0\u00a0 8:4\u00a0\u00a0\u00a0 0 393.9G\u00a0 0 part \/\r\n \u2514\u2500sda5\u00a0\u00a0 8:5\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 25G\u00a0 0 part\r\n sdb\u00a0\u00a0\u00a0\u00a0\u00a0 8:16\u00a0\u00a0 0 698.7G\u00a0 0 disk\r\n \u251c\u2500sdb1\u00a0\u00a0 8:17\u00a0\u00a0 0\u00a0\u00a0 9.5G\u00a0 0 part [SWAP]\r\n \u251c\u2500sdb2\u00a0\u00a0 8:18\u00a0\u00a0 0\u00a0 46.6G\u00a0 0 part\r\n \u251c\u2500sdb3\u00a0\u00a0 8:19\u00a0\u00a0 0\u00a0 50.2G\u00a0 0 part\r\n \u251c\u2500sdb4\u00a0\u00a0 8:20\u00a0\u00a0 0 451.8G\u00a0 0 part\r\n \u251c\u2500sdb5\u00a0\u00a0 8:21\u00a0\u00a0 0\u00a0 47.5G\u00a0 0 part\r\n \u2514\u2500sdb6\u00a0\u00a0 8:22\u00a0\u00a0 0\u00a0 93.1G\u00a0 0 part \/home\r\n<strong> sdc\u00a0\u00a0\u00a0\u00a0\u00a0 8:32\u00a0\u00a0 1 983.9M\u00a0 0 disk<\/strong>\r\n<strong> \u2514\u2500sdc1\u00a0\u00a0 8:33\u00a0\u00a0 1 983.4M\u00a0 0 part \/media\/dock\/LEXAR MEDIA<\/strong>\r\n sr0\u00a0\u00a0\u00a0\u00a0 11:0\u00a0\u00a0\u00a0 1\u00a0 1024M\u00a0 0 rom\r\n<\/code><\/pre>\n<p>Both of these methods let us know that there is a device \/dev\/sdc and that device has a single partition.<\/p>\n<p>In my latest case, I used the following command.<\/p>\n<p><em><strong>&gt; dd if=debian-8.2.0-i386-netinst.iso of=\/dev\/sdc bs=1m<\/strong><\/em><br \/>\n<em><strong> &gt; sync<\/strong><\/em><\/p>\n<p>The command sync has nothing to do with the copy but simply ensures that all I\/O buffers are flushed.\u00a0 This guarantees that the data is written out to the device.\u00a0 This shouldn&#8217;t be necessary but it is a good practice to get into.<\/p>\n<p><strong>Don&#8217;t make the mistake of writing the ISO image to the device&#8217;s partition.\u00a0 The boot record is at the beginning of the ISO image and must in the same location of the USB device otherwise the computer will not recognize the operating system and will hang.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most of the Linux distributions are downloadable as a ISO image which can be burned to a CD or DVD.\u00a0 This is pretty convenient, download the distribution and create your own disks. In the beginning floppy disks were used by &hellip; <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2016\/01\/20\/booting-linux-from-a-usb-stick\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,3],"tags":[26,17],"_links":{"self":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/564"}],"collection":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/comments?post=564"}],"version-history":[{"count":3,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/564\/revisions"}],"predecessor-version":[{"id":567,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/564\/revisions\/567"}],"wp:attachment":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/media?parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/categories?post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/tags?post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}