LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 07-24-2022, 08:16 AM   #1
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Rep: Reputation: 174Reputation: 174
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.
Code:
sudo rsync -r -l -H -p -E -o -g --devices --specials -t -v  /run/media/ken/PI_BOOT/* /xtra/store_boot

sudo rsync -r -l -H -p -E -o -g --devices --specials -t -v  /run/media/ken/PI_ROOT/* /xtra/store_root

sudo rsync -r -l -H -p -E -o -g --devices --specials -t -v  /xtra/store_boot/* /run/media/ken/PI_BOOT/ 

sudo rsync -r -l -H -p -E -o -g --devices --specials -t -v  /xtra/store_root/* /run/media/ken/PI_ROOT/
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.
 
Old 07-24-2022, 08:51 AM   #2
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,150

Rep: Reputation: 393Reputation: 393Reputation: 393Reputation: 393
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.
 
Old 07-24-2022, 09:08 AM   #3
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thank you jmgibson1981,

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.

Ken
 
Old 07-24-2022, 03:09 PM   #4
openbsd98324
Member
 
Registered: Feb 2022
Posts: 72

Rep: Reputation: 5
you can use whatever live like devuan live or ... slackware.
or https://gitlab.com/openbsd98324/flde-live/ <--- it is the best for classic MBR.

I cannot recommend clonezilla unless it is for MS Windows.
If not windows, goes to classic:

Code:
mount /dev/sda4 /mnt
cd /mnt
tar cvpfz allmydisk.tar.gz *
then.
Code:
cd /target
tar xvpfz allmydisk.tar.gz
 
Old 07-24-2022, 03:41 PM   #5
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks openbsd98324,

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
 
Old 07-24-2022, 03:54 PM   #6
openbsd98324
Member
 
Registered: Feb 2022
Posts: 72

Rep: Reputation: 5
Quote:
Originally Posted by taylorkh View Post
Thanks openbsd98324,

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.
 
Old 07-24-2022, 04:05 PM   #7
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks again for your input openbsd98324,

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
 
Old 07-24-2022, 04:15 PM   #8
openbsd98324
Member
 
Registered: Feb 2022
Posts: 72

Rep: Reputation: 5
Quote:
Originally Posted by taylorkh View Post
Thanks again for your input openbsd98324,

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.
 
Old 07-24-2022, 05:08 PM   #9
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
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!

Ken
 
Old 07-25-2022, 03:26 PM   #10
remmilou
Member
 
Registered: Mar 2010
Location: Amsterdam
Distribution: MX Linux (21)/ XFCE
Posts: 212

Rep: Reputation: 69
Quote:
Originally Posted by openbsd98324 View Post
you can use whatever live like devuan live or ... slackware.
or https://gitlab.com/openbsd98324/flde-live/ <--- it is the best for classic MBR.

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.
 
Old 07-25-2022, 05:23 PM   #11
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
According to the Clonezilla web site is seems to handle just about any situation. Same for Rescuezilla. Not sure where you got that information from.

Ken
 
Old 07-25-2022, 05:55 PM   #12
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Many many users use clonezilla with linux.
That particular user thought it should only be for windows but no, it works on linux really well in fact.
 
Old 07-28-2022, 11:17 PM   #13
kleinde66
Member
 
Registered: Nov 2008
Location: Mid Atlantic
Distribution: debian cbpp11 mabox.22.09
Posts: 97
Blog Entries: 9

Rep: Reputation: 2
i'v used it a lot, you can add the iso to grub2, and copy the cd.iso to you hdd .
i like systemback also.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Boot a GPT-partitioned hard drive from a non-UEFI machine tramni1980 *BSD 8 11-11-2018 07:12 AM
fdisk sees 2TB HDDs as GPT partitioned... Should I leave this or remove it? Aunnix Linux - Hardware 5 11-18-2012 04:52 PM
Cloning dual-boot drive onto a smaller drive. Harju Linux - Newbie 4 05-29-2010 11:40 AM
how to format an EFI partition on a GPT partitioned HD nfolken Linux - Laptop and Netbook 2 01-28-2010 08:59 AM
Need to know the command which shows all non-partitioned & partitioned hard drive saidul Linux - Newbie 2 12-04-2007 04:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:58 AM.

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