How do I move my LVM 250 GB root partition to a new 120GB hard disk?
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.
partitioning lvm
add a comment |
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.
partitioning lvm
related question -- the above answers are not clear enough...
– MeSo2
Feb 16 '18 at 20:06
the above two answers are not clear enough to me. So a started a new post.
– MeSo2
Feb 16 '18 at 20:10
add a comment |
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.
partitioning lvm
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.
partitioning lvm
partitioning lvm
edited Feb 19 '18 at 12:27
NotANormalNerd
asked Jul 8 '12 at 19:15
NotANormalNerdNotANormalNerd
200127
200127
related question -- the above answers are not clear enough...
– MeSo2
Feb 16 '18 at 20:06
the above two answers are not clear enough to me. So a started a new post.
– MeSo2
Feb 16 '18 at 20:10
add a comment |
related question -- the above answers are not clear enough...
– MeSo2
Feb 16 '18 at 20:06
the above two answers are not clear enough to me. So a started a new post.
– MeSo2
Feb 16 '18 at 20:10
related question -- the above answers are not clear enough...
– MeSo2
Feb 16 '18 at 20:06
related question -- the above answers are not clear enough...
– MeSo2
Feb 16 '18 at 20:06
the above two answers are not clear enough to me. So a started a new post.
– MeSo2
Feb 16 '18 at 20:10
the above two answers are not clear enough to me. So a started a new post.
– MeSo2
Feb 16 '18 at 20:10
add a comment |
2 Answers
2
active
oldest
votes
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.
It would have been nice if you had provided concrete examples.
– isaaclw
Jan 5 '13 at 0:50
12
Ah, that's nice voting down a valid accepted post with helpful information. I intentionally did NOT give a concrete example, because the danger is that someone will mindlessly copy-paste that and destroy his/her data. If you do anything with lvm, you should be able to find you bearing with the pointers i give.
– Floyd
Jan 5 '13 at 14:28
1
Worked on Cento7 As well. Steps provided here were enough for me to learn a little and google a little. Spot-on
– terary
Mar 17 '18 at 8:07
centos: use grub2-mkconfig -o "$(readlink -e /etc/grub2.cfg)" ... from here
– terary
Mar 17 '18 at 10:57
add a comment |
First, if you used the whole 250GB disk for your current installation, you'll need to shrink it to fit the 120GB disk. You can only shrink an ext4 filesystem while it's unmounted, so you'll need to boot off an Ubuntu live system (CD or USB), or a specialized maintenance live system such as GParted live. You can use resize2fs
or GParted to resize the existing filesystem.
Once you've shrunk the filesystem(s) of your existing installation to fit on the new disk, you can do the rest of the move with the filesystem mounted if you like. If the existing filesystem fits on the new disk, you can do the transfer without unmounting anything or rebooting.
In the following description, I'll show how to move from the physical volume /dev/sdb1
to the physical volume /dev/sda1
, with an existing volume group called oldvg
. Be sure to adjust the disk letters and partition numbers to match your system.
To do a live transfer:
- Partition the new disk, using the partitioning tool of your choice (
cfdisk
,fdisk
,parted
, …). See e.g. How do I add an additional hard drive?
- Create a physical volume on the new disk:
pvcreate /dev/sda1
- Add this physical volume to the existing volume group containing the logical volume(s) you want to move:
vgextend oldvg /dev/sda1
- Move the logical volumes from one physical volume to another:
pvmove /dev/sdb1 /dev/sda1
- Split the existing volume group in two:
vgsplit oldvg newvg /dev/sda1
Another method is to make the existing logical volume(s) a mirror volume with lvconvert --mirror
, set up a mirror on the new disk, then split the mirrors with lvconvert --splitmirrors
. This way, you end up with two copies of your data, and after the split each copy leads its own life.
After you've done the copy, you'll need to make the new disk bootable. Mount the filesystem for this. Assuming it's mounted on /mnt
, run these commands as root:
chroot /mnt
# if the name of the volume group has changed, edit /etc/fstab
update-grub
grub-install /dev/sda
Alternatively, you might be able to use Clonezilla. This is a powerful disk manipulation and cloning tool, and I think it covers your situation, but I have no experience with it.
1
How an answer that basically sayspvadd, pvmove, pvremove
gets accepted over THIS is beyond me...
– ish
Jul 8 '12 at 21:01
Much too complicated and not what he needs
– Floyd
Jul 9 '12 at 5:19
add a comment |
protected by Community♦ Jan 21 at 9:25
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
It would have been nice if you had provided concrete examples.
– isaaclw
Jan 5 '13 at 0:50
12
Ah, that's nice voting down a valid accepted post with helpful information. I intentionally did NOT give a concrete example, because the danger is that someone will mindlessly copy-paste that and destroy his/her data. If you do anything with lvm, you should be able to find you bearing with the pointers i give.
– Floyd
Jan 5 '13 at 14:28
1
Worked on Cento7 As well. Steps provided here were enough for me to learn a little and google a little. Spot-on
– terary
Mar 17 '18 at 8:07
centos: use grub2-mkconfig -o "$(readlink -e /etc/grub2.cfg)" ... from here
– terary
Mar 17 '18 at 10:57
add a comment |
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.
It would have been nice if you had provided concrete examples.
– isaaclw
Jan 5 '13 at 0:50
12
Ah, that's nice voting down a valid accepted post with helpful information. I intentionally did NOT give a concrete example, because the danger is that someone will mindlessly copy-paste that and destroy his/her data. If you do anything with lvm, you should be able to find you bearing with the pointers i give.
– Floyd
Jan 5 '13 at 14:28
1
Worked on Cento7 As well. Steps provided here were enough for me to learn a little and google a little. Spot-on
– terary
Mar 17 '18 at 8:07
centos: use grub2-mkconfig -o "$(readlink -e /etc/grub2.cfg)" ... from here
– terary
Mar 17 '18 at 10:57
add a comment |
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.
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.
edited Jul 15 '16 at 9:48
answered Jul 8 '12 at 20:12
FloydFloyd
1,29811116
1,29811116
It would have been nice if you had provided concrete examples.
– isaaclw
Jan 5 '13 at 0:50
12
Ah, that's nice voting down a valid accepted post with helpful information. I intentionally did NOT give a concrete example, because the danger is that someone will mindlessly copy-paste that and destroy his/her data. If you do anything with lvm, you should be able to find you bearing with the pointers i give.
– Floyd
Jan 5 '13 at 14:28
1
Worked on Cento7 As well. Steps provided here were enough for me to learn a little and google a little. Spot-on
– terary
Mar 17 '18 at 8:07
centos: use grub2-mkconfig -o "$(readlink -e /etc/grub2.cfg)" ... from here
– terary
Mar 17 '18 at 10:57
add a comment |
It would have been nice if you had provided concrete examples.
– isaaclw
Jan 5 '13 at 0:50
12
Ah, that's nice voting down a valid accepted post with helpful information. I intentionally did NOT give a concrete example, because the danger is that someone will mindlessly copy-paste that and destroy his/her data. If you do anything with lvm, you should be able to find you bearing with the pointers i give.
– Floyd
Jan 5 '13 at 14:28
1
Worked on Cento7 As well. Steps provided here were enough for me to learn a little and google a little. Spot-on
– terary
Mar 17 '18 at 8:07
centos: use grub2-mkconfig -o "$(readlink -e /etc/grub2.cfg)" ... from here
– terary
Mar 17 '18 at 10:57
It would have been nice if you had provided concrete examples.
– isaaclw
Jan 5 '13 at 0:50
It would have been nice if you had provided concrete examples.
– isaaclw
Jan 5 '13 at 0:50
12
12
Ah, that's nice voting down a valid accepted post with helpful information. I intentionally did NOT give a concrete example, because the danger is that someone will mindlessly copy-paste that and destroy his/her data. If you do anything with lvm, you should be able to find you bearing with the pointers i give.
– Floyd
Jan 5 '13 at 14:28
Ah, that's nice voting down a valid accepted post with helpful information. I intentionally did NOT give a concrete example, because the danger is that someone will mindlessly copy-paste that and destroy his/her data. If you do anything with lvm, you should be able to find you bearing with the pointers i give.
– Floyd
Jan 5 '13 at 14:28
1
1
Worked on Cento7 As well. Steps provided here were enough for me to learn a little and google a little. Spot-on
– terary
Mar 17 '18 at 8:07
Worked on Cento7 As well. Steps provided here were enough for me to learn a little and google a little. Spot-on
– terary
Mar 17 '18 at 8:07
centos: use grub2-mkconfig -o "$(readlink -e /etc/grub2.cfg)" ... from here
– terary
Mar 17 '18 at 10:57
centos: use grub2-mkconfig -o "$(readlink -e /etc/grub2.cfg)" ... from here
– terary
Mar 17 '18 at 10:57
add a comment |
First, if you used the whole 250GB disk for your current installation, you'll need to shrink it to fit the 120GB disk. You can only shrink an ext4 filesystem while it's unmounted, so you'll need to boot off an Ubuntu live system (CD or USB), or a specialized maintenance live system such as GParted live. You can use resize2fs
or GParted to resize the existing filesystem.
Once you've shrunk the filesystem(s) of your existing installation to fit on the new disk, you can do the rest of the move with the filesystem mounted if you like. If the existing filesystem fits on the new disk, you can do the transfer without unmounting anything or rebooting.
In the following description, I'll show how to move from the physical volume /dev/sdb1
to the physical volume /dev/sda1
, with an existing volume group called oldvg
. Be sure to adjust the disk letters and partition numbers to match your system.
To do a live transfer:
- Partition the new disk, using the partitioning tool of your choice (
cfdisk
,fdisk
,parted
, …). See e.g. How do I add an additional hard drive?
- Create a physical volume on the new disk:
pvcreate /dev/sda1
- Add this physical volume to the existing volume group containing the logical volume(s) you want to move:
vgextend oldvg /dev/sda1
- Move the logical volumes from one physical volume to another:
pvmove /dev/sdb1 /dev/sda1
- Split the existing volume group in two:
vgsplit oldvg newvg /dev/sda1
Another method is to make the existing logical volume(s) a mirror volume with lvconvert --mirror
, set up a mirror on the new disk, then split the mirrors with lvconvert --splitmirrors
. This way, you end up with two copies of your data, and after the split each copy leads its own life.
After you've done the copy, you'll need to make the new disk bootable. Mount the filesystem for this. Assuming it's mounted on /mnt
, run these commands as root:
chroot /mnt
# if the name of the volume group has changed, edit /etc/fstab
update-grub
grub-install /dev/sda
Alternatively, you might be able to use Clonezilla. This is a powerful disk manipulation and cloning tool, and I think it covers your situation, but I have no experience with it.
1
How an answer that basically sayspvadd, pvmove, pvremove
gets accepted over THIS is beyond me...
– ish
Jul 8 '12 at 21:01
Much too complicated and not what he needs
– Floyd
Jul 9 '12 at 5:19
add a comment |
First, if you used the whole 250GB disk for your current installation, you'll need to shrink it to fit the 120GB disk. You can only shrink an ext4 filesystem while it's unmounted, so you'll need to boot off an Ubuntu live system (CD or USB), or a specialized maintenance live system such as GParted live. You can use resize2fs
or GParted to resize the existing filesystem.
Once you've shrunk the filesystem(s) of your existing installation to fit on the new disk, you can do the rest of the move with the filesystem mounted if you like. If the existing filesystem fits on the new disk, you can do the transfer without unmounting anything or rebooting.
In the following description, I'll show how to move from the physical volume /dev/sdb1
to the physical volume /dev/sda1
, with an existing volume group called oldvg
. Be sure to adjust the disk letters and partition numbers to match your system.
To do a live transfer:
- Partition the new disk, using the partitioning tool of your choice (
cfdisk
,fdisk
,parted
, …). See e.g. How do I add an additional hard drive?
- Create a physical volume on the new disk:
pvcreate /dev/sda1
- Add this physical volume to the existing volume group containing the logical volume(s) you want to move:
vgextend oldvg /dev/sda1
- Move the logical volumes from one physical volume to another:
pvmove /dev/sdb1 /dev/sda1
- Split the existing volume group in two:
vgsplit oldvg newvg /dev/sda1
Another method is to make the existing logical volume(s) a mirror volume with lvconvert --mirror
, set up a mirror on the new disk, then split the mirrors with lvconvert --splitmirrors
. This way, you end up with two copies of your data, and after the split each copy leads its own life.
After you've done the copy, you'll need to make the new disk bootable. Mount the filesystem for this. Assuming it's mounted on /mnt
, run these commands as root:
chroot /mnt
# if the name of the volume group has changed, edit /etc/fstab
update-grub
grub-install /dev/sda
Alternatively, you might be able to use Clonezilla. This is a powerful disk manipulation and cloning tool, and I think it covers your situation, but I have no experience with it.
1
How an answer that basically sayspvadd, pvmove, pvremove
gets accepted over THIS is beyond me...
– ish
Jul 8 '12 at 21:01
Much too complicated and not what he needs
– Floyd
Jul 9 '12 at 5:19
add a comment |
First, if you used the whole 250GB disk for your current installation, you'll need to shrink it to fit the 120GB disk. You can only shrink an ext4 filesystem while it's unmounted, so you'll need to boot off an Ubuntu live system (CD or USB), or a specialized maintenance live system such as GParted live. You can use resize2fs
or GParted to resize the existing filesystem.
Once you've shrunk the filesystem(s) of your existing installation to fit on the new disk, you can do the rest of the move with the filesystem mounted if you like. If the existing filesystem fits on the new disk, you can do the transfer without unmounting anything or rebooting.
In the following description, I'll show how to move from the physical volume /dev/sdb1
to the physical volume /dev/sda1
, with an existing volume group called oldvg
. Be sure to adjust the disk letters and partition numbers to match your system.
To do a live transfer:
- Partition the new disk, using the partitioning tool of your choice (
cfdisk
,fdisk
,parted
, …). See e.g. How do I add an additional hard drive?
- Create a physical volume on the new disk:
pvcreate /dev/sda1
- Add this physical volume to the existing volume group containing the logical volume(s) you want to move:
vgextend oldvg /dev/sda1
- Move the logical volumes from one physical volume to another:
pvmove /dev/sdb1 /dev/sda1
- Split the existing volume group in two:
vgsplit oldvg newvg /dev/sda1
Another method is to make the existing logical volume(s) a mirror volume with lvconvert --mirror
, set up a mirror on the new disk, then split the mirrors with lvconvert --splitmirrors
. This way, you end up with two copies of your data, and after the split each copy leads its own life.
After you've done the copy, you'll need to make the new disk bootable. Mount the filesystem for this. Assuming it's mounted on /mnt
, run these commands as root:
chroot /mnt
# if the name of the volume group has changed, edit /etc/fstab
update-grub
grub-install /dev/sda
Alternatively, you might be able to use Clonezilla. This is a powerful disk manipulation and cloning tool, and I think it covers your situation, but I have no experience with it.
First, if you used the whole 250GB disk for your current installation, you'll need to shrink it to fit the 120GB disk. You can only shrink an ext4 filesystem while it's unmounted, so you'll need to boot off an Ubuntu live system (CD or USB), or a specialized maintenance live system such as GParted live. You can use resize2fs
or GParted to resize the existing filesystem.
Once you've shrunk the filesystem(s) of your existing installation to fit on the new disk, you can do the rest of the move with the filesystem mounted if you like. If the existing filesystem fits on the new disk, you can do the transfer without unmounting anything or rebooting.
In the following description, I'll show how to move from the physical volume /dev/sdb1
to the physical volume /dev/sda1
, with an existing volume group called oldvg
. Be sure to adjust the disk letters and partition numbers to match your system.
To do a live transfer:
- Partition the new disk, using the partitioning tool of your choice (
cfdisk
,fdisk
,parted
, …). See e.g. How do I add an additional hard drive?
- Create a physical volume on the new disk:
pvcreate /dev/sda1
- Add this physical volume to the existing volume group containing the logical volume(s) you want to move:
vgextend oldvg /dev/sda1
- Move the logical volumes from one physical volume to another:
pvmove /dev/sdb1 /dev/sda1
- Split the existing volume group in two:
vgsplit oldvg newvg /dev/sda1
Another method is to make the existing logical volume(s) a mirror volume with lvconvert --mirror
, set up a mirror on the new disk, then split the mirrors with lvconvert --splitmirrors
. This way, you end up with two copies of your data, and after the split each copy leads its own life.
After you've done the copy, you'll need to make the new disk bootable. Mount the filesystem for this. Assuming it's mounted on /mnt
, run these commands as root:
chroot /mnt
# if the name of the volume group has changed, edit /etc/fstab
update-grub
grub-install /dev/sda
Alternatively, you might be able to use Clonezilla. This is a powerful disk manipulation and cloning tool, and I think it covers your situation, but I have no experience with it.
edited Apr 13 '17 at 12:25
Community♦
1
1
answered Jul 8 '12 at 20:45
GillesGilles
44.9k13102141
44.9k13102141
1
How an answer that basically sayspvadd, pvmove, pvremove
gets accepted over THIS is beyond me...
– ish
Jul 8 '12 at 21:01
Much too complicated and not what he needs
– Floyd
Jul 9 '12 at 5:19
add a comment |
1
How an answer that basically sayspvadd, pvmove, pvremove
gets accepted over THIS is beyond me...
– ish
Jul 8 '12 at 21:01
Much too complicated and not what he needs
– Floyd
Jul 9 '12 at 5:19
1
1
How an answer that basically says
pvadd, pvmove, pvremove
gets accepted over THIS is beyond me...– ish
Jul 8 '12 at 21:01
How an answer that basically says
pvadd, pvmove, pvremove
gets accepted over THIS is beyond me...– ish
Jul 8 '12 at 21:01
Much too complicated and not what he needs
– Floyd
Jul 9 '12 at 5:19
Much too complicated and not what he needs
– Floyd
Jul 9 '12 at 5:19
add a comment |
protected by Community♦ Jan 21 at 9:25
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
related question -- the above answers are not clear enough...
– MeSo2
Feb 16 '18 at 20:06
the above two answers are not clear enough to me. So a started a new post.
– MeSo2
Feb 16 '18 at 20:10