Take working Linux install and create a bootable USB?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Take working Linux install and create a bootable USB?
Hey all, I would like to take my workstation (with all installed programs) and use it to create a bootable USB drive. I can find tons of ways to make bootable USB drives but only with existing ISO images. Is there a way to do what I want to do or am I going to have to do temp installs every time I boot to my USB drive?
If your disk is as large or smaller than your usb, you could try unmounting the usb and then use
Code:
$ sudo dd if=/dev/sda of=/dev/sdb count=1
and then mounting the / partition on the usb to /mnt with
Code:
$ sudo mount /dev/sdbX /mnt
where X is the number of the partition on sda.
You should then edit /mnt/etc/fstab and change every occurence of /dev/sda into /dev/sdb.
If your usb is smaller, dismount it and partition it with
Code:
$ sudo cfdisk /dev/sdb
or
Code:
$ sudo parted /dev/sdb
and create the partitions.
Then use 'mkfs.ext2', 'mkfs.ext4' to create the filesystems on the partitions and copy the contents of the partitions on /dev/sda to /dev/sdb.
Make sure you have grub installed and then run
Code:
$ sudo modprobe dm-mod
$ sudo grub-install --target=i386-pc --recheck --debug /dev/sdb
$ sudo mount /dev/sdbX /mnt # X is the number of the boot partition
$ sudo mkdir -p /mnt/grub/locale
$ sudo cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /mnt/grub/locale/en.mo
$ sudo umount /mnt
$ sudo mount /dev/sdY /mnt # the partition containing /etc
$ sudo your-favorite-editor /mnt/etc/fstab # and replace every occurrence of /dev/sda with /dev/sdb
But it might be easier to boot the install image and use that to install to the usb.
It might work to dd the install. Problems may have to be fixed that might take a while. It is worth a try.
Knowing the actual size of the install might be a start. The live cd's have a compressed file that packs in data. That is different than using a debian installer app to install to a usb as if were your hard drive. To most linux a usb is a scsi drive.
Might be possible to use a clone tool like clonezilla/redobackup. Still might need to edit some files.
As stated it might be worth it to do a clean install to the usb. The live cd deals tend to take an iso image and cheat it and not a true install.
Maybe I need to clarify -- I want to copy my full workstation configuration to the USB drive, diagnostic programs and everything, and have that be what boots when I boot to the USB drive. I know it's possible to start installing programs once the USB drive boots but that's a lot of hassle and very time consuming.
Is your USB drive smaller than your SATA (or IDE) drive? If so, then a full "dd" copy is not an option. You'll have to format new filesystem(s) on the USB drive at its smaller size, and copy the files (rsync is a good choice for this).
Be sure your filesystems are specified (in /etc/fstab) to be mounted by LABEL or UUID, not by device not (an example of a device node is /dev/sda1). Since the USB drive is likely NOT going to be the same device node when using it, you need to be sure the kernel will mount the correct partition. Its initrd or initramfs should take care of this. How well this happens depends on your distribution.
I built my own USB memory stick based system from Slackware. But I used by own code to find the drive by UUID and make sure it got mounted. I did this because stock initrds did not do one extra step I wanted: to give me the choice of 32 bit or 64 bit system to boot, and do it from the same partition.
Maybe I need to clarify -- I want to copy my full workstation configuration to the USB drive, diagnostic programs and everything, and have that be what boots when I boot to the USB drive.
In that case I think it would be easiest to boot an install cd or usb for the distro you want, then plug in the usb, figure out its /dev id and have the live{cd,usb} isntall. At the disk partitioning stage, select the target usb, and after it's installed onto the usb, copy the /bin, /sbin, /usr, /home, /var and everything in /etc except for fstab and mtab from your workstation to the usb.
The system on the usb should now be pretty much indistinguishable from the system on the workstation.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.