Occasionally we need to move a hard-install of Linux from one disk to another ( or to a different partition on the same disk, or to another computer.
This can be accomplished quite easily.
- Find the partition names, using lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 1.8T 0 disk
├─sda1 8:1 0 186.1G 0 part
├─sda3 8:3 0 293G 0 part [SWAP]
├─sda4 8:4 0 1.1T 0 part /common
├─sda5 8:5 0 1007K 0 part
├─sda6 8:6 0 512M 0 part
└─sda7 8:7 0 301.8G 0 part
sdb 8:16 0 1.8T 0 disk
├─sdb1 8:17 0 97.7G 0 part
├─sdb2 8:18 0 97.7G 0 part [SWAP]
├─sdb3 8:19 0 195.3G 0 part
├─sdb4 8:20 0 1M 0 part
├─sdb5 8:21 0 97.7G 0 part
├─sdb6 8:22 0 97.7G 0 part
├─sdb7 8:23 0 97.7G 0 part
├─sdb8 8:24 0 195.3G 0 part
├─sdb9 8:25 0 97.7G 0 part
├─sdb10 8:26 0 195.3G 0 part
├─sdb11 8:27 0 1000M 0 part
├─sdb12 8:28 0 195.3G 0 part
├─sdb13 8:29 0 68.4G 0 part
└─sdb14 8:30 0 320.4G 0 part
sdc 8:32 0 3.6T 0 disk
├─sdc1 8:33 0 576M 0 part /boot/efi
├─sdc2 8:34 0 2M 0 part
├─sdc3 8:35 0 97.7G 0 part /var/lib/docker
│ /
├─sdc4 8:36 0 195.3G 0 part /home
├─sdc5 8:37 0 439.5G 0 part /media/nevj/SLinuxRH2
└─sdc6 8:38 0 390.6G 0 part
sdd 8:48 1 0B 0 disk
sde 8:64 1 0B 0 disk
sdf 8:80 1 0B 0 disk
sdg 8:96 1 0B 0 disk
sr0 11:0 1 1024M 0 rom
Yes I have 3 disks, sda and sdb are HDD, sdc is SSD.
I want to move my Void system from sda7 to sdc5
- Mount both the source and target partitions
I used the file manager… you can alternatively usemount
ststements
The resultingdf
was
Filesystem 1K-blocks Used Available Use% Mounted on
udev 32862672 0 32862672 0% /dev
tmpfs 6581632 1724 6579908 1% /run
/dev/sdc3 100205640 19378928 75690328 21% /
tmpfs 5120 16 5104 1% /run/lock
efivarfs 128 85 39 69% /sys/firmware/efi/efivars
tmpfs 95082700 8 95082692 1% /dev/shm
/dev/sdc1 588636 288 588348 1% /boot/efi
/dev/sdc4 200476396 2355768 187864244 2% /home
/dev/sda4 1116209476 108497248 950985292 11% /common
cgroup 12 0 12 0% /sys/fs/cgroup
tmpfs 6581628 4 6581624 1% /run/user/108
tmpfs 6581628 12 6581616 1% /run/user/1000
/dev/sdc5 452448728 130179064 299213280 31% /media/nevj/SLinuxRH2
/dev/sda7 310397484 130180012 164376912 45% /media/nevj/VoidRH
the last 2 rows are the relevant partitions. The others ( sdc1,sdc4) are the Linux I am running while doing this (MX23)… it is better not to be in Void while copying itself.
- Use rsync to do the copy
rsync -aAXvH /media/nevj/VoidRH/* /media/nevj/SLinuxRH2
That took about 45mins.
4.Go into the new copy of Void and change the file /etc/fstab
to reflect the
UUID of the partition it now occupies
To find the UUIDs use blkid
$ blkid
/dev/sdb10: LABEL="LinuxHome4" UUID="f68ff5a8-c96b-402f-aa34-37c3c3680db7" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="LinuxHome4" PARTUUID="e555e7aa-09c0-426c-87d5-4211148197b3"
.....
/dev/sdc5: LABEL="SLinuxRH2" UUID="95fbb983-a8d2-452a-b33d-5687caa3b1b9" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="SLinuxRH2" PARTUUID="332e2066-1532-41f9-8041-e3afc9f2c1da"
/dev/sdc1: LABEL_FATBOOT="EFISYSTEM" LABEL="EFISYSTEM" UUID="F536-33BF" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFISystem" PARTUUID="2f9e5f96-9da6-44de-8c28-257d9ecb6777"
So sdc5 is my new / partition and sdc1 is the EFI System partiton on disk sdc
… I need to fix both of those in /etc/fstab. If there was a separate /home partition, I would need to fix that as well, but my Void is all on one partition.
So I edit /etc/fstab in the new Void partition, and it now looks like this
#dev/sdc5 root
UUID=95fbb983-a8d2-452a-b33d-5687caa3b1b9 / ext4 defaults 0 1
#/dev/sdb3 swap
UUID=23785d73-fcac-40f2-bcd6-e2a77432bdf7 none swap sw 0 0
#/dev/sda2 swap
UUID=88863b70-879c-4306-b659-da6081dba125 none swap sw 0 0
#/dev/sdc1 efi
UUID=F536-33BF /boot/efi vfat defaults 0 2
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
#/dev/sda4 /common ext4 rw 0 2
UUID=77cc1e80-1d2b-4139-b391-b1873de9cfed /common ext4 rw 0 2
#/dev/sdb14 /qemuvm ext2 rw 0 2
UUID=7aac0a79-bcaa-49b3-b60e-deca4b437b7e /qemuvm ext4 rw 0 2
The new UUID’s should match those on the blkid output
- Do update-grub in MX23 ( MX23 controls grub on the SSD disk)
root@trinity:/home/nevj# update-grub
Generating grub configuration file ...
Found theme: /boot/grub/themes/mx_linux/theme.txt
Found linux image: /boot/vmlinuz-6.5.0-1mx-ahs-amd64
Found initrd image: /boot/initrd.img-6.5.0-1mx-ahs-amd64
Found mtest-64.efi image: /boot/uefi-mt/mtest-64.efi
Found Void Linux on /dev/sda7
Found MX 21.3 Wildflower (21.3) on /dev/sdb1
Found PeppermintOS Devuan on /dev/sdb12
Found Void Linux on /dev/sdb5
Found Devuan GNU/Linux 5 (daedalus) on /dev/sdb9
Found Void Linux on /dev/sdc5
done
The last line is the new copy of Void… it found it!
- Reboot and test if the new Void boots
Carefully chooseVoid Linux on sdc5
on the grub menu
It boots… I can login … but
It seems to be still on the HDD ??
nevj@trinity ~]$ df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 32867072 0 32867072 0% /dev
tmpfs 32912412 0 32912412 0% /dev/shm
tmpfs 32912412 2240 32910172 1% /run
/dev/sdc7 310397484 130177576 164379348 45% /
efivarfs 128 115 9 94% /sys/firmware/efi/efivars
cgroup 32912412 0 32912412 0% /sys/fs/cgroup
/dev/sdc6 201633 124 201510 1% /boot/efi
tmpfs 32912412 8 32912404 1% /tmp
/dev/sdc4 1116209476 108497248 950985292 11% /common
/dev/sdb14 329584540 114421136 198348300 37% /qemuvm
none 32912412 28 32912384 1% /run/systemd
none 32912412 0 32912412 0% /run/user
tmpfs 6582480 12 6582468 1% /run/user/1000
[nevj@trinity ~]$
That /dev/sdc7 for the root partition is actually HD0… the first HDD
which was called sda when I was in MX.
What have I done wrong?
It IS the original Void, NOT the copy
I checked its /etc/fstab file… it has not been edited.
So grub has muddled up the lables in its menu??