LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 03-13-2024, 07:56 AM   #1
prophet001
LQ Newbie
 
Registered: Mar 2024
Posts: 2

Rep: Reputation: 0
Question about Linux USB flash drive cloning


Hello. I was wondering if someone could help with a question about cloning a USB drive with Linux on it. We have a drive that is 4GB and has 3 partitions on it with ext2 file systems in them. The drive is used for loading the OS for a commercial machine.

We bought a Startech USB cloner/duplicator with the intent of cloning the drive to another 4GB drive however the sizes aren't the same. The source is 3920MB and the destination is 3782MB so the duplicator won't start the clone.

I don't know much about Linux. Is there a way to create these 3 partitions manually and resize/shrink the last partition to make it fit? Then we would copy the contents of each partition and make the drive bootable? Is this something that can be done?

I have some knowledge of doing this in diskpart and using windows tools like bcdedit to set the boot configuration but I don't know anything about how Linux does these things.

Thank you for any help you can give.
 
Old 03-13-2024, 08:30 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,575
Blog Entries: 19

Rep: Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453Reputation: 4453
Quote:
Originally Posted by prophet001 View Post
I don't know much about Linux. Is there a way to create these 3 partitions manually and resize/shrink the last partition to make it fit? Then we would copy the contents of each partition and make the drive bootable? Is this something that can be done?
Yes, that's quite easy to do. The best tool for partitioning is gparted. There's a CD image called SystemRescueCD which has this and many other useful tools on it. You can use gparted to create partitions of the sizes you want. The copying can be done with various tools; I would go with fsarchiver which is also on SystemRescueCD. Basically it will pack a filesystem up and you can then unpack it on the appropriate partition on the new drive.

If your computer has a UEFI, you set the bootloader up on the EFI system partition and register it using efibootmgr, which is a sort of Linux equivalent to bcedit. I think GRUB is the bootloader most commonly used for this sort of thing nowadays but a lot of flash images boot with syslinux.
 
1 members found this post helpful.
Old 03-13-2024, 08:55 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Try using 8Gb drives as the destination. Or even bigger, USB drives are "commodity" these days, so you may find larger sizes are cheaper than 4Gb.
 
2 members found this post helpful.
Old 03-13-2024, 09:23 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,707

Rep: Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898Reputation: 5898
I agree with just using a bigger flash drive. The amount of effort versus cost does not make sense.

Typically drives are list using their size in GB but report their size in Gib. 4 GB = 3.7 GiB.
 
1 members found this post helpful.
Old 03-13-2024, 05:04 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,129

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Changing the partition sizes will be irrelevant - the cloner will presumably count sectors on the physical device. Bigger drive(s) is the answer - if you have to use (nominally) 4G go buy a bunch, and check the real size with say fdisk. Pick an appropriate one.
 
1 members found this post helpful.
Old 03-13-2024, 05:37 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,985

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
Kind of a dangerous test maybe.

The ext2 is not very safe.

I might be tempted to use something like clonezilla to at least copy the data to a set of files on some other storage media.

G4U of could might be used but not very user friendly.
 
1 members found this post helpful.
Old 03-13-2024, 05:55 PM   #7
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,113
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
Used to use EXT2 file system on / and /home on internal non journaling ssd drive on clambook.

Live gparted > unmount > check was always good enough to fix improper unmount/shutdowns to where the system would not boot.
 
1 members found this post helpful.
Old 03-14-2024, 09:06 AM   #8
prophet001
LQ Newbie
 
Registered: Mar 2024
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you all very much for the help. I greatly appreciate it. I am trying to find a drive to match so I probably won't need to try to make this work with parted or other commands.

Just as a curiosity though, is it possible to resize the last partition to shrink it to the size available on the smaller drive and then copy boot configuration and files from the 3 partitions to the new drive and have the new drive work the same and behave as if it was cloned?
 
Old 03-14-2024, 12:23 PM   #9
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,113
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
If I shrink partitions. I double check to make sure things are OK with a re-boot.

If it re-boots. You are golden. Then you can try your copy files.
 
Old 03-14-2024, 03:31 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,985

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
Gparted is a great tool to copy partitions but there is more to that. Usually there is a loader.
 
Old 03-14-2024, 11:36 PM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,129

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Quote:
Originally Posted by prophet001 View Post
Just as a curiosity though, is it possible to resize the last partition to shrink it to the size available on the smaller drive and then copy boot configuration and files from the 3 partitions to the new drive and have the new drive work the same and behave as if it was cloned?
Yes - but the physical cloner is the better option if you can find a drive of at least the same number of sectors.

Shrink the filesystem, then the partition, then when happy simply dd the device over specifying a block count. Don't get cute - copy a size that is slightly bigger than the total allocated on the source device, but will fit into the target device. Doesn't have to be exactly the target size. Give yourself a few megabyte leeway if you can.
 
Old 03-15-2024, 04:11 PM   #12
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,985

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
We had a cloner that was a linux box basically.

We also had a cloner with backwards storage and we deleted a few drives before we figured it out.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Cloning OS on a GPT partitioned drive - to a smaller drive??? taylorkh Linux - Software 12 07-28-2022 11:17 PM
Will cloning one hdd (not ssd) to another encrypted hdd work on a cloning device? hddfsck Linux - Newbie 16 09-05-2019 07:02 AM
Cloning bootable USB flash drive onto larger flash drive - best method? cilbuper Linux - General 5 02-26-2014 09:51 AM
Cloning dual-boot drive onto a smaller drive. Harju Linux - Newbie 4 05-29-2010 11:40 AM
FLASH FLASH XP Home and Samba Fix FLASH FLASH zollodav Linux - Networking 1 02-19-2006 01:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration