17 March 2013

361. Installing Debian on a USB stick (from a running Debian system)

Post 70 (Installing Debian on a USB stick -- live usb vs a true and full installation) is receiving a lot of traffic. While the method of installing debian used there -- using virtualbox -- works, it is slow and unnecessarily complex.

A better, faster and easier way is to use a chroot. Sure, it's a bit more command line oriented, but that doesn't necessarily make it harder.
You'll need an empty USB stick. Some sticks are faster than others, but they are all slower than spinning disks, and a lot slower than SSDs (never tried a USB3 stick though).

1. Prepare the USB stick
Attach the USB stick to a computer with Debian. Find out what device it is (do ls /dev/sd* before and after attaching the stick, and if it automounts, you can also check the output of df -h). In this case we'll assume that it's /dev/sdb.


sudo apt-get install util-linux e2fsprogs
sudo umount /dev/sdb*
sudo fdisk /dev/sdb
Command (m for help): o
Building a new DOS disklabel with disk identifier 0x209d6329.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdb: 4051 MB, 4051697664 bytes
125 heads, 62 sectors/track, 1021 cylinders, total 7913472 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x209d6329

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-7913471, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-7913471, default 7913471): 
Using default value 7913471

Command (m for help): a                                                                               
Partition number (1-4): 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

It really is that simple to set up the partition table. o wipes the previous table, n creates a new partition, and a makes it bootable. w writes the changes. Now prepare the file system:

sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.5 (29-Jul-2012) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 247504 inodes, 988928 blocks 49446 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1015021568 31 block groups 32768 blocks per group, 32768 fragments per group 7984 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done
2. Mount and bootstrap the USB stick

Note that you can change between i386 and amd64, testing and stable and different mirrors, by editing the debootstrap line below. I'd recommend i386 since it will run on 64 bit machines as well, which is useful if you're traveling.

sudo apt-get install debootstrap coreutils
mkdir ~/tmp/usbstick -p
sudo mount /dev/sdb1 ~/tmp/usbstick
sudo debootstrap --arch i386 testing $HOME/tmp/usbstick http://ftp.au.debian.org/debian/
I: Retrieving InRelease I: Checking Release signature I: Valid Release signature (key id 9FED2BCBDCD29CDF762678CBAED4B06F473041FA) I: Retrieving Packages [..] I: Configuring tasksel... I: Configuring tasksel-data... I: Base system installed successfully.

sudo mount -t proc none $HOME/tmp/usbstick/proc
sudo mount --bind /sys $HOME/tmp/usbstick/sys
sudo mount --bind /dev $HOME/tmp/usbstick/dev
sudo cp /etc/resolv.conf $HOME/tmp/usbstick/resolv.conf
sudo chroot $HOME/tmp/usbstick/

3. Basic setup

Edit the sources.list line as needed. The key is to enable non-free so you can install all the non-free firmware so that youre prepared for most types of hardware.

rm /etc/apt/sources.list
echo 'deb  http://ftp.au.debian.org/debian/ testing main contrib non-free' >> /etc/apt/sources.list
apt-get update
apt-get install locales sudo vim
echo 'export LC_ALL="C"'>>/etc/bash.bashrc
echo 'export LANG="C"'>>/etc/bash.bashrc
echo '127.0.0.1 usbstick >> /etc/hosts'
source /etc/bash.bashrc
useradd -m traveller
passwd traveller
usermod -G sudo -a traveller

If you're going to travel with this, you may want to install AIDE to make sure that you're executables haven't been changed (you can also use tripwire). Of course, if anyone has the ability to regenerate the database, then this won't help you.
apt-get install aide

You will have to wait with generating the database until you're properly booted from the USB stick.

4. Make the usbstick bootable
Make sure to install grub to /dev/sdb so that you don't mess up your desktop.

grep -v rootfs /proc/mounts > /etc/mtab
sudo apt-get install grub-pc linux-base linux-image-3.2.0-4-686-pae


