Cloning a Drive in Linux via Commands: Difference between revisions

mNo edit summary
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 17: Line 17:
│ └─VG.NVMe.P4-LV.Storage  253:1    0    60G  0 lvm  /mnt/NVMEx1
│ └─VG.NVMe.P4-LV.Storage  253:1    0    60G  0 lvm  /mnt/NVMEx1
└─nvme1n1p5                259:7    0    20G  0 part [SWAP]</syntaxhighlight>And just for the below examples, /dev/sdc will be the Destination Drive.  Be really careful to identify the drive you want as the source, because all the restoration stuff is destructive to what's on the drive.
└─nvme1n1p5                259:7    0    20G  0 part [SWAP]</syntaxhighlight>And just for the below examples, /dev/sdc will be the Destination Drive.  Be really careful to identify the drive you want as the source, because all the restoration stuff is destructive to what's on the drive.
=== Before ===
Again, this assumes the same size or larger drive.  See the Resizing Drives Section at the end for information on expanding LVs and File Systems AND the appropriate time to do those resizings.


=== The Steps ===
=== The Steps ===
Line 69: Line 72:
=== Scripting ===
=== Scripting ===
Of course all this will be scripted in the future.  So basically Acronis for Linux.
Of course all this will be scripted in the future.  So basically Acronis for Linux.
=== Resizing Drives ===
Use CFDISK to resize a Partition
Use the lvextend -l +100%FREE /dev/VG.NVMe.P4/LV.Storage or lvreduce -L 300G /dev/VG.NVMe.P4/LV.Storage, to enlarge or reduce the size of an LV
Use resize2fs /dev/VG.NVMe.P4/LV.Storage to expand a File System
=== Renaming a VG or LV ===
vgrename OldName NewName
...but first: vgchange -an /dev/VG.NVMe.P3 (-ay enables it)
And then change the name in a bunch of different places like: /etc/kernel/cmdline, /etc/fstab, /etc/default/grub/, /boot/loader/entries/WhatEverEntryName, /boot/grub2/grub.cfg (only if on the booted OS: sudo grub2-mkconfig -o /boot/grub2/grub.cfg, otherwise edit the dang file)
=== IDs for Drives ===
Tune2fs for UUID:
PARTUUID: sfdisk --disk-id /dev/sda 0x40dae42c (remember, the 0x is sort of a static thing that has to preceed whatever ever value is to be changed, plus the partition number will be tacked onto the end.  IE, if one has a PARTUUID Number as 55fa144a-01 and wants to change a PARTUUID number to this, 40dae42c, add 0x, that's a zero, in front of 40dae42c, and the -01 will be tacked onto the end of it when viewing with blkid)
=== Drive Creation and LVMs (Logical Volume Management SYSTEMs) ===
cfdisk
pvcreate /dev/nvme2n1p1
vgcreate VG.NVMEx1.P1 /dev/nvme2n1p1
lvcreate -L 460G -n LV.Storage VG.NVMEx1.P1
mkfs.ext4 -L Storage_NVMEx1 -v /dev/VG.NVMEx1.P1/LV.Storage
pvs, vgs, lvs AND pvdisplay, vgdisplay, lvdisplay


=== And for the Critics ===
=== And for the Critics ===