this post was submitted on 28 Sep 2024
51 points (96.4% liked)

Linux

47471 readers
1127 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

I'm not coming up with a lot of useful (clear) results when searching for a solution to this issue.

Is it OK to simply dd the 128GB disk to the 32GB disk using count to stop after the 16GB partition was cloned?

A bit more context: I had to clone a 16GB eMMC and only had a 128GB SD around. Now I purchased a 32GB eMMC and want to clone it again. The partition holds a root filesystem for an ARMv8 device. I don't have the 16GB eMMC anymore, that would have been the easy way out.

all 22 comments
sorted by: hot top controversial new old
[–] zelifcam@lemmy.world 19 points 1 day ago* (last edited 1 day ago) (1 children)

I’d use clonezilla

E: It’s not that it can’t be done other ways, it’s just clonezilla will work and has worked for nearly 2 decades. Also there’s no information provided above about the data. So clonezilla is nice if it’s a complicated scenario.

Plus, it’s a nice tool to throw in the toolbox once you know how to use it.

E. Why do you feel like you have to use something like dd for this particular task? Less than 16 GB of data? Ya probably could have copied it over manually by now.

[–] InFerNo@lemmy.ml 2 points 1 day ago (3 children)

It's not an active partition/disk I want to clone. Clonezilla seems like something I need to boot into?

[–] IsoKiero@sopuli.xyz 4 points 1 day ago

You can run clonezilla on your shell session, just apt install conezilla (or whatever variant you're using) and it can do the trick. Dd will almost surely work too, but that leaves a ton of responsibility to you instead of making any sanity checks on the way. That makes dd very powerful tool and it has saved my ass a multiple times, but if you already have a working partitioning schema clonezilla has a ton of options to make your life a lot simpler and a likely a bit faster than dd.

[–] Taleya@aussie.zone 3 points 21 hours ago

Use a clonezilla boot usb. I did exactly what you're trying with clonezilla: 16gb partition on a 128gb ssd to a 64gb ssd. The clone disk is in a production machine rn and has been for two months.

[–] hushable@lemmy.world 2 points 1 day ago

Yes, Clonezilla runs off a live USB. If it is large enough it can also store the partition you want to clone, making the whole process a lot simpler.

[–] Kazumara@discuss.tchncs.de 11 points 1 day ago* (last edited 1 day ago) (1 children)

Is it OK to simply dd the 128GB disk to the 32GB disk using count to stop after the 16GB partition was cloned?

I think it would work, but it seems a little overcomplicated, you can just use the partition paths as if and of of dd directly, as long as the output partition is not smaller than the input partition. For example dd if=/dev/sdc1 of=/dev/sdd1 bs=4M status=progress

Your method would also copy the partition table I suppose, which might be something you want under specific circumstances, but then it would be a little harder to get the count right, just taking the size of partition 1 would be wrong, because there is some space before it (where the partition table lives) and dd would start at 0. You'd need to add up the start position and the size of partition 1 instead.

Personally I would prefer making a new partition table on the new eMCC, and create a target partition on it. Then you clone the content of the partition (i.e. the file system). This way the file system UUID will still be the same, and the fstab should still work because these days it usually refers to mounts by filesystem UUID in my experience.

If you make the target partition larger than the source partition, and you intend to use the full partition going forward you will additionally need to resize the filesystem to fit the new larger partition, for example with resize2fs.

[–] ekky@sopuli.xyz 6 points 1 day ago

This is the way!

Way simpler than using any GUI tool or somehow recreating the partition and manually copying the files.

[–] BCsven@lemmy.ca 5 points 1 day ago* (last edited 15 hours ago)

Dd with count does work. scroll down to: Use dd, with the count option. response

https://serverfault.com/questions/439128/dd-on-entire-disk-but-do-not-want-empty-portion

[–] friend_of_satan@lemmy.world 4 points 1 day ago* (last edited 1 day ago)

If I understand the problem correctly it has a pretty simple solution that I have done before. Make a new partition on the destination and dd if=/dev/diskAsB of=/dev/diskXsY where A is the source disk and B is the source partition and X is the destination disk and Y is the destination partition. You may have to run fsck on the destination afterwards and maybe a gpt repair tool.

Honestly though, since it's an ext filesystem, if it were me I'd just mount the source and dest and rsync.

[–] avi2022@masto.ai 5 points 1 day ago* (last edited 1 day ago)

@InFerNo if it's not a boot drive, you can use gparted to copy the partition over - it's copy and paste, literally. Then set flags using gparted as well. If it's a boot drive you'll need an additional step after to use boot-repair to fix the boot sector and load grub onto it.

It's really simpler than it sounds, I've used it a few times myself. You can also use an #Ubuntu iso to execute this process after booting from it to ensure the 16GB partition is not in use when trying to copy it.

#Linux

[–] seaQueue@lemmy.world 2 points 1 day ago* (last edited 1 day ago)

Is the 16gb partition the first partition? If so I'd just dd the 128gb drive at the 32gb drive then fix the partition table and remove the others.

If it's not the first partition use gparted to copy it to the new drive.

[–] 7U5K3N@lemmy.dbzer0.com 2 points 1 day ago

Gnome-disk-utility or "disks" in Linux will clone a partition and then restore it to another disk.

[–] nickapos@nickapos.social.oncrete.gr 2 points 1 day ago (1 children)

@InFerNo@lemmy.ml you should do the partition not the whole disk. Then create a new partition in the 32gb disk or mount the dd file with a loopback device and transfer the files to the whole 32gb disk

[–] InFerNo@lemmy.ml 3 points 1 day ago (1 children)

It's a root fs for an ARM device. I can't simply copy the files over.

[–] azron@lemmy.ml 3 points 1 day ago

Is the system Linux? If so, then yes you can. Rsync it on to the newly created device get the uiid and fix up the fstab and boot loader configs and you are back in business.

[–] 30p87@feddit.org 3 points 1 day ago (1 children)

Could be - just try it ig. And even if not, just create a new partition on the 32 GB disk and then dd it over.

[–] Rin@lemm.ee 1 points 1 day ago

Do you only have the root parition or do you have everything else too (like /boot)?

  1. If you only have root, reinstall the OS then just overwrite the root partition with your old one.
  2. Run fsck on the root partition and/or use gparted to expand the ext4 partition. You might have to fuck around with the disk UUIDs to get it to boot again. You'll most likely have to at the very least change your /etc/fstab file to update the UUID of the boot partition.

if you have everything, you can just dd the sd disk to the emmc, provided that you didn't mess around with the partitions after.

  1. Copy with dd to the emmc with or without the count, it doesn't matter that much if time isn't a priority. (something like dd if=/dev/sdcard of=/dev/newemmc). If it fails and says the device is out of memory after 32GB, that's fine. Any other error is not fine.
  2. Use gparted to expand the root partition.
  3. fsck the partition.
[–] PetteriPano@lemmy.world 1 points 1 day ago (1 children)

INFO: What filesystem does your source drive/partition have?

[–] InFerNo@lemmy.ml 1 points 1 day ago
[–] g_damian@lemmy.world 1 points 1 day ago

I recommend FSArchiver, it can handle different size partitions