Re: Quick and dirty debian live on USB stick.
On Sat, Nov 28, 2009 at 05:19:56PM EST, Chris Jones wrote: I'm playing with the idea of copying my laptop's debian lenny partition to a USB stick that I can take with me when traveling. Since I can't be sure I'll have a machine with available space on the HDD or be allowed to partition the drive, what I thought was that I could have a bootable system on the USB stick and boot into it pretty much as I would off of a live CD. What I had in mind was as simple as: . clone the lenny partition to /dev/sda1 . install grub to /dev/sda . make adjustments to the contents of /dev/sda1 The trouble is that I don't have a machine that can boot off of a USB stick to test ahead of time. Adjustments that I had in mind: . /etc/fstab . /boot/grub/menu.lst (grub.cfg with grub2) Naturally, reconfiguring network internet access, Xorg, printers, etc. will be necessary, but they cannot be done ahead of time - although it may be possible to make it less of a pain with some preparation and a bit of scripting. Since I'm running the stock lenny kernel, I shouldn't have problems with differences in hardware, but I'm a little concerned that udev might not cooperate. I'm sure there are other issues, but unfortunately, I can't take the trial and error approach. So, I was wondering if anyone had done anything comparable, and would care to point out possible gotchas? I now have-a-proof of concept system on the USB stick and have been able to boot into it by doing the following: 1. Power up the laptop 2. On the grub2 menu, hit 'c' to escape to a shell of sorts and load the USB modules: insmod uhci¹ insmod usbms The light on the USB stick should come on telling you it's alive 3. Escape back to the grub menu and Ctrl+X to boot a stanza with something like the following: search --no-floppy --fs-uuid --set fb796a23-e59e-4e15-ba92-15f0cd087714 linux /boot/vmlinuz-2.6.26-1-686 root=UUID=fb796a23-e59e-4e15-ba92-15f0cd087714 ro initrd /boot/initrd.img-2.6.26-1-686 where the UUID was determined by: # vol_id --uuid /dev/sda1# blkid on more recent systems Since I'm running it on the same hardware as the cloned system, it wasn't too hard, network, X, etc. came up with no problems, just very slowly, since on top of the thumb drive's limitations, the laptop only supports USB 1.1. The challenges that I see now are getting rid of any customization specific to my laptop and come up with something generic that will boot on just about any machine, and set it up so that personal data is clearly separated from the software and configuration files. After that, it's just only a matter of writing a couple of trivial rsync scripts to keep the data on the HDD and the USB stick in sync'. Kinda boils down to what Rob Owens initially recommended after all.. Thanks to those who have responded. CJ ¹ There is a bug in grub2 that can be worked around by issuing a 'debug=uhci,ohci,usbms' command jut before issuing the insmod uhci, and resetting it immediately afterwards by issuing a 'debug=' -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
On Wed, Dec 02, 2009 at 08:48:49PM -0500, Stefan Monnier wrote: I guess the better way is to read (and digest) whatever udev doc is available and run enough tests, possibly with differenty hardware, and get an in-depth understanding of how it really works. I understand just fine how it works: when the network interface is discovered (typically at boot), udev is asked to choose a name for that interface. And /etc/udev/rules.d/75-persistent-net-generator.rules then saves the result as a new rule in /etc/udev/rules.d/70-persistent-net.rules that associates that interface's MAC address with the name that was chosen. There are 2 consequences: 1- next time this interface is found, the same name will be used (good). 2- when another interface is found, another name will be chosen: not so good, when you use your install on many different machines, since then each machine's interface will get a different interface name, even though they'll never be present at the same time. So I use a boot-time rule which erases /etc/udev/rules.d/70-persistent-net.rules so the name is chosen anew each time (and will basically always be eth0). Except for wireless interfaces, which I've seen labeled as ethX, wlanX, raX, etc. -Rob -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
I guess the better way is to read (and digest) whatever udev doc is available and run enough tests, possibly with differenty hardware, and get an in-depth understanding of how it really works. I understand just fine how it works: when the network interface is discovered (typically at boot), udev is asked to choose a name for that interface. And /etc/udev/rules.d/75-persistent-net-generator.rules then saves the result as a new rule in /etc/udev/rules.d/70-persistent-net.rules that associates that interface's MAC address with the name that was chosen. There are 2 consequences: 1- next time this interface is found, the same name will be used (good). 2- when another interface is found, another name will be chosen: not so good, when you use your install on many different machines, since then each machine's interface will get a different interface name, even though they'll never be present at the same time. So I use a boot-time rule which erases /etc/udev/rules.d/70-persistent-net.rules so the name is chosen anew each time (and will basically always be eth0). Except for wireless interfaces, which I've seen labeled as ethX, wlanX, raX, etc. That's another issue: the base name is provided by the driver. Most drivers included in the vanilla kernel use wlanX nowadays, but older ones or drivers provided from elsewhere (or not yet well-integrated) often use other names. For that I added a udev file /etc/udev/rules.d/10-monnier.rules that overrides the default names. I've used rules like: kernel==eth*, SUBSYSTEM==net, DRIVERS==ipw3945, NAME=wlan0 kernel==ath*, SUBSYSTEM==net, DRIVERS==madwifi, NAME=wlan0 -- Stefan -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
I guess the better way is to read (and digest) whatever udev doc is available and run enough tests, possibly with differenty hardware, and get an in-depth understanding of how it really works. I understand just fine how it works: when the network interface is discovered (typically at boot), udev is asked to choose a name for that interface. And /etc/udev/rules.d/75-persistent-net-generator.rules then saves the result as a new rule in /etc/udev/rules.d/70-persistent-net.rules that associates that interface's MAC address with the name that was chosen. There are 2 consequences: 1- next time this interface is found, the same name will be used (good). 2- when another interface is found, another name will be chosen: not so good, when you use your install on many different machines, since then each machine's interface will get a different interface name, even though they'll never be present at the same time. So I use a boot-time rule which erases /etc/udev/rules.d/70-persistent-net.rules so the name is chosen anew each time (and will basically always be eth0). Same for the cdrom drive names. Stefan -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
On Wed, Dec 02, 2009 at 08:48:49PM EST, Stefan Monnier wrote: I guess the better way is to read (and digest) whatever udev doc is available and run enough tests, possibly with differenty hardware, and get an in-depth understanding of how it really works. I understand just fine how it works: when the network interface is discovered (typically at boot), udev is asked to choose a name for that interface. And /etc/udev/rules.d/75-persistent-net-generator.rules then saves the result as a new rule in /etc/udev/rules.d/70-persistent-net.rules that associates that interface's MAC address with the name that was chosen. There are 2 consequences: 1- next time this interface is found, the same name will be used (good). 2- when another interface is found, another name will be chosen: not so good, when you use your install on many different machines, since then each machine's interface will get a different interface name, even though they'll never be present at the same time. So I use a boot-time rule which erases /etc/udev/rules.d/70-persistent-net.rules so the name is chosen anew each time (and will basically always be eth0). Same for the cdrom drive names. Crystal-clear. Thanks for doing my homework for me :-) CJ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
On Tue, Dec 01, 2009 at 01:30:43AM -0500, Chris Jones wrote: On Mon, Nov 30, 2009 at 09:45:11AM EST, Stefan Monnier wrote: I'm playing with the idea of copying my laptop's debian lenny partition to a USB stick that I can take with me when traveling. I have a Live USB Debian system that follows this idea (i.e. it's just a plain normal Debian install, except it works off of a USB stick). . clone the lenny partition to /dev/sda1 . install grub to /dev/sda . make adjustments to the contents of /dev/sda1 The trouble is that I don't have a machine that can boot off of a USB stick to test ahead of time. You can do some of the tests by putting the vmlinuz and initrd.img on your harddrive and telling them to mount / from the USB stick. Good point - I guess simply adding an entry to grub.cfg with the UUID of my root partition on the the USB stick should do it. I guess the only thing that I won't be able to test will be grub on the USB stick. Probably wise to bring a rescue CD along first time around. That will already help you figure out some of the tricky things (e.g. how to specify the right device to use to mount the USB stick: either use partition labels, UUIDs, or use LVM volumes). I'll definitely use the UUID. Since I'm running the stock lenny kernel, I shouldn't have problems with differences in hardware, but I'm a little concerned that udev might not cooperate. The only typical problems are things like the /etc/udev/rules.d/70-persistent-* files, so every time you use your system on a new machine, the new ethernet device will appear under a new name (eth0, eth1, eth2, ...). You can solve it by adding a script which removes those files at boot. Well, I guess that since my pcmcia nic won't be there on the target system(s), I should remove the corresponding udev rule for instance. What does udev do in this respect, anyway? Probe the system at startup and set up the devices for the hardware it detects? So I guess the rules need to be cleaned up every time you know you are using a given system for the last time? You could try deleting the file that creates the persistent network interfaces: /etc/udev/rules.d/75-persistent-net-generator.rules (on my Lenny system, anyway) I'm not sure what negative side-effects there might be, but I did this on my Debian-Live system so that my wired interface would always be eth0. It seems to work, but I'm sure there's a better way. -Rob -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
On Tue, Dec 01, 2009 at 08:35:49PM EST, Rob Owens wrote: On Tue, Dec 01, 2009 at 01:30:43AM -0500, Chris Jones wrote: [..] So I guess the rules need to be cleaned up every time you know you are using a given system for the last time? You could try deleting the file that creates the persistent network interfaces: /etc/udev/rules.d/75-persistent-net-generator.rules (on my Lenny system, anyway) I'm not sure what negative side-effects there might be, but I did this on my Debian-Live system so that my wired interface would always be eth0. It seems to work, but I'm sure there's a better way. I guess the better way is to read (and digest) whatever udev doc is available and run enough tests, possibly with differenty hardware, and get an in-depth understanding of how it really works. Unfortunately, this is hardly compatible with the QND approach :-) Thanks, CJ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
I'm playing with the idea of copying my laptop's debian lenny partition to a USB stick that I can take with me when traveling. I have a Live USB Debian system that follows this idea (i.e. it's just a plain normal Debian install, except it works off of a USB stick). . clone the lenny partition to /dev/sda1 . install grub to /dev/sda . make adjustments to the contents of /dev/sda1 The trouble is that I don't have a machine that can boot off of a USB stick to test ahead of time. You can do some of the tests by putting the vmlinuz and initrd.img on your harddrive and telling them to mount / from the USB stick. That will already help you figure out some of the tricky things (e.g. how to specify the right device to use to mount the USB stick: either use partition labels, UUIDs, or use LVM volumes). Since I'm running the stock lenny kernel, I shouldn't have problems with differences in hardware, but I'm a little concerned that udev might not cooperate. The only typical problems are things like the /etc/udev/rules.d/70-persistent-* files, so every time you use your system on a new machine, the new ethernet device will appear under a new name (eth0, eth1, eth2, ...). You can solve it by adding a script which removes those files at boot. I'm sure there are other issues, but unfortunately, I can't take the trial and error approach. In my case the main issue was space, so I ended up using a jffs2 install (the only compressing file-system back then), which is inefficient and inconvenient. But even with today's large sticks, space will probably still be an issue. So you may want to keep /var/cache/apt on tmpfs (and add mkdir -p /var/cache/apt/lists to /etc/rc.local), for example (I even keep /var/lib/apt on tmpfs as well, but that's mostly because these files can't be on jffs2 because jffs2 doesn't support mmapping files). Also you may want to avoid log files. For that I use busybox's syslogd with the following script: # cat /etc/init.d/syslog-busybox #!/bin/sh ### BEGIN INIT INFO # Provides: sysklogd # Required-Start: $remote_fs $time # Required-Stop:$remote_fs $time # Should-Start: $network # Should-Stop: $network # Default-Start:2 3 4 5 # Default-Stop: 0 1 6 # Short-Description:System logger ### END INIT INFO case $1 in start ) echo -n Starting Busybox syslog: if busybox syslogd -C16; then echo -n syslogd; else echo -n !syslogd!; fi if busybox klogd; then echo -n klogd; else echo -n !kogd!; fi echo . ;; esac # you can then read your logs (which are kept in a cyclic buffer in memory) with busybox logread, or just logread if you first create a symlink ln -s busybox /bin/logread. Stefan -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
On Mon, Nov 30, 2009 at 09:45:11AM EST, Stefan Monnier wrote: I'm playing with the idea of copying my laptop's debian lenny partition to a USB stick that I can take with me when traveling. I have a Live USB Debian system that follows this idea (i.e. it's just a plain normal Debian install, except it works off of a USB stick). . clone the lenny partition to /dev/sda1 . install grub to /dev/sda . make adjustments to the contents of /dev/sda1 The trouble is that I don't have a machine that can boot off of a USB stick to test ahead of time. You can do some of the tests by putting the vmlinuz and initrd.img on your harddrive and telling them to mount / from the USB stick. Good point - I guess simply adding an entry to grub.cfg with the UUID of my root partition on the the USB stick should do it. I guess the only thing that I won't be able to test will be grub on the USB stick. Probably wise to bring a rescue CD along first time around. That will already help you figure out some of the tricky things (e.g. how to specify the right device to use to mount the USB stick: either use partition labels, UUIDs, or use LVM volumes). I'll definitely use the UUID. Since I'm running the stock lenny kernel, I shouldn't have problems with differences in hardware, but I'm a little concerned that udev might not cooperate. The only typical problems are things like the /etc/udev/rules.d/70-persistent-* files, so every time you use your system on a new machine, the new ethernet device will appear under a new name (eth0, eth1, eth2, ...). You can solve it by adding a script which removes those files at boot. Well, I guess that since my pcmcia nic won't be there on the target system(s), I should remove the corresponding udev rule for instance. What does udev do in this respect, anyway? Probe the system at startup and set up the devices for the hardware it detects? So I guess the rules need to be cleaned up every time you know you are using a given system for the last time? I'm sure there are other issues, but unfortunately, I can't take the trial and error approach. In my case the main issue was space, so I ended up using a jffs2 install (the only compressing file-system back then), which is inefficient and inconvenient. But even with today's large sticks, space will probably still be an issue. So you may want to keep /var/cache/apt on tmpfs (and add mkdir -p /var/cache/apt/lists to /etc/rc.local), for example (I even keep /var/lib/apt on tmpfs as well, but that's mostly because these files can't be on jffs2 because jffs2 doesn't support mmapping files). Also you may want to avoid log files. For that I use busybox's syslogd with the following script: # cat /etc/init.d/syslog-busybox #!/bin/sh ### BEGIN INIT INFO # Provides: sysklogd # Required-Start: $remote_fs $time # Required-Stop:$remote_fs $time # Should-Start: $network # Should-Stop: $network # Default-Start:2 3 4 5 # Default-Stop: 0 1 6 # Short-Description:System logger ### END INIT INFO case $1 in start ) echo -n Starting Busybox syslog: if busybox syslogd -C16; then echo -n syslogd; else echo -n !syslogd!; fi if busybox klogd; then echo -n klogd; else echo -n !kogd!; fi echo . ;; esac # you can then read your logs (which are kept in a cyclic buffer in memory) with busybox logread, or just logread if you first create a symlink ln -s busybox /bin/logread. It's an 8G stick, 7.4GB as computed by df -h, and my partition is 5.9GB, so I should be OK. Thanks for confirming feasability. CJ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
On Sat, Nov 28, 2009 at 08:59:21PM EST, Rob Owens wrote: On Sat, Nov 28, 2009 at 05:19:56PM -0500, Chris Jones wrote: I'm playing with the idea of copying my laptop's debian lenny partition to a USB stick that I can take with me when traveling. Since I can't be sure I'll have a machine with available space on the HDD or be allowed to partition the drive, what I thought was that I could have a bootable system on the USB stick and boot into it pretty much as I would off of a live CD. [..] I'm not sure that what you're planning won't work, but if I were you I'd do it like this: Create a live USB system (see my instructions in the live cd/usb projects thread). Install all the same software as your current laptop ha. Then transfer over your data. What I had in mind was more like a bootable backup. I tried Debian Live before and it does not do that. IIRC, ubuntu has something that does this, but I don't remember the name right now, and it probably would not work for a debian system. Supposedly you can test your USB image using Qemu, although I've never done it myself. http://live.debian.net/manual/html/ch03s03.html#id2911160 I tried qemu when I was trying to get Debian Live to work but all it did was it went to 100% and stayed there doing nothing. I didn't have the time to investigate, but I have a feeling you need more RAM than I have to run a VM under qemu - just to boot one, even. Thanks, CJ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
Rob Owens wrote: On Sat, Nov 28, 2009 at 05:19:56PM -0500, Chris Jones wrote: I'm playing with the idea of copying my laptop's debian lenny partition to a USB stick that I can take with me when traveling. Since I can't be sure I'll have a machine with available space on the HDD or be allowed to partition the drive, what I thought was that I could have a bootable system on the USB stick and boot into it pretty much as I would off of a live CD. What I had in mind was as simple as: . clone the lenny partition to /dev/sda1 . install grub to /dev/sda . make adjustments to the contents of /dev/sda1 The trouble is that I don't have a machine that can boot off of a USB stick to test ahead of time. I'm not sure that what you're planning won't work, but if I were you I'd do it like this: Create a live USB system (see my instructions in the live cd/usb projects thread). Install all the same software as your current laptop ha. Then transfer over your data. Supposedly you can test your USB image using Qemu, although I've never done it myself. http://live.debian.net/manual/html/ch03s03.html#id2911160 -Rob Hm, not necessary to install from scratch. Just copy over to the usb and put in fstab and relevant files (grub,etc) the disk id instead of /dev/sda (you need udev for this), so you can be sure to use the same device no matter which id it sd id it gets assigned to. recreate initrd and possibly hack it. For me I needed to add manually command for inserting dm-mod and triggering vgscan/vgchange on a crypted partition with lvm. After playing a bit I managed it to get a working initrd. It's all mater of initrd to get it running. A major issue is that there are different machines on around with different chipsets cpus etc, so you'll need more generic kernel and drivers ... may be 386 to be sure it will run on each system, or get some 386, 586 and 686. regards -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
On Sun, Nov 29, 2009 at 07:00:55PM EST, Emanoil Kotsev wrote: [..] Hm, not necessary to install from scratch. Just copy over to the usb and put in fstab and relevant files (grub,etc) the disk id instead of /dev/sda (you need udev for this), so you can be sure to use the same device no matter which id it sd id it gets assigned to. Good point: UUID= in /etc/fstab and grub.cfg recreate initrd and possibly hack it. I don't see why at this point, but that's the problem when you cannot test. I already have a custom initrd and recreating it is not going to make any difference. Actually, since I can't get qemu to work, I'm thinking of copying the system on the USB stick to a DVD and see if I can boot off of that. If it doesn't it could mean different things, but if it does boot then I'll know that the USB stick is problably going to do likewise. For me I needed to add manually command for inserting dm-mod and triggering vgscan/vgchange on a crypted partition with lvm. After playing a bit I managed it to get a working initrd. It's all mater of initrd to get it running. A major issue is that there are different machines on around with different chipsets cpus etc, so you'll need more generic kernel and drivers ... may be 386 to be sure it will run on each system, or get some 386, 586 and 686. Good point, although machines that can boot off of a USB device are likely to be fairly recent and should be happy with a 686 kernel. Thanks for you comments. CJ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Quick and dirty debian live on USB stick.
I'm playing with the idea of copying my laptop's debian lenny partition to a USB stick that I can take with me when traveling. Since I can't be sure I'll have a machine with available space on the HDD or be allowed to partition the drive, what I thought was that I could have a bootable system on the USB stick and boot into it pretty much as I would off of a live CD. What I had in mind was as simple as: . clone the lenny partition to /dev/sda1 . install grub to /dev/sda . make adjustments to the contents of /dev/sda1 The trouble is that I don't have a machine that can boot off of a USB stick to test ahead of time. Adjustments that I had in mind: . /etc/fstab . /boot/grub/menu.lst (grub.cfg with grub2) Naturally, reconfiguring network internet access, Xorg, printers, etc. will be necessary, but they cannot be done ahead of time - although it may be possible to make it less of a pain with some preparation and a bit of scripting. Since I'm running the stock lenny kernel, I shouldn't have problems with differences in hardware, but I'm a little concerned that udev might not cooperate. I'm sure there are other issues, but unfortunately, I can't take the trial and error approach. So, I was wondering if anyone had done anything comparable, and would care to point out possible gotchas? Thanks, CJ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Re: Quick and dirty debian live on USB stick.
On Sat, Nov 28, 2009 at 05:19:56PM -0500, Chris Jones wrote: I'm playing with the idea of copying my laptop's debian lenny partition to a USB stick that I can take with me when traveling. Since I can't be sure I'll have a machine with available space on the HDD or be allowed to partition the drive, what I thought was that I could have a bootable system on the USB stick and boot into it pretty much as I would off of a live CD. What I had in mind was as simple as: . clone the lenny partition to /dev/sda1 . install grub to /dev/sda . make adjustments to the contents of /dev/sda1 The trouble is that I don't have a machine that can boot off of a USB stick to test ahead of time. I'm not sure that what you're planning won't work, but if I were you I'd do it like this: Create a live USB system (see my instructions in the live cd/usb projects thread). Install all the same software as your current laptop ha. Then transfer over your data. Supposedly you can test your USB image using Qemu, although I've never done it myself. http://live.debian.net/manual/html/ch03s03.html#id2911160 -Rob -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org