During my internet searches I came across this great article, A Beginners Guide to LVM. Read this all the way through and you should get a good grasp of the main commands of LVM. Since that article did not really explain how to what I wanted I had to adapt it to my needs. Here are the steps I used to get my 80GB Maxtor(sda) and 60GB Western Digital(sdb) to work together as one logical unit. I am also using ext3 as my filesystem because it supports on-line resizing.
- Fresh install of Ubuntu Server 8.10
- Run updates:
sudo aptitude update && sudo aptitude safe-upgrade
- Reboot because of kernel upgrade
- Figure out what the extra hard drive is (mine is sdb):
sudo fdisk -l
- Partition the hard drive as Linux LVM:
sudo fdisk /dev/sdb
- Initialize partition for use by LVM (on my system sdb1 is swap):
sudo pvcreate /dev/sdb2
- Display attributes of volume groups to find your group name (mine is ubuntu-server):
sudo vgdisplay
- Add my physical volume to my volume group:
sudo vgextend ubuntu-server /dev/sdb2
- Now extend the logical volume root to include the new physical volume:
sudo lvextend -L128G /dev/ubuntu-server/root
- Lastly, resize the filesystem to include the new free space:
sudo resize2fs /dev/ubuntu-server/root
3 comments:
Thanks a lot - I figured out up to step 10. But nowhere were there concise instructions all in one place like this. I actually got started correctly, but winding it up was not at all clear. There's an "fsadm" bug which, for the life of me, seems to have been here for years, but hasn't been corrected. Who knew you could just run resize2fs w/o parameters other than the device? (!)
Very concise and easy to follow. Thank you.
The only problem I had was with `sudo lvextend -L128G /dev/ubuntu-server/root`. I had trouble getting the size exactly right (not sure why). Looking at the lvextend manpage, I found that `sudo lvextend /dev/ubuntu-server/root /dev/sdb2` will simply add the size of the new disk to the existing volume, without any need to specify the exact size.
After 2.5 years, this is still relevant and works!
Post a Comment