[SOLVED] Cloning OS on a GPT partitioned drive - to a smaller drive???
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.
Cloning OS on a GPT partitioned drive - to a smaller drive???
Since the days of my CP/M Osborne I have always separated my data from the OS. This makes for much easier and effective backup. The data is easy, the OS I have typically performed a cold backup with Ghost, Clonezilla or most recently with redorescue. These producte work great and have saved me many times. EXCEPT if the target drive is even a tiny bit smaller than the source.
I came across this https://blnlabs.com/clone-hdd-to-smaller-sdd-on-linux/ brilliant approach and have used it with success on FAT/MBR formatted media. On GPT - no luck I believe that is because, as I understand, GPT stores partition information in multiple places around the drive.
I have some hardware on which I boot Linux from a USB flash drive. For example an Intel NUC which serves as a gateway, firewall, VPN sharing box between my LAN and the Internet. It does not need any storage, only enough to boot the OS and run a couple of programs. I have Linux Mint installed on a Samsung (nominal) 32 GB flash drive. I am attempting to clone it to a SanDisk (nominal) 32 GB flash drive which is a little bit smaller. Plenty of room for the files but Clonezilla and redurescue both barf that the target is too small. I tried the dd approach as described in the linked page above. No luck. My target drive is unreadable.
A couple of years ago when I was playing with Raspberry Pi computers heavily I came across this issue frequently as MicroSD cards are very nominal in size and a few kB difference will cause the cloning programs to fail. I developed this rsync process to do the job.
I tried this with the Mint install but grub would not boot. I suspect grub was referencing UUIDs on the original disk although I have not explored down that road yet.
Bottom line... can anyone recommend a program or process to clone a GPT formatted storage device to a smaller one?
TIA,
Ken
p.s. I have several of these situations. I guess I can just purchase some 64 and 128 GB flash drives. I started out with the OS on 16 GB flash drives with much space left over. When I needed to back them up I ended up cloning to 32 GB drives with MUCH MORE space left over. I have verified that I can clone the larger nominal 32 GB drive to a nominal 64 GB drive... But this is getting off track.
I've gotten in the habit of making tarballs instead of cloning and imaging directly. Then the filesystem size and type is irrelevant. Just get your partitions in order, tar into place, make sure fstab is updated and do grub. Is a bit more manual I suppose than a direct clone but also gives plenty more flexibility.
I typically clonezilla or redorescue to an image which I then backup to one of my data servers. I restore said image to the new drive if ever needed.
I use tar extensively for data backups. I never tried it on an OS. Let me give that a try. I understand how to check and update fstab. I am not sure about grub. I will have to research into that a little.
I have a thread going over on the Mint forums asking how to cause the Mint installer to use MBR/DOS rather than GPT. As I suspected I can achieve this by partitioning the drive before running the installer.
A side discussion pointed me to the Foxclone utility. It will write an image to a smaller drive provided the partitions will fit. Gparted is included in the live image for this purpose. I have tested both partitioning schemes successfully.
I have a thread going over on the Mint forums asking how to cause the Mint installer to use MBR/DOS rather than GPT. As I suspected I can achieve this by partitioning the drive before running the installer.
A side discussion pointed me to the Foxclone utility. It will write an image to a smaller drive provided the partitions will fit. Gparted is included in the live image for this purpose. I have tested both partitioning schemes successfully.
Ken
It depends the size of your disk
mbr/dos is limited to smaller disks.
mbr/dos is comfort and luxus, all works easily.
Is it a large disk, like a >= 4,5.... 6 TB ?
For large disk, EFI/GPT is needed on linux.
edit: tar xvpfz / tar cvpfz is your friend.
Last edited by openbsd98324; 07-24-2022 at 03:55 PM.
I put my OS on SMALL disks and my data on LARGE disks which are GPT and encrypted with dmcrypt and Luks. For example I have a data server with 4 x 8 TB drives. I boot it from a USB flash drive - CentOS 7. This way I do not waste on of my 4 SATA ports for the boot drive and I can mirror the data drives in pairs.
I put my OS on SMALL disks and my data on LARGE disks which are GPT and encrypted with dmcrypt and Luks. For example I have a data server with 4 x 8 TB drives. I boot it from a USB flash drive - CentOS 7. This way I do not waste on of my 4 SATA ports for the boot drive and I can mirror the data drives in pairs.
Ken
you actually just need a grub on one, you could run your server out of ramdisk. I usually run linux out of ram for saving my disks.
devuan/debian can be stored on fs, you run it from squashfs-tools (see debian-scripts).
Is CentOS 7 fast enough?
I use devuan mostly for usb sticks.
(flde)
Last edited by openbsd98324; 07-24-2022 at 04:16 PM.
My "server" is just an over grown hard drive. I could use some sort of NAS but a Dell Poweredge T-30 server was a lot cheaper. Less than $200 US for the bare bones box. I boot it up only when I need to store some files to it, movie collection mostly, or to retrieve a file. I could get by with a couple of external USB hard drives I suppose or, considering the way flash memory is going, a handful of MicroSD cards or flash drives. A 1 TB MicroSD card is SCARY I could easily loose that in a physical sense. That is more data than my first 20 or more hard drives put together!
I cannot recommend clonezilla unless it is for MS Windows.
If not windows, goes to classic:
Just curious... Why is Clonezilla not recommended for other than MS Windows?
I use it (Rescuezilla) since long for my Debian system with GPT drives. Never had a problem, but want to stay ahead of that as well...;-)
Thanks in advance.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.