You need to set up your /etc/fstab:
blkid /dev/sdb1 -o export|head -n 1 > /etc/fstab

Edit /etc/fstab (your UUID will vary):
UUID=24056f3d-d0c5-4297-adc4-40b2d2007412       /       ext4    errors=remount-ro,user_xattr    0 1

Run
update-grub
Generating grub.cfg ... Found linux image: /boot/vmlinuz-3.2.0-4-686-pae Found initrd image: /boot/initrd.img-3.2.0-4-686-pae done

At this point you've used ca 559 Mb.

5. Installing command line tools
The following installs a curses-based network connection manager, a mail program, a chat program and a browser. All of them work in the terminal:
sudo apt-get install wicd-curses mutt mcabber elinks rcconf

You've now used ca 670 Mb.

To set up Mutt and Mcabber, see here: http://verahill.blogspot.com.au/2011/12/configuring-mutt-for-two-imap-accounts.html
http://verahill.blogspot.com.au/2011/12/linux-basics-google-talk-using-gajim-or.html

6. Installing a desktop
This is luckily very easy. The bad thing is that USB sticks are very slow, so starting a heavy desktop from a USB stick is going to lead to long boot times.

To install gnome (2340 Mb) do
sudo apt-get install gnome rcconf

To install lxde (523 Mb) do
sudo apt-get install lxde rcconf

and to install xfce (457 Mb) do
sudo apt-get install xfce4 rcconf

We installed rcconf to prevent network-manager to start if it has been installed:
Run
rcconf
And unstar whatever you don't want to launch at boot.
To reduce boot times, edit /etc/default/grub and change to
GRUB_CMDLINE_LINUX_DEFAULT="quiet text"
Run
update-grub

You will now have to start whatever desktop you installed manually by running
startx

from the command line i.e. you only start the desktop if you really need it.

Clean your cache to free up some space:

apt-get clean

With xfce4 and cleaning, you've now used a total of 951 Mb.

7. Pull in some extra firmware
In case you'll be using this usb stick on random computers you might want to pull in as many different firmware as you can stomach:
apt-get install firmware-atheros firmware-iwlwifi firmware-ralink firmware-realtek

And so on.
You might also want to install programs such as clamav , but that's your business.

8. Unmounting your usbstick
Once you've installed everything you need:
exit
sudo umount $HOME/tmp/usbstick/sys
sudo umount $HOME/tmp/usbstick/dev
sudo umount $HOME/tmp/usbstick/proc
sudo umount $HOME/tmp/usbstick/

Now you should be able to boot from the USB stick on any computer that supports boot from USB -- and that would be most boxes made in the past five years or so.

Done.


Note that you can generate initramfs manually in debian using
sudo mkinitramfs -o /boot/initrd.img-VER -v VER

where VER e.g. 3.8.0 or 3.2.0-4-amd64 -- the name should be consistent with the vmlinuz, config and system.map suffixes.

Links to this post:
http://atomowki.net/dokuwiki/doku.php
http://andrewgudgel.com/cl-debian-usb.htm

