Cloning file system: Difference between revisions
From Bradnor
Created page with "⇐ Notes ;to clone file system use dd to clone disk, e.g." |
mNo edit summary |
||
| (10 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
;to clone file system | ;to clone file system | ||
use dd to clone disk, e.g. | use dd to clone disk, e.g. | ||
:<tt>sudo dd if=/dev/sda of=/dev/sdb bs=4M conv=noerror,sync status=progress</tt> | |||
;to mount clone | |||
principle is that the cloned volume needs to renamed before it can be mounted | |||
::rename volume | |||
:<tt>sudo vgimportclone --basevgname ubuntu-vg-clone /dev/sdd3</tt> | |||
::activate | |||
:<tt>sudo lvchange -a y 'ubuntu-vg-clone/ubuntu-lv'</tt> | |||
::mount | |||
:<tt>sudo mount /dev/sdb1 /media/USB/sdb1</tt> | |||
:<tt>sudo mount /dev/sdb2 /media/USB/sdb2</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 | |||
the principle is to change uuid of disks and modify <tt>grub.cfg</tt> files to reflect this. There appears to be a <tt>grub.cfg</tt> in both <tt>/boot/efi</tt> (which is separate VFAT partition on my system) and in <tt>/boot/grub</tt> (which is the ext4 boot partition). Note that the external disk is listed as <tt>/dev/sdb</tt> when we have booted normally. If we attempt to boot from the external disk it will be listed as <tt>/dev/sda</tt> | |||
;: to find current uuids a number of commands show them | |||
:<tt>sudo blkid</tt> | |||
::lists the physical uuids of the disks | |||
:<tt>sudo pvdisplay</tt> | |||
:<tt>sudo vgdisplay</tt> | |||
:<tt>sudo lvdisplay</tt> | |||
::will display the lvm physical and logical groups and logical volumes respectively | |||
;: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. 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> | |||
:<tt>sudo uuidgen</tt> | |||
::to generate and display a new random uuid number | |||
:<tt>sudo tune2fs -U <new_uuid> /dev/sdb2</tt> | |||
::where <tt><new_uuid></tt> is the new uuid displayed earlier | |||
;:edit <tt>grub.cfg</tt> on <tt>/boot/efi</tt> | |||
:<tt>sudo emacs /media/USB/sdb1/EFI/ubuntu/grub.cfg</tt> | |||
::& change the line which looks like | |||
:::<tt>search.fs_uuid 96b8896d-0474-48c4-9976-f71e754b7ca4 root hd0,gpt4 </tt> | |||
::and insert the new uuid generated previously | |||
;:edit <tt>grub.cfg</tt> on <tt>/boot</tt> | |||
:sudo emacs /media/USB/sdb2/grub/grub.cfg</tt> | |||
::& 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 | |||
;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
