Cloning bootable USB flash drive onto larger flash drive - best method?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
Cloning bootable USB flash drive onto larger flash drive - best method?
I have a server running on a USB flash drive and I need to move it to a larger drive. I'd like to keep the server up and running if it is possible, at least until the new drive is ready and all I have to do is reboot.
I know how to use ddrescue and already gave this a try. I copied the original 8gb drive to a 32gb drive. It has 2 primary partitions (sda1, sda2) and an extended partition (sda5 - swap) - both were partitioned to 4gb. I expanded sda2 to take up the rest of the drive so it ended at the end of the drive, moved the data so that sda5 started at about 24GB mark, giving it 8GB space, then moved the beginning of sda2 to the beginning point of sda5 (leaving a large open space between the 2 primary partitions. I then resized sda1 to end at the 24GB mark (where sda2 starts) taking up all the remaining free space in the middle. So now the whole drive is in use
When I try to boot from the larger drive I get the screen where I choose which installed version of Linux to run, run recovery mode, memtests, etc. When I select any of the linux options it says that there isn't enough room or space.
I really need to get the new drive working and can shut down the server if I have to but would like to know if it is possible to do it while it is still running.
Not much to go on. What linux distribution/version are you running?
What did you use to resize the partitions/filesystems? gparted?
When during the boot phase did you see this message?
swap does not contain data when it isn't in use so you could delete sda2(sda5) and extend/resize sda1 as desired. Then recreate sda2 (extended partition) and sda5 (swap). Reformat swap using the same UUID as the original swap. Look the fstab file to see if your OS is using UUIDs.
Yes, just delete the partitions with swap, extend the root parition as you need, and leave space at the end for swap. You can put swap into an extended partition or not, it doesn't really matter. Swap is just swap, not formatted, and nothing is stored there when the system is not running. AFAIK you can't do this while the system is running.
Yes, just delete the partitions with swap, extend the root parition as you need, and leave space at the end for swap. You can put swap into an extended partition or not, it doesn't really matter. Swap is just swap, not formatted, and nothing is stored there when the system is not running. AFAIK you can't do this while the system is running.
I used gparted to resize them, in another linux box. I used ddrescue to do a bit for bit copy of the original to the new drive then moved the drive to a new machine to resize. I'm running ubuntu 12.04.
I got the message about not enough room or space immediately after selecting the version of linux I wanted the bootloader to load (this is the screen that also gives the option for selecting memtest86+ and such). It doesn't get very far, maybe spits out 3-4 lines but they are all similar messages about not loading or to reboot or retry with more space.
Well I though I understood what I needed to do but I'm not seeing the new primary partition as needing to be resized but it says there is no space left.
I deleted the MBR of the new USB drive. I then fdisk'd the new drive, created a primary partition and used 75% of the sectors (~22GB). I then created sda2 as an extened partition using the remaining sectors. I then created a logical partition - sda5 - using the same sectors as sda2 - taking up all the remaining room on the drive. I then changed the partition type from 83 Linux to 82 swap on sda5. Then wrote the changes.
Now that I thought the partitions were set up I did dd rescue: ddrescue -d -f -r3 /dev/sdb1 /dev/sda1 -- ( old primary partition copied to new primary partition on larger drive). Completed successfully. mounted the new partition in /mnt/temp and ran "df" to see how much space was left on the partition. It shows the same results as the original smaller drive - 97% used.
Moved new drive to other linux box and ran gparted on it thinking I had to resize the partition (Maybe I misunderstand this part) because it was showing 97% used.
I also was trying to find out how to change the UUID of the swap but could only find how to generate a new random one.
Sorry for not getting this right the first time, but thank you for the help!
The option should be available with 12.04.
sudo mkswap -U uuid /dev/sdx5 (Make sure you get the sda vs sdb correct...) (where uuid is the old swap UUID)
I'm not sure at the moment what generates the out of space message. Hopefully others will chime in.
Another method would be to create the desired partitions and instead of using the dd command, format the partition then mount your new / to /mnt/new_drive (as an example) and then use the cp command to copy everything over i.e.
sudo cp -pr /*.* /mnt/new_drive
Copy the bootloader via dd i.e.
sudo dd if=/dev/sdx of=/dev/sdy bs=446 count=1
Be very careful to make sure the source and destination drives are correct. To be safe do you have a backup?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.