* [LINUX-LVM] shrinking a volume inside an LVM [not found] <F61B3F3722111146AF452DF29FDCCF5F038D1BD3@xchg03.bolivar.k12.mo.us> @ 2008-01-04 19:07 ` Kemp, Levi 2008-01-04 19:38 ` Brian McCullough 0 siblings, 1 reply; 7+ messages in thread From: Kemp, Levi @ 2008-01-04 19:07 UTC (permalink / raw) To: linux-lvm [-- Attachment #1: Type: text/plain, Size: 515 bytes --] I'm sure it's been asked before, but I must be terrible at searching because I cannot find the answer. I have, like many, followed defaults and ended up wiht a boot partion and a lvm. Inside the lvm is a / and a swap. I'd like to shrink the / so that I can do another install of a different distro without upsetting my current one. I don't have another computer, or equal setup to run my test on and cannot take this one down yet either. If it's impossible let me know, but either way thanks for the help. Levi [-- Attachment #2: Type: text/html, Size: 914 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LINUX-LVM] shrinking a volume inside an LVM 2008-01-04 19:07 ` [LINUX-LVM] shrinking a volume inside an LVM Kemp, Levi @ 2008-01-04 19:38 ` Brian McCullough 2008-01-04 20:50 ` Kemp, Levi 0 siblings, 1 reply; 7+ messages in thread From: Brian McCullough @ 2008-01-04 19:38 UTC (permalink / raw) To: LVM general discussion and development On Fri, Jan 04, 2008 at 01:07:42PM -0600, Kemp, Levi wrote: > I'm sure it's been asked before, but I must be terrible at searching because I cannot find the answer. I have, like many, followed defaults and ended up wiht a boot partion and a lvm. Inside the lvm is a / and a swap. I'd like to shrink the / so that I can do another install of a different distro without upsetting my current one. I don't have another computer, or equal setup to run my test on and cannot take this one down yet either. If it's impossible let me know, but either way thanks for the help. This is relatively easy, as long as you are careful. First, which filesystem format are you using? I will base my answer on ext2/ext3, because that's what I am most familiar with, others can answer better if you have something else. Second, I presume from your question that / is not full. 1. Boot with a Rescue Disk or Live CD ( you need to make sure that your LVM is not Live and being used. ) 2. Start a terminal window and run: 3. vgchange -a y 4. e2fsck -f /dev/"volgroupname"/"volname of '/'" ( you can fill in the blanks ) 5. mkdir /mnt1 6. mount /dev/"volgroupname"/"volname of '/'" /mnt1 7. df ( check the amount of space occupied in / ) 8. umount /mnt1 9. resize2fs /dev/"volgroupname"/"volname of '/'" "amount occupied + some" 10. lvreduce -L "size from 9" /dev/"volgroupname"/"volname of '/'" ( If you want to be extra paranoid, you can add a "-t" parameter once, and then run it without. ) 11. resize2fs /dev/"volgroupname"/"volname of '/'" ( This will adjust the filesystem to fit the Logical Volume. ) At this point, you should have a smaller / volume and some free space. Note that resize2fs will insist on the e2fsck, and may require it more often than I have shown. I have put in a couple of paranoia steps, such as 6-8, to make sure that you are using the correct sizes in the next couple of steps. Have fun! Brian ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [LINUX-LVM] shrinking a volume inside an LVM 2008-01-04 19:38 ` Brian McCullough @ 2008-01-04 20:50 ` Kemp, Levi 2008-01-04 20:59 ` Stuart D. Gathman 2008-01-05 6:35 ` Brian McCullough 0 siblings, 2 replies; 7+ messages in thread From: Kemp, Levi @ 2008-01-04 20:50 UTC (permalink / raw) To: LVM general discussion and development [-- Attachment #1: Type: text/plain, Size: 3159 bytes --] Most of this makes sense. Especially the part about using a live CD. But if you don't mind I'm gonna pick your brain on the other parts because I like to understand a command before I use it, so I can blame myself when I mess up ;-) Actually the only part I'm unsure about is 9-11. resize2fs will resize my ext2/3 file system which will clear up more room in my lvm to create another lv correct? Or do you have to shrink the file system then the lv to have the space back? I'm going to back up anything that I need to be safe, but I'd like to avoid a total reinstall right now(that's for May). Thanks again. I think you've got me on track. One more quick one, on 9 you said "amount occupied + some" wouldn't it be minus some? Levi -----Original Message----- From: linux-lvm-bounces@redhat.com on behalf of Brian McCullough Sent: Fri 1/4/2008 1:38 PM To: LVM general discussion and development Subject: Re: [LINUX-LVM] shrinking a volume inside an LVM On Fri, Jan 04, 2008 at 01:07:42PM -0600, Kemp, Levi wrote: > I'm sure it's been asked before, but I must be terrible at searching because I cannot find the answer. I have, like many, followed defaults and ended up wiht a boot partion and a lvm. Inside the lvm is a / and a swap. I'd like to shrink the / so that I can do another install of a different distro without upsetting my current one. I don't have another computer, or equal setup to run my test on and cannot take this one down yet either. If it's impossible let me know, but either way thanks for the help. This is relatively easy, as long as you are careful. First, which filesystem format are you using? I will base my answer on ext2/ext3, because that's what I am most familiar with, others can answer better if you have something else. Second, I presume from your question that / is not full. 1. Boot with a Rescue Disk or Live CD ( you need to make sure that your LVM is not Live and being used. ) 2. Start a terminal window and run: 3. vgchange -a y 4. e2fsck -f /dev/"volgroupname"/"volname of '/'" ( you can fill in the blanks ) 5. mkdir /mnt1 6. mount /dev/"volgroupname"/"volname of '/'" /mnt1 7. df ( check the amount of space occupied in / ) 8. umount /mnt1 9. resize2fs /dev/"volgroupname"/"volname of '/'" "amount occupied + some" 10. lvreduce -L "size from 9" /dev/"volgroupname"/"volname of '/'" ( If you want to be extra paranoid, you can add a "-t" parameter once, and then run it without. ) 11. resize2fs /dev/"volgroupname"/"volname of '/'" ( This will adjust the filesystem to fit the Logical Volume. ) At this point, you should have a smaller / volume and some free space. Note that resize2fs will insist on the e2fsck, and may require it more often than I have shown. I have put in a couple of paranoia steps, such as 6-8, to make sure that you are using the correct sizes in the next couple of steps. Have fun! Brian _______________________________________________ linux-lvm mailing list linux-lvm@redhat.com https://www.redhat.com/mailman/listinfo/linux-lvm read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/ [-- Attachment #2: winmail.dat --] [-- Type: application/ms-tnef, Size: 4505 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [LINUX-LVM] shrinking a volume inside an LVM 2008-01-04 20:50 ` Kemp, Levi @ 2008-01-04 20:59 ` Stuart D. Gathman 2008-01-04 21:58 ` Kemp, Levi 2008-01-05 6:35 ` Brian McCullough 1 sibling, 1 reply; 7+ messages in thread From: Stuart D. Gathman @ 2008-01-04 20:59 UTC (permalink / raw) To: LVM general discussion and development On Fri, 4 Jan 2008, Kemp, Levi wrote: > Most of this makes sense. Especially the part about using a live CD. But if > you don't mind I'm gonna pick your brain on the other parts because I like to > understand a command before I use it, so I can blame myself when I mess up > ;-) Actually the only part I'm unsure about is 9-11. resize2fs will resize my > ext2/3 file system which will clear up more room in my lvm to create another > lv correct? Or do you have to shrink the file system then the lv to have the > space back? I'm going to back up anything that I need to be safe, but I'd > like to avoid a total reinstall right now(that's for May). Thanks again. I > think you've got me on track. One more quick one, on 9 you said "amount > occupied + some" wouldn't it be minus some? The plan given was to shrink the fs first, then reduce the LV to something *bigger* than the shrunk filesystem. I would add a little to the size on lvreduce just to be sure. The second resize is then to grow the fs into the exact size of the LV (which it can do automatically and safely). Shrinking is more dangerous than growing with current tools because the lvreduce isn't smart enough to know exactly how big the filesystem inside is, and you had better have shrunk the fs sufficiently first. resize2fs, on the other hand, *does* know exactly how big the underlying LV or other device is when expanding. -- Stuart D. Gathman <stuart@bmsi.com> Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flammis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [LINUX-LVM] shrinking a volume inside an LVM 2008-01-04 20:59 ` Stuart D. Gathman @ 2008-01-04 21:58 ` Kemp, Levi 2008-01-05 6:37 ` Brian McCullough 0 siblings, 1 reply; 7+ messages in thread From: Kemp, Levi @ 2008-01-04 21:58 UTC (permalink / raw) To: LVM general discussion and development [-- Attachment #1: Type: text/plain, Size: 2601 bytes --] Ok I understand. Is there anything I need to do to the volume to prep it first, as in defragment it or something similar? I'm unsure as to how the ext2/3 file systems work with data, so I didn't know if it needed to be moved before shrinking the file system, then shrinking the LV, then exanding the file system to fill the LV, leaving room in the LVM to create another LV with whatever file system I want correct? Doesn't sound as complicated now. Thanks. Levi -----Original Message----- From: linux-lvm-bounces@redhat.com on behalf of Stuart D. Gathman Sent: Fri 1/4/2008 2:59 PM To: LVM general discussion and development Subject: RE: [LINUX-LVM] shrinking a volume inside an LVM On Fri, 4 Jan 2008, Kemp, Levi wrote: > Most of this makes sense. Especially the part about using a live CD. But if > you don't mind I'm gonna pick your brain on the other parts because I like to > understand a command before I use it, so I can blame myself when I mess up > ;-) Actually the only part I'm unsure about is 9-11. resize2fs will resize my > ext2/3 file system which will clear up more room in my lvm to create another > lv correct? Or do you have to shrink the file system then the lv to have the > space back? I'm going to back up anything that I need to be safe, but I'd > like to avoid a total reinstall right now(that's for May). Thanks again. I > think you've got me on track. One more quick one, on 9 you said "amount > occupied + some" wouldn't it be minus some? The plan given was to shrink the fs first, then reduce the LV to something *bigger* than the shrunk filesystem. I would add a little to the size on lvreduce just to be sure. The second resize is then to grow the fs into the exact size of the LV (which it can do automatically and safely). Shrinking is more dangerous than growing with current tools because the lvreduce isn't smart enough to know exactly how big the filesystem inside is, and you had better have shrunk the fs sufficiently first. resize2fs, on the other hand, *does* know exactly how big the underlying LV or other device is when expanding. -- Stuart D. Gathman <stuart@bmsi.com> Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flammis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. _______________________________________________ linux-lvm mailing list linux-lvm@redhat.com https://www.redhat.com/mailman/listinfo/linux-lvm read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/ [-- Attachment #2: winmail.dat --] [-- Type: application/ms-tnef, Size: 4065 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LINUX-LVM] shrinking a volume inside an LVM 2008-01-04 21:58 ` Kemp, Levi @ 2008-01-05 6:37 ` Brian McCullough 0 siblings, 0 replies; 7+ messages in thread From: Brian McCullough @ 2008-01-05 6:37 UTC (permalink / raw) To: LVM general discussion and development On Fri, Jan 04, 2008 at 03:58:43PM -0600, Kemp, Levi wrote: > Ok I understand. Is there anything I need to do to the volume to prep it first, as in defragment it or something similar? I'm unsure as to how the ext2/3 file systems work with data, so I didn't know if it needed to be moved before shrinking the file system, then shrinking the LV, then exanding the file system to fill the LV, leaving room in the LVM to create another LV with whatever file system I want correct? Doesn't sound as complicated now. Thanks. As long as the "/" volume isn't actually "Live," this can be done "in place." ( don't you love quotation marks? ) The "e2fsck" does a form of defragment as a side effect of "cleaning up" the filesystem. Brian ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LINUX-LVM] shrinking a volume inside an LVM 2008-01-04 20:50 ` Kemp, Levi 2008-01-04 20:59 ` Stuart D. Gathman @ 2008-01-05 6:35 ` Brian McCullough 1 sibling, 0 replies; 7+ messages in thread From: Brian McCullough @ 2008-01-05 6:35 UTC (permalink / raw) To: LVM general discussion and development On Fri, Jan 04, 2008 at 02:50:00PM -0600, Kemp, Levi wrote: > Most of this makes sense. Especially the part about using a live CD. But if you don't mind I'm gonna pick your brain on the other parts because I like to understand a command before I use it, so I can blame myself when I mess up ;-) > Actually the only part I'm unsure about is 9-11. resize2fs will resize my ext2/3 file system which will clear up more room in my lvm to create another lv correct? Or do you have to shrink the file system then the lv to have the space back? I'm going to back up anything that I need to be safe, but I'd like to avoid a total reinstall right now(that's for May). Thanks again. I think you've got me on track. One more quick one, on 9 you said "amount occupied + some" wouldn't it be minus some? Stuart answered at least as well as I could, but for the last, "occupied + some" is what I meant. By "occupied" I am talking about the amount of data that actually exists in your "/" volume. Then, since you need a little room to grow, add some to that value, so that you have a bit of free space in that volume. ( As well as Stuart's explanation, to leave room for errors. ) Brian ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-01-05 6:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <F61B3F3722111146AF452DF29FDCCF5F038D1BD3@xchg03.bolivar.k12.mo.us>
2008-01-04 19:07 ` [LINUX-LVM] shrinking a volume inside an LVM Kemp, Levi
2008-01-04 19:38 ` Brian McCullough
2008-01-04 20:50 ` Kemp, Levi
2008-01-04 20:59 ` Stuart D. Gathman
2008-01-04 21:58 ` Kemp, Levi
2008-01-05 6:37 ` Brian McCullough
2008-01-05 6:35 ` Brian McCullough
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.