LVM: Difference between revisions
Brian Wilson (talk | contribs) mNo edit summary |
Brian Wilson (talk | contribs) |
||
Line 15: | Line 15: | ||
Remove journal, turning the filesystem from ext3 to ext2 | Remove journal, turning the filesystem from ext3 to ext2 | ||
tune2fs -O ^has_journal /dev/magniatmp/root | tune2fs -O ^has_journal /dev/magniatmp/root | ||
Preen again: | Preen again: | ||
e2fsck -f /dev/magniatmp/root | e2fsck -f /dev/magniatmp/root | ||
Resize the filesystem: | Resize the filesystem: | ||
resize2fs /dev/magniatmp/root 10000M | resize2fs /dev/magniatmp/root 10000M | ||
Note the block count and size returned by resize command: 2560000 and 4k | Note the block count and size returned by resize command: 2560000 and 4k | ||
There is also a swap space on this volume group, I can remove it for now and recreate it later. lvremove /dev/magniatmp/swap_1 | There is also a swap space on this volume group, I can remove it for now and recreate it later. | ||
lvremove /dev/magniatmp/swap_1 | |||
Figure out the new size | |||
bc 2560000*4 | bc 2560000*4 | ||
10240000 | 10240000 | ||
Resize the logical volume | |||
lvresize -L 10240000 /dev/magniatmp/root | lvresize -L 10240000 /dev/magniatmp/root | ||
Create new journal to convert back to ext3: | Create new journal to convert back to ext3: | ||
tune2fs -j /dev/magniatmp/root | tune2fs -j /dev/magniatmp/root | ||
Shrink the physical volume | |||
pvresize --setphysicalvolumesize 19G /dev/sdb5 | |||
Delete the partitions and re-create them smaller. | |||
fdisk /dev/sdb | |||
Put the swap partition | Put the swap partition |
Revision as of 06:43, 20 August 2010
Rename a volume group
I have two disks (one is a 'dd' copy of the other) and so they have identical volume names '/dev/magnia'. How do I change one?
Short answer: It is impossible. Using the UUID does not work!
Long answer: you have to have only one drive hooked up, boot from a rescue disk, and do it there. This sucks.
How do I shrink everything to fit on a smaller hard drive?
Figure out what space you want to make the partition before you start.
Preen: fsck /dev/magniatmp/root
Remove journal, turning the filesystem from ext3 to ext2
tune2fs -O ^has_journal /dev/magniatmp/root
Preen again:
e2fsck -f /dev/magniatmp/root
Resize the filesystem:
resize2fs /dev/magniatmp/root 10000M
Note the block count and size returned by resize command: 2560000 and 4k
There is also a swap space on this volume group, I can remove it for now and recreate it later.
lvremove /dev/magniatmp/swap_1
Figure out the new size
bc 2560000*4 10240000
Resize the logical volume
lvresize -L 10240000 /dev/magniatmp/root
Create new journal to convert back to ext3:
tune2fs -j /dev/magniatmp/root
Shrink the physical volume
pvresize --setphysicalvolumesize 19G /dev/sdb5
Delete the partitions and re-create them smaller.
fdisk /dev/sdb
Put the swap partition