Clone Linux disk to a larger drive and extend partitions
UbuntuThis forum is for the discussion of Ubuntu Linux.
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.
Clone Linux disk to a larger drive and extend partitions
Greetings,
I currently have an Ubuntu media server running on a 500GB drive. I am finding that the drive is too small for holding my data, so interested in migrating the server to a newer larger drive. I don't want to go through all the hassle of having to rebuild and configure the server, so I am interested in what would be the best method to clone the current drive to a larger one (in this case a 3 TB drive), and expand the partitions once the drive has been cloned.
My drive is currently set up as the following:
257.03 MB Linux EXT uses for /boot
29.36 GB ext4 for root
7.89 GB swap
428 GB ext4 for media storage
I tend to have issues where once in a while, the server fails to boot as the boot partition fills up. One a month I run an app called Ubuntu Tweak - Janitor, to clean up unnecessary system files, which seems to keep this issue at bay, however migrating my server to a larger drive and then expanding these partitions to be a bit bigger should be able to help this issue even further.
I am interested in what would be the best course of action to perform this task. I am thinking a combination of Clonezilla and gparted would do the trick, but any suggestions would be welcomed. I'm fairly new with Linux so unsure what the best options or method to do this task would be.
Can you fit both disks physically in the box ?. If so just add the new disk to LVM, and extend the data lv on the fly. Easy.
As for that /boot, I'd get rid of it altogether, but it is not a trivial matter. Later maybe.
Can't fit both disks in the same box, as the system is a NUC, however I have a USB 3 to SATA cable that is recognized by Ubuntu. I created a backup of the media, although unsure on how to back up the system partition. I have another 500GB drive so may just create a direct clone to that drive to use as a backup.
For the /boot, interested in how I could get rid of that. I'll do some poking on the Internet on that subject. I would be very happy either expand the
space for /boot or go about it in a different way so that it doesn't fill up so quickly.
In that case clonezilla might be a good bet.
Take an image, say to that other 500G, then you can do all the work using the live clonezilla on any machine - might be more convenient. Set up the new disk partitions and just restore it as partitions, not "image". For the new disk I'd use gpt so you can easily use all the space - may make the final restore a bit more "interesting" though. If you do it on a partition-by-partition basis you should be ok, but you would need to chroot into the new disk and re-install grub - well documented for Ubuntu.
Another option is to use fsarchiver - it creates a single file backup of an entire filesystem. CRC checked. You can restore to any partition of sufficient size. Foolproof. But you will need to set up the partitions and LVM in advance, and fix fstab and the boot-loader after the (root) restore.
I have used fsarchiver like that and it is great. Many years ago I looked at clonezilla and had some issues with it (which I can't recall), so I've never got back to it. Not near the top of my to-do list.
The good news is that it doesn't matter if you stuff up - just wipe the 3T disk and start again. Your original disk is the ultimate backup. As for /boot, forget about it for now, you will be sufficiently stressed by this. Getting the LVM support correct in the initramfs isn't straight-forward after the fact - and the Ubuntu devs don't seem confident enough to offer it as an option on initial install. So ...
Moving the root partition to a new drive > Tutorial
So essentially, I wouldn't need to clone at all. I could use this tutorial to migrate my whole media server to a new larger drive by using gparted. Sounds like I can just create the partitions in the sizes that I want, and then just copy them over. Interesting. I will give this a try
You will see that the original Mint partition and the new copy both have the same UUID number. This is a bad situation which MUST be corrected before you reboot.
What would happen if the machine crashed before you could make that correction, and you were forced to reboot?
Last edited by Dave Lerner; 05-12-2017 at 04:27 PM.
rknichols is right - simply disconnect one of the drives.
What would happen if you reboot without changing the UUID number is that your operating system would not know which partition is the root partition, and would use both simultaneously and randomly. Sounds stange, right? And it would give you strange results. For example, if you edited /etc/fstab or any other system file, you would not know which of the 2 fstab files was actually changed.
Been there... Done that...
Last edited by TxLonghorn; 05-13-2017 at 06:43 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.