Sunday, April 28, 2024
42
rated 0 times [  42] [ 0]  / answers: 1 / hits: 49159  / 1 Year ago, wed, february 22, 2023, 5:34:39

I have the following situation:



My current Ubuntu (12.04) installation is running from an external HDD (250 GB) because I was to lazy to buy an new internal hdd. Now i've got a new internal (120GB) and i want to move everything to the internal. Installing Ubuntu new is out of disscussion because its to peronalized.



Luckily (i hope so) the root partition is partitioned with LVM, so i hope i can move the partition to the smaller internal HDD.



Is this possible? And where do i find help?



EDIT: This question already is quite old and could be outdated. I added the Ubuntu version that was used back then.


More From » partitioning

 Answers
6

As you suspect, this is extremely elegant to do using LVM.



Shrink the existing installation to fit the smaller disk.



Physically install the new harddisk, format and pvcreate it, use vgextend to add it to the same vg as your root partition



Use pvmove to transparently move all data away from the old partition



Use vgreduce to remove your external hd from your vg. Unplug the old disk /dev/sdOLD.



In the example below:




  • /dev/sdOLD stands for the old partition to replace

  • /dev/sdNEW stands for the new partition to take its place.

  • vgX stands for the volume group



Example: Of course, you have to be 100% sure that your are using the right devices. Also, having complete and up-to-date backups, removed from the system, is essential.



pvcreate /dev/sdNEW
vgextend vgX /dev/sdNEW
pvmove /dev/sdOLD
vgreduce vgX /dev/sdOLD


Use update-grub and grub-install to make your new root disk bootable



Done.


[#37000] Thursday, February 23, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
whoppinolo

Total Points: 93
Total Questions: 113
Total Answers: 107

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
;