Cloning file system: Difference between revisions
From Bradnor
No edit summary |
mNo edit summary |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 18: | Line 18: | ||
:<tt>sudo mount /dev/sdb2 /media/USB/sdb2</tt> | :<tt>sudo mount /dev/sdb2 /media/USB/sdb2</tt> | ||
:<tt>sudo mount /dev/mapper/ubuntu--vg--clone-ubuntu--lv /media/USB/sdb3</tt> | :<tt>sudo mount /dev/mapper/ubuntu--vg--clone-ubuntu--lv /media/USB/sdb3</tt> | ||
::mark disk | |||
Create file on root of disk to identify it easily as it could be mounted as /dev/sda, /dev/sdb etc, e.g. | |||
:<tt>sudo touch /disk_is_external</tt> | |||
;to boot from clone | ;to boot from clone | ||
| Line 31: | Line 35: | ||
;:modify uuid of <tt>/dev/sda1</tt> which will be mounted as <tt>/boot/efi</tt> | ;:modify uuid of <tt>/dev/sda1</tt> which will be mounted as <tt>/boot/efi</tt> | ||
::not sure how to do this reliably as yet - but probably doesn't matter | ::not sure how to do this reliably as yet - but probably doesn't matter. The disk selected from the boot source options at startup will be /<tt>dev/sda</tt> and its first partition <tt>/dev/sda1</tt> | ||
;:modify uuid of <tt>/dev/sda2</tt> which will be mounted as <tt>/boot</tt> | ;:modify uuid of <tt>/dev/sda2</tt> which will be mounted as <tt>/boot</tt> | ||
| Line 41: | Line 45: | ||
;:edit <tt>grub.cfg</tt> on <tt>/boot/efi</tt> | ;:edit <tt>grub.cfg</tt> on <tt>/boot/efi</tt> | ||
:<tt>sudo emacs /media/USB/sdb1 | :<tt>sudo emacs /media/USB/sdb1/EFI/ubuntu/grub.cfg</tt> | ||
::& change the line | ::& change the line which looks like | ||
:::<tt>search.fs_uuid 96b8896d-0474-48c4-9976-f71e754b7ca4 root hd0,gpt4 </tt> | :::<tt>search.fs_uuid 96b8896d-0474-48c4-9976-f71e754b7ca4 root hd0,gpt4 </tt> | ||
::and insert the new uuid generated previously | ::and insert the new uuid generated previously | ||
| Line 50: | Line 54: | ||
::& and add a new <tt>menuentry</tt> section (or edit the existing one) so that the referenced uuids point to the uuids of the cloned disk | ::& and add a new <tt>menuentry</tt> section (or edit the existing one) so that the referenced uuids point to the uuids of the cloned disk | ||
::& and modify the line starting <tt>linux</tt> to point to the cloned logical volume instead | ::& and modify the line starting <tt>linux</tt> to point to the cloned logical volume instead | ||
;boot | |||
::Start the old mac laptop, pressing the option key during startup to show boot menu | |||
Latest revision as of 15:51, 9 March 2026
- to clone file system
use dd to clone disk, e.g.
- sudo dd if=/dev/sda of=/dev/sdb bs=4M conv=noerror,sync status=progress
- to mount clone
principle is that the cloned volume needs to renamed before it can be mounted
- rename volume
- sudo vgimportclone --basevgname ubuntu-vg-clone /dev/sdd3
- activate
- sudo lvchange -a y 'ubuntu-vg-clone/ubuntu-lv'
- mount
- sudo mount /dev/sdb1 /media/USB/sdb1
- sudo mount /dev/sdb2 /media/USB/sdb2
- sudo mount /dev/mapper/ubuntu--vg--clone-ubuntu--lv /media/USB/sdb3
- mark disk
Create file on root of disk to identify it easily as it could be mounted as /dev/sda, /dev/sdb etc, e.g.
- sudo touch /disk_is_external
- to boot from clone
the principle is to change uuid of disks and modify grub.cfg files to reflect this. There appears to be a grub.cfg in both /boot/efi (which is separate VFAT partition on my system) and in /boot/grub (which is the ext4 boot partition). Note that the external disk is listed as /dev/sdb when we have booted normally. If we attempt to boot from the external disk it will be listed as /dev/sda
- to find current uuids a number of commands show them
- lists the physical uuids of the disks
- will display the lvm physical and logical groups and logical volumes respectively
- modify uuid of /dev/sda1 which will be mounted as /boot/efi
- not sure how to do this reliably as yet - but probably doesn't matter. The disk selected from the boot source options at startup will be /dev/sda and its first partition /dev/sda1
- modify uuid of /dev/sda2 which will be mounted as /boot
- to generate and display a new random uuid number
- where <new_uuid> is the new uuid displayed earlier
- edit grub.cfg on /boot/efi
- & change the line which looks like
- search.fs_uuid 96b8896d-0474-48c4-9976-f71e754b7ca4 root hd0,gpt4
- and insert the new uuid generated previously
- edit grub.cfg on /boot
- & and add a new menuentry section (or edit the existing one) so that the referenced uuids point to the uuids of the cloned disk
- & and modify the line starting linux to point to the cloned logical volume instead
- boot
-
- Start the old mac laptop, pressing the option key during startup to show boot menu
