Moving my Void Linux from HDD to SSD

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.

  1. 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

  1. Mount both the source and target partitions
    I used the file manager… you can alternatively use mount ststements
    The resulting df 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.

  1. 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

  1. 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!

  1. Reboot and test if the new Void boots
    Carefully choose Void 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??

4 Likes

@nevj
I would leave the target partition unallocated and use clonezilla to do the clone. Or just save your Void Linux files and do a clean Void install.

1 Like

Too much work. It has docker and virt-manager and many other things that would have to be reinstalled.
I would trust rsync more than clonezilla… clonezilla is likely to do something behind my back, like fiddle with grub.

I think I have the solution.
My original Void had a grub.cfg. I left it there in the copy.
grub.cfg contains info about where the root filesystem is…
I should edit that , or easier just delete grub.cfg in the new Void and grub should boot it without a grub .cfg.

Will try today. Have you thawed yet?

Slowly, can at last see the ground!!!

1 Like

@Daniel_Phillips
Tried the following
1.Mount the new copy of Void

 # mount -t ext4 /dev/sdc5 /mnt/nevj

2.Remove grub.cfg

cd /mnt/nevj/boot/grub
mv grub.cfg grub.cfg.hide

Yes, dont actually rm it, hide it

3.Update grub again in MX23

# 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 MX 21.3 Wildflower (21.3) on /dev/sda1
Found PeppermintOS Devuan on /dev/sda12
Found Void Linux on /dev/sda5
Found Devuan GNU/Linux 5 (daedalus) on /dev/sda9
Found Void Linux on /dev/sdb7
Found Void Linux on /dev/sdc5
done
  1. reboot
    It shows 3 Void’s on the grub menu… I choose Void Linux on /dev/sdc5
    It boots, and now I seem to be in the correct ( new copy) of Void
$ df
Filesystem      1K-blocks      Used Available Use% Mounted on
devtmpfs         32867072         0  32867072   0% /dev
tmpfs            32912412         0  32912412   0% /dev/shm
tmpfs            32912412      2232  32910180   1% /run
/dev/sdc5       452448728 130179384 299212960  31% /
efivarfs              128        24       100  19% /sys/firmware/efi/efivars
cgroup           32912412         0  32912412   0% /sys/fs/cgroup
/dev/sdc1          588636       288    588348   1% /boot/efi
tmpfs            32912412         8  32912404   1% /tmp
/dev/sda4      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

So / is on sdc5
When I check /etc/fstab it is the new edited version, and

$ ls /boot/grub
fonts  grub.cfg.hide  grubenv  i386-pc  locale

there is the hidden grub.cfg file

  1. Now I can make grub.cfg again in the new Void
# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.6.11_1
Found initrd image: /boot/initramfs-6.6.11_1.img
....
Found linux image: /boot/vmlinuz-5.10.199_1
Found initrd image: /boot/initramfs-5.10.199_1.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
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 MX 23.1 Libretto (23.1) on /dev/sdc3
done

Yes, Void keeps lots of kernels

  1. Now reboot into MX23 and do update-grub there so it picks up the new grub.cfg file in Void

  2. Now reboot and test booting Void on sdc5 again !
    Yes , it is still booting the correct, new copy of Void
    SUCCESS!!

  3. The only thing I had to do in the new copy of Void was redo
    my login to itsFOSS. It would not login from the copy.
    and
    Void on SSD boots much faster than Void on HDD.

The Conclusion:

If you are going to move an OS , you should fix both /etc/fstab and
/boot/grub/cfg in the new copy, before trying to boot it.

3 Likes

There are some directories ( the ones populated at boot time, like /dev, /proc, …) for which you dont need to copy the contents. It does not matter if you do.

You can use ‘exclude’ option on rsync to avoid copying them.

1 Like
Use rsync to do the copy
rsync -aAXvH /media/nevj/VoidRH/* /media/nevj/SLinuxRH2

It is better to leave out the ‘*’, in case there are dot files in
the top level directory. That would be unusual, but better cover it, so revised version

rsync -aAXvH /media/nevj/VoidRH/  /media/nevj/SLinuxRH2
3 Likes