Clone (disk to disk) Ubuntu (14.x) LVM2 to a larger harddisk with Clonezilla and GParted and allocate free space within Ubuntu

  • Post published:October 30, 2017

How to clone Ubuntu 14.04.5 LTS (GNU/Linux 3.16.0-30-generic i686) to a larger disk?

In the following I’ll go through the process of expanding a lvm2-pv image that holds ubuntu-root to a larger disk!

 

A Clonezilla

A1 Prepare LIVE USB (clone clonzilla http://clonezilla.org/downloads.php via etcher https://etcher.io to usb pendrive)

A2 Boot your Clonezilla LIVE via USB

A3 Clonezilla live (Default settings, VGA 800×600)
Choose language
Choose keyboard layout
Choose “Start Clonezilla”
Choose “device-device” (work directly…)
Choose “Beginner”
Choose “disk_to_local_disk”
Choose source disk
Choose target disk
Choose -sfsck
Choose -pa choose
Start Cloning (accept confirmations)
Choose poweroff

 

B Gparted

B1 Prepare LIVE USB (clone gparted https://gparted.org/download.php via etcher https://etcher.io to usb pendrive)

B2 Boot your GParted LIVE via USB

B3 Open GParted
Select “cloned disk”
Select “unused disk space” and remove, apply
Select partion and resize, apply
Select lvm2 partition resize, apply

 

C Expand the root filesystem

C1 Find the main logical volume:
s…@ubuntu-s…:~$ sudo lvdisplay
— Logical volume —
LV Path /dev/ubuntu-seafile-vg/root
LV Name root
VG Name ubuntu-seafile-vg
LV UUID S…
LV Write Access read/write
LV Creation host, time ubuntu-seafile, 201…
LV Status available
# open 1
LV Size 147,82 GiB
Current LE 37841
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 252:0

— Logical volume —
LV Path /dev/ubuntu-seafile-vg/swap_1
LV Name swap_1
VG Name ubuntu-seafile-vg
LV UUID u…
LV Write Access read/write
LV Creation host, time ubuntu-seafile, 201…
LV Status available
# open 2
LV Size 1016,00 MiB
Current LE 254
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 252:1

C2 Extend the logical volume to all free space available:
s…@ubuntu-s…~$ sudo lvextend -l+100%FREE /dev/ubuntu-seafile-vg/root
Extending logical volume root to 930,28 GiB
Logical volume root successfully resized

C3 Extend the filesystem:
s..@ubuntu-s…:~$ sudo resize2fs /dev/mapper/ubuntu–seafile–vg-root
resize2fs 1.42.9 (4-Feb-2014)
Das Dateisystem auf /dev/mapper/ubuntu–seafile–vg-root ist auf / eingehängt; Online-Grössenveränderung nötig
old_desc_blocks = 10, new_desc_blocks = 59
Das Dateisystem auf /dev/mapper/ubuntu–seafile–vg-root ist nun 243866624 Blöcke groß.

C4 Check free space:
s…@ubuntu-s…:~$ df -h
Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf
udev 487M 4,0K 487M 1% /dev
tmpfs 100M 620K 99M 1% /run
/dev/dm-0 916G 138G 739G 16% /
none 4,0K 0 4,0K 0% /sys/fs/cgroup
none 5,0M 0 5,0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda1 236M 39M 185M 18% /boot