Install persistent version of USB onto a hard drive

If this has been asked before, I am sorry ahead of time. It is extremely difficult to find what I am trying to ask because there are so many threads on installing persistent installations onto pen drives.

Right to the point:

I have a USB pen drive with a persistent installation of Ubuntu on it. I have it configured and have all my personal programs installed and all of the programs I do not use removed. It is perfect to my liking and took many hours getting it this way.

It took a long time to get it perfectly how I want it and I purchased a new laptop. Though, everytime I try to install Ubuntu from the pen drive it does not install any changes I have made, just the basic live version of it.

So, I was wondering is there a way to install the persistent version of the pen drive onto the laptop? That way all the programs added and changes I have made can transfer right into the new laptop as the main OS without having to do it all over again?

Thank you very much for your help and time!


Solution 1:

You'll need to boot from a live USB (you might be able to use the same source USB).

Assuming your USB is located at /dev/sdb and that your hard drive is located at /dev/sda then you can simply run the following:

dd if=/dev/sdb of=/dev/sda

And that will copy bit for bit everything on the USB to your hard drive. You should be able to boot from it then. Once you boot into it, you can use various tools to expand your data partition to fill the entire drive.

Solution 2:

casper-rw contains the persistent information on the pendrive, it can be a file or partition. If a file, it is limited in size to 4GB, if an ext partition it is only limited by the size of the drive

The command to boot the pendrive into persistent mode is "persistent", it may be located in several different files. If the pendrive was created using UNetbootin, the file is syslinux.cfg, if created using Startup Disk Creator, the file is text.cfg or txt.cfg, depending on version.

append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash --

Location of the word persistent in the line is not important, as long as it is preceded by a space.

If you have been successful in installing Ubuntu Live to the laptop's internal drive, you only need to copy the casper-rw file to the root of the laptops HDD and confirm the existence of the word "persistent" as shown above.

If you require more than 4GB of persistence, you can add an ext2, 3, or 4 partition using gparted and name it casper-rw.

You can then copy the "perfect" casper-rw file and mount it someplace convient:

sudo mount -o loop /home/cscameron/Desktop/casper-rw /home/cscameron/Desktop/casper

and then rsync it's contents to the new partition.

sudo rsync -rltDvu --progress --delete /home/cscameron/Desktop/casper/ /media/cscameron/casper-rw

After confirming that the partition is working, you can delete the casper-rw file or save it off root.