64 comments:

  1. can you use it on another distros that is debian-based like Ubuntu or Knoppix?

    ReplyDelete
    Replies
    1. As host or as target?

      You can use this exact approach on any distro with debootstrap.

      You can even install RHEL clones from debian this way:
      http://verahill.blogspot.com.au/2013/03/359-installing-scientific-linux-centos.html

      It's also not too different from the standard installation approach in arch: http://verahill.blogspot.com.au/2013/02/330-installing-archlinux-installing.html

      Delete
    2. Then,what should be changed when creating on other distros with debootstrap? I think when on Ubuntu, part 2 and 6 should be changed and changed for ubuntu's repository and part 6 should be ubuntu-desktop, kubuntu-desktop,etc. Part 3 and part 7 can be ignored as ubuntu has less restrictions than debian on hardwares.

      Delete
    3. If you are installing another linux distro, then it depends.
      If you are installing another debian-based distro, then simply change the repos.

      If you are installing a complete different distro (different package manager), then see e.g.
      http://verahill.blogspot.com.au/2013/03/359-installing-scientific-linux-centos.html
      http://verahill.blogspot.com.au/2013/02/331-full-linux-install-on-usb-stick.html

      To avoid confusion: if you are installing debian FROM e.g. ubuntu, you use the debian repos i.e. it is the target distro that dictates the choice of repos.

      This, however, isn't true: "as ubuntu has less restrictions than debian on hardwares."

      The difference is that non-free isn't enabled by default. That's it.

      Delete
  2. Should I reboot once or more when the creation of this?

    ReplyDelete
  3. Then what version? testing or stable or both?
    The last question means that I have done on the same way but it reloaded to the hard drive instead. I really checked that it was /dev/sdb.

    ReplyDelete
    Replies
    1. Is testing/stable referring to the host system or the system you are creating?

      Anyway, if you could describe what problems you are facing in more detail I may be able to help you. From what I understand you have followed everything verbatim in this post but when you boot from the USB and load GRUB from the usb stick, it only shows you the linux distros on the hard drive? What messages did you get when you install grub?

      Or have you made any changes to the steps described in this post? If so, could you describe them in detail?

      Delete
    2. Anyway, you should change to 486 kernel as Debian 7 now use a pae kernel(physical address extension) for 686 cpus.

      Delete
    3. Furthermore, the KDE desktop is not available in this tutorial. this means that no qt tools are used, but some GTK+ tools. some people like KDE for default, isn't it?

      Delete
    4. 1. it's because of pae I suggest 686 above. Why in your opinion is this a bad thing?

      2. Installing KDE can be done similar to what is shown above, e.g.
      sudo apt-get install kde-standard
      However, there are a lot of different KDE option (-standard, -core, -full) and I rather wouldn't recommend one over the other since I'm not that familiar with KDE. Anyone interested in KDE is presumable savvy enough to figure it out on their own. Likewise I don't mention xmonad, E17 etc.

      Delete
    5. 1.When you are traveling with this, 486 kernel is recommended for best compatibility. Why this is a bad thing is that even the newer PCs can't boot from that because of the lack of RAM.
      2.Nobody is trying to figure out with KDE. Furthermore, I need other DEs like Razor-Qt or something. I need a smaller piece.

      Delete
    6. 1. Agreed. Very old hardware won't support pae.
      http://forums.linuxmint.com/viewtopic.php?f=141&t=76911

      2. You can always look at how the desktops are set up in the minimal distros like DSL (http://www.damnsmalllinux.org/). Google will show you other options.

      Or do without a WM and just run X11.

      Delete
  4. mafro,
    thanks for the suggestion.

    ReplyDelete
  5. Hi, I cannot get past the grub install for this. It fails with:
    grub-probe: error: cannot find a device for / (is /dev mounted?).
    grub-probe: error: cannot find a device for /boot (is /dev mounted?).
    grub-probe: error: cannot find a device for /boot/grub (is /dev mounted?).
    Even thought I definitely mounted dev in step 2.
    Thanks
    Luke

    ReplyDelete
    Replies
    1. What do
      df -h
      and
      ls /dev
      return?

      Delete
    2. From googling around:

      First look at this post (hakcenter's post): http://forums.gentoo.org/viewtopic-t-911076-view-next.html?sid=39c3a15002533e9ae3383b034f24ac1d

      If nothing else work you can do this:
      http://edoceo.com/notabene/grub-probe-error-cannot-find-device-for-root ?

      Delete
    3. root@OpenMediaVault:/# df -h
      df: `/lib/init/rw': No such file or directory
      df: `/media/55940ca8-f14e-48a2-82a4-6100fd7b038c': No such file or directory
      df: `/media/01CD562CF699B270': No such file or directory
      df: `/home/ftp/FTP': No such file or directory
      df: `/export/Complete': No such file or directory
      df: `/var/lib/nfs/rpc_pipefs': No such file or directory
      df: `/root/tmp/usbstick': No such file or directory
      Filesystem Size Used Avail Use% Mounted on
      none 1001M 268K 1001M 1% /dev
      none 1001M 268K 1001M 1% /dev/pts
      /dev/disk/by-uuid/ef7ee6a9-f4bc-470d-8963-531721d02464 1006M 424M 583M 43% /
      tmpfs 1001M 268K 1001M 1% /dev/shm
      /dev/sda6 1006M 424M 583M 43% /boot
      tmpfs 1006M 424M 583M 43% /tmp
      none 1001M 268K 1001M 1% /dev
      none 1001M 268K 1001M 1% /dev

      root@OpenMediaVault:/# ls /dev
      MAKEDEV fd loop0 mcelog port ram11 ram5 rtc0 sdb1 sndstat tty12 tty20 tty29 tty37 tty45 tty53 tty61 ttyS3 vcs5 vcsa6
      block full loop1 md ppp ram12 ram6 sda sdb2 stderr tty13 tty21 tty3 tty38 tty46 tty54 tty62 uinput vcs6 vcsa7
      bsg fuse loop2 mem psaux ram13 ram7 sda1 sdb3 stdin tty14 tty22 tty30 tty39 tty47 tty55 tty63 urandom vcs7 vga_arbiter
      bus hpet loop3 net ptmx ram14 ram8 sda2 sdb4 stdout tty15 tty23 tty31 tty4 tty48 tty56 tty7 v4l vcsa video0
      char initctl loop4 network_latency pts ram15 ram9 sda3 sdc tty tty16 tty24 tty32 tty40 tty49 tty57 tty8 vcs vcsa1 watchdog
      console input loop5 network_throughput ram ram16 random sda5 sdc1 tty0 tty17 tty25 tty33 tty41 tty5 tty58 tty9 vcs1 vcsa2 xconsole
      core kmem loop6 null ram0 ram2 rfkill sda6 shm tty1 tty18 tty26 tty34 tty42 tty50 tty59 ttyS0 vcs2 vcsa3 zero
      cpu_dma_latency kmsg loop7 nvidia0 ram1 ram3 root sda7 snapshot tty10 tty19 tty27 tty35 tty43 tty51 tty6 ttyS1 vcs3 vcsa4
      disk log mapper nvidiactl ram10 ram4 rtc sdb snd tty11 tty2 tty28 tty36 tty44 tty52 tty60 ttyS2 vcs4 vcsa5

      In my case /dev/root exists and hakcenter's solution gives:
      root@OpenMediaVault:/# ln -s /dev/sdc1 /dev/root
      ln: failed to create symbolic link `/dev/root': File exists

      The edoceo work around appears to install grub but then I get:
      Segmentation fault

      Delete
    4. Luke, not sure what's going on here. /dev is obviously populated.

      I'm guessing that you're trying to install OpenMediaVault? Your error is more closely associated with openmediavault than with debian (you're using the debian kernel, but the openmediavault binaries when you're in the chroot), so it might be worth posting on their forum to see whether anyone has any ideas.

      How did you do the bootstrap if you installed openmediavault?

      Delete
    5. I've had OpenMediaVault running on this system for sometime. Im trying to install Debian on a USB stick for another machine. Everything was going smoothly including the bootstrap, it was just the grub install that was giving me grief. I didnt consider the openmediavault binaries as a cause.

      Delete
    6. OK. So the debian system is in the chroot. In the chroot only the running openmediavault kernel is used. Everything else are debian binaries. Not sure what's going on then.

      If you can let me know more about your system (e.g. 32 or 64 bit, type of hardware, ext3/4 etc) I might be able to set up a similar system here and troubleshoot. No promises though.

      Delete
    7. Its a 64bit Asus eeepc 1015PN notebook, ext3 but I decided to install Debian on my mac via virtualbox and try it. Im up to step 6 and so far so good. Thanks for your help and great blog.
      Luke

      Delete
    8. No worries. Sorry that I couldn't offer you a better resolution for the openmediavault/debian case.

      Delete
  6. Now this is a problem as Debian Wheezy became a stable release and I changed to stable but it failed to fetch some packages. if I fail fetching, what should I do?
    And what is the size of the Debian installation? I have a 8GB USB drive. does GNOME fit with mine? or should I use the 32GB USB?

    ReplyDelete
    Replies
    1. The different size are mentioned in the text. Gnome would be ca 670 + 2340 Mb (+ downloaded packages). Gnome should fit on an 8 Gb usb stick if you run sudo apt-get clean between installing packages.

      As for failing to fetch, the solution depends on the cause. Why is it failing? Are you using a major, complete mirror?

      Delete
  7. Anyway, KDE is not in the guide. that's okay. but I want a full-fledged experience with desktop environments. What's better, KDE or GNOME?

    ReplyDelete
  8. Only you can answer that. Pick one DE and stick with it -- they are different but equal. Only real difference that I've noticed is that it's trickier getting conky to work on kde than Gnome.

    ReplyDelete
    Replies
    1. I'm not asking what is truly better, but what is better in size. I'm not managed to use apt-get clean for each procedures.

      Delete
    2. That wasn't clear from your question.

      Size depends on what you install in terms of tools.

      To find out the size of the virtual packages, just do
      sudo apt-get install [package]
      and you'll be prompted with
      "After this operation, [..] of additional disk space will be used."

      That should give you an indication.

      Or look up one of the many DE reviews out there.

      Delete
  9. Sure I used the trusted one you shown above. I actually tested the mirror to check out what is in the mirrors.

    ReplyDelete
    Replies
    1. I'm not really sure what you mean -- is everything working for you?

      Delete
  10. older boxes that HAVE usb drives can do with PLoP boot manager. well,,,,,, that may be cool, but I think the system folders will change.

    ReplyDelete
    Replies
    1. As far as I understand you'd have to boot using plop on a CD or floppy, which would then allow you to boot from a USB i.e. you'll have to burn a separate CD and it is independent of the process of setting up a bootable USB stick.

      Those who are interested can look at:
      http://www.plop.at/en/bootmanagers.html

      Note that plop isn't in the debian repos.

      Delete
  11. HELP!
    Last Month(June), I also essayed another time, but the mirror and the release index files were not verified. this time, It's long that debian mirrors have changed to 7-stable. as a result, I gave up and deleted ubuntu. That's the result that I do not use Ubuntu for now.

    ReplyDelete
    Replies
    1. I'm a bit confused. Is there something you'd like help with? Also, I don't see the connection between ubuntu and debian wheezy. Let me know if there's something you'd like help with.

      Delete
  12. For security reasons, how can you install this with full disk encryption, or at least eCryptFS?

    ReplyDelete
    Replies
    1. I haven't tried, but I'd be interested to. Have a look at how it's done for full hdd installations, since the approach will be similar. I might write a how-to at some point in the future, but it will be in months, not days or weeks.

      Delete
    2. To only encrypt the home folder, see e.g http://wiki.debian.org/TransparentEncryptionForHomeFolder

      Delete
    3. A few other approaches are here:
      http://madduck.net/docs/cryptdisk/
      and with LVM:
      http://linuxgazette.net/140/kapil.html
      http://smcv.pseudorandom.co.uk/2008/09/cryptroot/

      I haven't tried either method.

      Delete
  13. A really useful post! It covered something that I have wanted to do for some time. I followed your instructions (almost) to the letter and found that when I tried to boot from the usb stick, the file system was mounted as read-only. This, I discovered, was simply because I had made a simple typing error on the fstab entry, when corrected, it booted up fine.

    My other problem was that startx was not found, I had installed gnome but I couldn't start it. Once I had installed xorg and xinit, startx worked just fine. I was surprised that they weren't installed with gnome.

    Anyway - thanks for a great post.

    ReplyDelete
    Replies
    1. Jeff, thank you for your feedback, and happy that it worked out for you!

      Delete
  14. Excelent article! Any regards with other drivers, such as video and audio drivers? Should I install ATI and nVidia non-frees aswell?

    ReplyDelete
    Replies
    1. That depends on your needs, desires and how much space you have. For a portable USB stick I probably wouldn't bother beyond the free radeon and nouveau drivers.

      Delete
    2. What you might want to focus on is installing all the (non-conflicting -- watch out with broadcom) non-free firmware you can, in order to make sure that you won't have issues with unrecognised NICs.

      Delete
  15. Xfce is a lightweight desktop environment for UNIX-like operating systems. It aims to be fast and low on system resources, while still being visually appealing and user friendly.

    To install Xfce on debian 7 wheezy
    # apt-get install xorg xfce4 xfce4-goodies thunar-archive-plugin synaptic gdebi wicd

    To install extra XFCE packages
    # apt-get install xdg-utils xfce4-power-manager xfce4-goodies htop bzip2 zip unzip unrar-free

    There are more gui to choose from http://namhuy.net/1085/install-gui-on-debian-7-wheezy.html

    ReplyDelete
  16. Hi, first thanks for this tuto ! ;)
    Second, just 1 question : when I start deby (on the usb stick), I arrived on a xterm console not the usual console ? which doesn't take my bashrc either ? So could you please point me in the right direction to configure this correctly and have a correct 'env' setup ? Thank you.

    ReplyDelete
    Replies
    1. I'm not sure exactly what you mean -- if you end up in an xterm console you must be starting some X11 environment.

      Re .bashrc -- the first step is to make sure that you are mounting your /home partition and that you end up in the right partition on logging in. Check your fstab as well.

      What DE did you install, if any?

      Delete
    2. Actually I thought it was xterm because it looked like a non-configured xterm terminal. But I just learned that xterm needs X to run. So I guess it is just the linux console you get where you log and start X by "startx" command.
      This happens when I boot from usb where the os is installed. This console doesn't not accept the arrows as commands but as "5]]" characters, I don't have my bashrc loaded even after logged into my account and then the "env" command returns a minimal environment.
      I installed the stable version which is wheezy by now.

      Delete
    3. To see what shell you're using, do
      echo $SHELL

      Does it not read your ~/.bashrc, or do you actually just have a minimal ~/.bashrc? Try
      source ~/.bashrc
      to force it being read, and see what happens.

      If it turns out that ~/.bashrc isn't read by default, have a look at /etc/bash.bashrc and /etc/profile

      A 'normal' bashrc should look like:
      case $- in
      *i*) ;;
      *) return;;
      esac

      HISTCONTROL=ignoreboth

      shopt -s histappend

      HISTSIZE=1000
      HISTFILESIZE=2000

      shopt -s checkwinsize

      if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
      debian_chroot=$(cat /etc/debian_chroot)
      fi

      case "$TERM" in
      xterm-color) color_prompt=yes;;
      esac

      if [ -n "$force_color_prompt" ]; then
      if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
      color_prompt=yes
      else
      color_prompt=
      fi
      fi

      if [ "$color_prompt" = yes ]; then
      PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
      else
      PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
      fi
      unset color_prompt force_color_prompt

      case "$TERM" in
      xterm*|rxvt*)
      PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
      ;;
      *)
      ;;
      esac

      if [ -x /usr/bin/dircolors ]; then
      test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
      alias ls='ls --color=auto'

      fi



      if [ -f ~/.bash_aliases ]; then
      . ~/.bash_aliases
      fi

      if ! shopt -oq posix; then
      if [ -f /usr/share/bash-completion/bash_completion ]; then
      . /usr/share/bash-completion/bash_completion
      elif [ -f /etc/bash_completion ]; then
      . /etc/bash_completion
      fi
      fi

      Delete
  17. Or just use the first full Debian install DVD, select the USB drive during partition, set up as necessary, then continue the install as you would with a normal HDD install...easy peasy, and with none of this extraneous chroot crap.

    Open source is more complicated than what Windows users are used ok but no need to make it more complicated than necessary.

    ReplyDelete
    Replies
    1. Hi Sean,
      The methods are complimentary. Progress is made by people who explore the options -- using a chroot can be used for neat stuff like this: http://verahill.blogspot.com.au/2013/03/359-installing-scientific-linux-centos.html.

      And personally I have no intention of rebooting my computer just to prepare a USB stick. Over 5,000 page hits on this page so far would indicate that I'm not the only one.

      Finally, there's nothing inherently 'complicated' with open source. In most cases managing your system is much more straightforward due to the everything-is-a-file principle on linux.

      Delete
  18. maybe add a warning that you can only make a amd64 system if to create it from a amd64 system.

    i just tried it from a i386 PC and the chroot failed (end of step 2)
    with the error :
    chroot failed to run command /bin/bash' exec format error

    ReplyDelete
  19. This doesn't work for me. Can you help? I followed the instructions very carefully (checked 4 times) but I end up with the following error during boot:
    No DEFAULT or UI configuration directive found

    Can you assist me further? Many thanks

    ReplyDelete
    Replies
    1. No idea -- haven't seen that error before. Searching brings up a number of hits, although most of them are related to using linux isos. Presumably the solutions to those issues should be similar to the issues you're seeing.

      Delete
    2. Thanks for replying. I suspect it has to do with the boot loader not being able to find appropriate kernel files. I'm probably missing some configuration files or configuration statements somewhere in the boot loader section (but where?)
      Maybe you can help, it's been bugging me for some time I need to get it up and running. Thanks mate.

      Delete
  20. Is it possible to do this from live usb system?

    I am trying to install to usb from live usb system and I get stuck at #2 step.
    Not able to mount ext4 file system created on usb. (in step #1)
    mount or mount -t ext4 command does not work. My pen drive is 32GB drive. fdisk -l is as bellow.

    root@debian:~# fdisk -l /dev/sdd

    Disk /dev/sdd: 34.1 GB, 34078719488 bytes
    64 heads, 31 sectors/track, 33548 cylinders, total 66559999 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x02ff938b

    Device Boot Start End Blocks Id System
    /dev/sdd1 * 2048 66559998 33278975+ 83 Linux

    ReplyDelete
    Replies
    1. Don't have much of an answer for you. I would've thought that the file system on the live usb stick would've been iso9660 or something similar so that you wouldn't be able to create a mount point under it. I presume from your post that you did manage to do that?

      You can try using palimpsest (aka Disk Utility) under Gnome and mount the target USB that way.

      Delete
  21. Can I install other program into the OS which installed in USB stick?

    ReplyDelete
    Replies
    1. Your question is a bit vague, but interpreting it in the most liberal way possible, then yes, you can.

      As a general rule, however, use the OS in control of a partition to install software on that partition. Your USB stick will be just like a harddrive with an OS installed on it, so you need to treat it accordingly.

      Delete
    2. Thank you.
      I will try it.

      Delete
  22. Getting this error at grub install. Anybody know what gives?

    :/# apt-get install grub-pc linux-base linux-image-3.2.0-4-686-pae
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package linux-image-3.2.0-4-686-pae
    E: Couldn't find any package by regex 'linux-image-3.2.0-4-686-pae'

    ReplyDelete
    Replies
    1. You'll need to install the correct linux image. In the instructions above I used 'testing' as the distro -- the current testing release is Jessie.
      Try e.g. linux-image-3.16.0-4-686-pae

      Delete
  23. Installing Debian 8 Jessie in VMware Workstation Video Tutorial
    http://bit.ly/1KgTLv9

    ReplyDelete
  24. hi lindqvist, it's been many years since this article was written but it seems to have stood the test of time; at least among internet search results! to the best of your knowledge, does this method still work for modern debian...kernel versions notwithstanding?

    ReplyDelete