Sunday 15th apr 2018
I success to clone a 128GB SSD (incl LVM) to a bigger one 256GB SSD samsung evo and install Windows 10 on a new primary partition. I want to share it with you.
tools: "live cd", gparted and a lot of patience :-). Thnaks to Kaboyish for his link about chroot/grub-update. kali & ubuntu release were from 2017.
Happy reading...
Old 128GB SSD - >256GB ssd Samsung evo
sda has kali (using sda6) , Ubuntu (using LVM on sda5). Boot menu is kali
sdb is my new 256GB
My goal: clone kali, Ubuntu to my new 256GB Samsung ssd and having a 110GB partition for windows 10. Boot menu is still kali
1) cloning
fdisk –l /dev/sda
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux ; boot grub
/dev/sda2 1001470 250068991 249067522 118,8G 5 Extended
/dev/sda5 1001472 159623167 158621696 75,7G 8e Linux LVM ; Ubuntu LVM
/dev/sda6 159625216 238493695 78868480 37,6G 83 Linux ; kali
/dev/sda7 238495744 250068991 11573248 5,5G 82 Linux swap / Solaris ; swap for kali
Disk /dev/mapper/ubuntu--vg-root: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ubuntu--vg-swap_1: 15,6 GiB, 16785604608 bytes, 32784384 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Boot your laptop from for example “mint boot DVD”. The new ssd is connect using ssd adapter to usb.
mint ~ # time dd if=/dev/sda of=/dev/sdb bs=8192 conv=notrunc,noerror
NB: from another session using “kill –USR1 ” to get progress/statistics for every 10s
watch -n10 sudo kill -USR1 $(pgrep ^dd)
990054+0 records in
990054+0 records out
8110522368 bytes (8.1 GB) copied, 183.261 s, 44.3 MB/s
2227622+0 records in
2227622+0 records out
18248679424 bytes (18 GB) copied, 412.6 s, 44.2 MB/s
6271782+0 records in
6271782+0 records out
51378438144 bytes (51 GB) copied, 1149.82 s, 44.7 MB/s
10460314+0 records in
10460314+0 records out
85690892288 bytes (86 GB) copied, 1920.88 s, 44.6 MB/s
15369910+0 records in
15369910+0 records out
125910302720 bytes (126 GB) copied, 2827.02 s, 44.5 MB/s
15629355+0 records in
15629355+0 records out
128035676160 bytes (128 GB) copied, 2874.86 s, 44.5 MB/s
real 47m54.867s
user 0m1.600s
sys 2m41.036s
mint ~ # date
Thu Apr 12 21:14:34 UTC 2018
Successfull, i replace the internal 128GB with the now cloned Samsung evo 256GB. It boots, I get kali grub menu as before, I choose kali, boot ok. Reboot I choose Ubuntu, boot also OK.
2) Reorganized the partition
I boot from usb “gparted live cd”, remove kali swap (kali was smart it uses Ubuntu lvm swap partition when I start it) and making a new primary partition for windows ntfs, ready for win10.
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sda 8:0 0 232,9G 0 disk
├─sda4 8:4 0 785M 0 part
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 75,7G 0 part
│ ├─ubuntu--vg-swap_1 253:1 0 15,6G 0 lvm [SWAP] UBUNTU
│ └─ubuntu--vg-root 253:0 0 60G 0 lvm / UBUNTU
├─sda3 8:3 0 112,9G 0 part 112Gb win10
├─sda1 8:1 0 487M 0 part /boot
└─sda6 8:6 0 43,1G 0 part KALI
$
3) Install win10 on sda3
I then install win10 on sda3, unfornutely it remove grub boot on sda, now I can only boot to win10. I need to have kali boot menu back as before.
4) Restore the kali grub menu (the menu will control all the boot partitions on sda)
Using chroot trick from to fix the grub issue
https://forums.kali.org/showthread.php?20559-How-To-Repair-Kali-Linux-Grub-With-Kali-Linux-Live-Cd-Dual-Boot-With-Windows-7
I boot from “kali” LIVE DVD.
mount /dev/sda6 /mnt ; my kali partition
mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt ; if this fail check if the boot DVD is 32 or 64bit as your kali installation
grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
update-grub ;it search for all the boot partition on the new disk sda
exit; it will quit chroot
umount /mnt/dev/pts
umount /mnt/dev
umount /mnt/proc
umount /mnt/sys
umount /mnt
stdout: just ignore the warning about lvmetad (LVM), it boots well to all 3 OS!! Something with LVM, don’t need to do anything about this.
root@kali:/# update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-4.9.0-kali4-amd64
Found initrd image: /boot/initrd.img-4.9.0-kali4-amd64
Found linux image: /boot/vmlinuz-4.9.0-kali3-amd64
Found initrd image: /boot/initrd.img-4.9.0-kali3-amd64
WARNING: Failed to connect to lvmetad. Falling back to device scanning.
WARNING: Failed to connect to lvmetad. Falling back to device scanning.
WARNING: Failed to connect to lvmetad. Falling back to device scanning.
Found Windows 10 on /dev/sda3
WARNING: Failed to connect to lvmetad. Falling back to device scanning.
WARNING: Failed to connect to lvmetad. Falling back to device scanning.
Found Ubuntu 16.04.2 LTS (16.04) on /dev/mapper/ubuntu--vg-root
done
root@kali:/#
DONE, now i have 3 OS on the new 256GB samsung.
Nb:
change run level in kali/debian , not work!
root@kali:/etc# ls -l /etc/systemd/system/default.target
lrwxrwxrwx 1 root root 37 Jun 22 2017 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target
root@kali:/etc# ls -l /lib/systemd/system/default.target
lrwxrwxrwx 1 root root 16 Jun 19 2017 /lib/systemd/system/default.target -> graphical.target
root@kali:/etc# systemctl set-default graphical.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/graphical.target.
root@kali:/etc# ls -l /etc/systemd/system/default.target
lrwxrwxrwx 1 root root 36 Apr 15 16:47 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target
Change grub boot order: set boot-default to 3 ; work OK
root@kali:~# cd /etc/default/
root@kali:/etc/default# vi grub
root@kali:/etc/default# update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-4.9.0-kali4-amd64
Found initrd image: /boot/initrd.img-4.9.0-kali4-amd64
Found linux image: /boot/vmlinuz-4.9.0-kali3-amd64
Found initrd image: /boot/initrd.img-4.9.0-kali3-amd64
Found Windows 10 on /dev/sda3
Found Ubuntu 16.04.2 LTS (16.04) on /dev/mapper/ubuntu--vg-root
done
root@kali:/etc/default# root@kali:~# cd /etc/default/
Boot screen
GOOD LUCK
Tuan CPH
I have ubuntu installed in legacy mode on a uefi BIOS. I tried Clonezilla many times, but, even if all was copied corrected I got problems with the grub (because of something between uefi/legacy). I finally solved with this command. thank you!! – linofex – 2018-11-14T09:11:24.260
Will this work with encrypted LVM without any changes to the approach? – wuno – 2020-01-05T07:42:05.010
@wuno Not sure, never used LVM, neither normal, nor encrypted. Try it out and comment, please. – LinuxSecurityFreak – 2020-01-05T12:51:55.680