LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 05-11-2017, 12:19 AM   #1
torbuck
LQ Newbie
 
Registered: Jun 2015
Posts: 7

Rep: Reputation: Disabled
Question 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.

Appreciate any feedback!

Cheers,
Torbuck
 
Old 05-11-2017, 12:41 AM   #2
torbuck
LQ Newbie
 
Registered: Jun 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Post

Here is the output of a sudo parted -l:

Code:
Model: ATA ST95005620AS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size   Type      File system  Flags
 1      1049kB  256MB  255MB  primary   ext2         boot
 2      257MB   500GB  500GB  extended
 5      257MB   500GB  500GB  logical                lvm


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/NUCmedia--vg-swap_1: 8472MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system     Flags
 1      0.00B  8472MB  8472MB  linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/NUCmedia--vg-NUCstorage: 460GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End    Size   File system  Flags
 1      0.00B  460GB  460GB  ext4


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/NUCmedia--vg-root: 31.5GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system  Flags
 1      0.00B  31.5GB  31.5GB  ext4
 
Old 05-11-2017, 12:46 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
Old 05-11-2017, 11:09 AM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Moderator response

Moved: This thread is more suitable in <Ubuntu> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 05-11-2017, 03:01 PM   #5
torbuck
LQ Newbie
 
Registered: Jun 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
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.

Appreciate the feedback!

Thanks,

Torbuck
 
Old 05-11-2017, 07:06 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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 ...
 
Old 05-11-2017, 07:29 PM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i've had good luck with using dd to image 2 gb of a disk and then using gparted to expand the empty storage.
 
Old 05-12-2017, 05:27 AM   #8
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Moving the root partition to a new drive > Tutorial
 
2 members found this post helpful.
Old 05-12-2017, 05:40 AM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
The things you learn - didn't know gparted did that. Should simplify things.
 
Old 05-12-2017, 10:48 AM   #10
torbuck
LQ Newbie
 
Registered: Jun 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Talking

Quote:
Originally Posted by TxLonghorn View Post
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

Thanks!
 
Old 05-12-2017, 04:25 PM   #11
Dave Lerner
Member
 
Registered: May 2005
Location: Florida, USA
Distribution: Pop_OS, Xubuntu
Posts: 152

Rep: Reputation: 44
I'm curious about something in that tutorial:

Quote:
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.
 
Old 05-12-2017, 04:30 PM   #12
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Quote:
Originally Posted by Dave Lerner View Post
What would happen if the machine crashed before you could make that correction, and you were forced to reboot?
You would have to boot into a rescue DVD and straighten things out.

-------------------------
Steve Stites
 
1 members found this post helpful.
Old 05-12-2017, 04:41 PM   #13
Dave Lerner
Member
 
Registered: May 2005
Location: Florida, USA
Distribution: Pop_OS, Xubuntu
Posts: 152

Rep: Reputation: 44
Thanks, that was my guess.
 
Old 05-12-2017, 06:31 PM   #14
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by jailbait View Post
You would have to boot into a rescue DVD and straighten things out.
Or, simply disconnect one of the drives (presumably the new drive with the copy).
 
1 members found this post helpful.
Old 05-13-2017, 06:41 AM   #15
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Red face

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.
 
1 members found this post helpful.
  


Reply

Tags
clone, partitionioning



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
Want to clone Windows Server 2003 to larger hard drive ZapTheSheep General 4 04-18-2011 06:57 PM
Need more details on how to clone a larger disk to smaller with cp Mountain Linux - General 27 07-13-2010 11:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 05:16 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