{"id":348,"date":"2015-10-05T09:59:56","date_gmt":"2015-10-05T09:59:56","guid":{"rendered":"https:\/\/edulab.unitn.it\/tecnici\/?p=348"},"modified":"2015-10-05T12:11:32","modified_gmt":"2015-10-05T12:11:32","slug":"debian-usb-live-with-persistent","status":"publish","type":"post","link":"https:\/\/edulab.unitn.it\/tecnici\/debian-usb-live-with-persistent\/","title":{"rendered":"Debian usb Live with Persistent"},"content":{"rendered":"<p><a href=\"http:\/\/crunchbang.org\/forums\/viewtopic.php?id=35327\">fonte<\/a><\/p>\n<p>After several attempts to create a waldorf liveUSB with persistence I finally bumped into this post &#8220;The Correct Way for Persistence on a LiveUSB for WALDORF&#8221; by kyeshi98 [1], who I would like to thanks again for the great tips.<\/p>\n<p>I guess Kye&#8217;s guide should work fine, but I don&#8217;t use unetbootin-like programs, as I like to use fdisk and dd to deal with the partitions and copying the ISO. There&#8217;s a portuguese version [<a href=\"http:\/\/librehacks.blogspot.pt\/2014\/06\/crunchbang-11-waldorf-liveusb.html\">2<\/a>] if you prefer. So in this guide I&#8217;ll explain how:<\/p>\n<ol class=\"decimal\">\n<li>Setup the USB drive with fdisk<\/li>\n<li>&#8220;Burn&#8221; the ISO to a partition with dd<\/li>\n<li>Setup and configure the persistence<\/li>\n<li>Install GRUB2 to the USB drive<\/li>\n<li>Troubleshoot the persistence #! environment<\/li>\n<\/ol>\n<h5>ADVISE<\/h5>\n<p><em><strong>Be advised that ALL DATA on your USB drive will be erased! And be extremely careful providing the correct path for the USB drive as you might erase ALL your HARD DRIVE DATA! You&#8217;ve been advise, check twice and only run the commands when you understand what they are doing!<\/strong><\/em><\/p>\n<p>&nbsp;<\/p>\n<h5>Setup the USB drive<\/h5>\n<p><strong>Setup the partitions with fdisk<\/strong><br \/>\nI assume there is no partition on the USB drive and in this case will be a 4GB device.<\/p>\n<p><strong>fdisk<\/strong> will create two <strong>ext2<\/strong> primary partitions: one labeled <strong>persistence<\/strong>, with the boot flag on, and the size of the USB drive minus the size of the ISO (as I roundup the ISO to 1GB), in this case <strong>3GB<\/strong>; the other with the remaining <strong>1GB<\/strong> and no other special care.<\/p>\n<div class=\"codebox\">\n<pre><code>$ sudo fdisk \/dev\/sdX<\/code><\/pre>\n<\/div>\n<p><strong>n<\/strong> &#8211; create the first partition<br \/>\n<strong>p<\/strong> &#8211; indicate it will be a primary partition<br \/>\n<strong>[enter]<\/strong> &#8211; accept the start of the first partition (zero)<br \/>\n<strong>+3GB<\/strong> &#8211; size of the partition<br \/>\n<strong>a<\/strong> &#8211; activate the boot flag so it can be booted from<\/p>\n<p><strong>n<\/strong> &#8211; create the second partition<br \/>\n<strong>p<\/strong> &#8211; indicate it will be a primary partition<br \/>\n<strong>[enter]<\/strong> &#8211; accept the start of the second partition (usually safe)<br \/>\n<strong>[enter]<\/strong> &#8211; accept the ending of the second partition (usually the last one of the drive)<br \/>\n<strong>w<\/strong> &#8211; write all changes<br \/>\n<strong>q<\/strong> &#8211; exit<\/p>\n<p>&nbsp;<\/p>\n<h5>&#8220;Burn&#8221; the ISO to a partition<\/h5>\n<p>After the partition setup you should guarantee that the second partition is unmounted before &#8220;burning&#8221; the ISO.<\/p>\n<div class=\"codebox\">\n<pre><code>$ dd if=crunchbang-11-20130506-amd64.iso of=\/dev\/sdX2; sync<\/code><\/pre>\n<\/div>\n<p><em>The <\/em>sync <em>will guarantee that it finishes only after all data is written on the drive<\/em><\/p>\n<p>&nbsp;<\/p>\n<h5>Setup and configure the persistence<\/h5>\n<p><strong>Create the filesystem for persistence<\/strong><\/p>\n<div class=\"codebox\">\n<pre><code>$ mkfs.ext2 -L persistence \/dev\/sdX1<\/code><\/pre>\n<\/div>\n<p><em>This will format the first partition of the drive with an ext2 filesystem and label it <strong>persistence<\/strong><\/em><\/p>\n<p><strong>Configure the persistence<\/strong><br \/>\nUnfortunately CrunchBang is built up a very old debian live system so the official debian live documentation can&#8217;t be fully used to configure the persistence. As explained to me there was a very short period of time long ago that the debian live project used the filename &#8220;live-persistence.conf&#8221;, but that was discontinued and almost all versions use the filename &#8220;persistence.conf&#8221;.<\/p>\n<p>So to run #! CrunchBang waldorf with persistence the <strong>live-persistence.conf<\/strong> file must exist on the persistence partition. So make sure the persistence partition is mounted, usually in <strong>\/media\/persistence<\/strong>.<\/p>\n<div class=\"codebox\">\n<pre><code>$ nano \/media\/persistence\/live-persistence.conf<\/code><\/pre>\n<\/div>\n<p>In it you should define what folders should be persistence and in what manners. You should read the debian live documentation [<a href=\"http:\/\/live.debian.net\/manual\/current\/html\/live-manual.en.html#549\">3<\/a>] to get a better idea. Don&#8217;t forget that it still states the persistence configuration file as being <strong>persistence.conf<\/strong>!<\/p>\n<p>For quick and simple persistence you should add<\/p>\n<div class=\"codebox\">\n<pre><code>\/ union<\/code><\/pre>\n<\/div>\n<p><em>It&#8217;s a [slash] [space] union<\/em> stating the root filesystem <strong>\/<\/strong> will be a union of the files on the liveUSB with the files persistent on the USB drive, so each time it boots it will merge together these files.<\/p>\n<p>My live-persistence.conf is little bit different<\/p>\n<div class=\"codebox\">\n<pre><code>\/home\r\n\/opt\r\n\/boot\/grub\r\n\/etc union\r\n\/usr union\r\n\/var union\r\n\/bin union\r\n\/sbin union<\/code><\/pre>\n<\/div>\n<p>I changed it a little bit, mainly for saving some space on the drive, being able to edit the GRUB from inside the liveUSB and to get all \/home files and \/opt programs on the USB drive directly.<br \/>\nThe other folders are still in test but handled well updates, upgrades and program installations using apt-get.<br \/>\nIf you need more folders (\/root or \/srv) just add them with the union option.<\/p>\n<p>If you know more about this please contribute in the comments!<\/p>\n<h5>Install GRUB2<\/h5>\n<p>You can play a lot with grub and if you need you can check out the CrunchBang ISO configuration boot files like \/isolinux\/live.cfg.<br \/>\nAlso there&#8217;s a great deal of documentation to the GRUB2, please check the ubuntu community [<a href=\"https:\/\/help.ubuntu.com\/community\/Grub2\">4<\/a>] and the dedoimedo documentation [<a href=\"http:\/\/www.dedoimedo.com\/computers\/grub-2.html\">5<\/a>].<\/p>\n<p>Make sure the persistence partition is mounted, usually in <strong>\/media\/persistence<\/strong>.<br \/>\nTo install GRUB2, version 1.99 you should:<\/p>\n<div class=\"codebox\">\n<pre><code>$ grub-install --force --no-floppy --root-directory=\/media\/persistence \/dev\/sdX<\/code><\/pre>\n<\/div>\n<p>Next setup the menu entries with:<\/p>\n<div class=\"codebox\">\n<pre><code>$ nano \/media\/persistence\/boot\/grub\/grub.cfg<\/code><\/pre>\n<\/div>\n<p>In this case I want two menu entries: one for the <strong>persistence<\/strong> environment; and another just to start the <strong>live<\/strong> environment as a regular #! CrunchBang liveUSB.<\/p>\n<div class=\"codebox\">\n<pre><code>set timeout=5\r\nset default=0\r\n\r\nmenuentry \"#! 11 - waldorf 64bits - Persistence\" {\r\n  linux (hd0,2)\/live\/vmlinuz boot=live config persistence\r\n  initrd (hd0,2)\/live\/initrd.img\r\n}\r\n\r\nmenuentry \"#! 11 - waldorf 64bits - Live\" {\r\n  linux (hd0,2)\/live\/vmlinuz boot=live config            \r\n  initrd (hd0,2)\/live\/initrd.img\r\n}<\/code><\/pre>\n<\/div>\n<p><em>This will boot the first menu entry if no key is pressed within 5 seconds.<br \/>\nAlso the first entry launches the kernel and initrd from the second partition (hd0,2) and adds the boot flag persistence to the kernel.<br \/>\nThe second entry is used to launch the live environment as a regular waldorf liveUSB.<\/em><\/p>\n<p><strong>EDIT<\/strong><br \/>\nThis entry boots #! into <strong>install<\/strong> mode.<\/p>\n<div class=\"codebox\">\n<pre><code>menuentry \"#! 11 - waldorf 64bits - Install\" {\r\n  linux (hd0,2)\/install\/gtk\/vmlinuz video=vesa:ywrap,mtrr vga=788 file=\/cdrom\/install\/crunchbang.cfg\r\n  initrd (hd0,2)\/install\/gtk\/initrd.gz\r\n}<\/code><\/pre>\n<\/div>\n<h5>Troubleshoot the persistence environment<\/h5>\n<p><strong>Users<\/strong><br \/>\nAdd your user and remove the crunchbang user, by the way the crunchbang user has password <strong>live<\/strong>.<\/p>\n<div class=\"codebox\">\n<pre><code>$ sudo adduser user\r\n$ sudo adduser user sudo\r\n$ sudo su\r\n$ passwd<\/code><\/pre>\n<\/div>\n<p>Logout and login with your user to test if it worked.<br \/>\nNext, change the login options in the System &gt; User Login Settings to comply with your setup.<\/p>\n<p><strong>Test your persistence<\/strong><br \/>\nNow if you want you might reboot just to check everything works fine!<br \/>\nIf so just update, upgrade and install all you need!<\/p>\n<p><strong>Update and upgrade<\/strong><\/p>\n<div class=\"codebox\">\n<pre><code>$ sudo apt-get update\r\n$ sudo apt-get upgrade<\/code><\/pre>\n<\/div>\n<p><strong>UPDATE:<\/strong><br \/>\nI think it&#8217;s not possibly to delete crunchbang user as all tty terminals (accessed with CTRL+ALT+F1&#8230;F4) are always with crunchbang already logged in&#8230;<\/p>\n<p>Please comment!<br \/>\nIf you have any issues, i&#8217;ll try to help you out.<\/p>\n<p>&nbsp;<\/p>\n<h5>References<\/h5>\n[1] &#8211; <a href=\"http:\/\/crunchbang.org\/forums\/viewtopic.php?id=25489\">http:\/\/crunchbang.org\/forums\/viewtopic.php?id=25489<\/a><br \/>\n[2] &#8211; <a href=\"http:\/\/librehacks.blogspot.pt\/2014\/06\/crunchbang-11-waldorf-liveusb.html\">http:\/\/librehacks.blogspot.pt\/2014\/06\/c \u2026 veusb.html<\/a><br \/>\n[3] &#8211; <a href=\"http:\/\/live.debian.net\/manual\/current\/html\/live-manual.en.html#549\">http:\/\/live.debian.net\/manual\/current\/h \u2026 n.html#549<\/a><br \/>\n[4] &#8211; <a href=\"https:\/\/help.ubuntu.com\/community\/Grub2\">https:\/\/help.ubuntu.com\/community\/Grub2<\/a><br \/>\n[5] &#8211; <a href=\"http:\/\/www.dedoimedo.com\/computers\/grub-2.html\">http:\/\/www.dedoimedo.com\/computers\/grub-2.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>fonte After several attempts to create a waldorf liveUSB with persistence I finally bumped into this post &#8220;The Correct Way for Persistence on a LiveUSB for WALDORF&#8221; by kyeshi98 [1], [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,9],"tags":[],"class_list":["post-348","post","type-post","status-publish","format-standard","hentry","category-how-to","category-linux"],"_links":{"self":[{"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/posts\/348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/comments?post=348"}],"version-history":[{"count":1,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/posts\/348\/revisions"}],"predecessor-version":[{"id":349,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/posts\/348\/revisions\/349"}],"wp:attachment":[{"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/media?parent=348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/categories?post=348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/tags?post=348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}