running out of disk space on root partition? here's how...

User avatar
lou1z
Posts: 206
Joined: Fri Jul 17, 2009 1:58 am

running out of disk space on root partition? here's how...

Postby lou1z » Mon Mar 14, 2011 1:07 pm

running out of space on your root partition? ruby not starting etc? a quick df -h shows 100% use on /?

simply add a new physical hard drive or extend your virtual drive and:

1. let's call the new drive /dev/sdc or if virtually extending your drive sdc1 (as i did)
2. fdisk /dev/sdc
3. n for new partition and go through all the defaults to use all the new space
4. w for write the partition table and reboot
5. fdisk -l to show your new partition (hopefully it's there!)
6. mkfs.ext3 /dev/sdc1 to make a ext3 file system on the new partition
7. pvcreate /dev/sdc1 to get the partition initialised
8. vgextend vg_hda /dev/sdc1 to add it to vg_hda (amahi's default lvm group)
9. lvextend -L +20G /dev/mapper/vg_hda-lv_root to add a 20gig disk. If you get errors here about not enough extents etc, just reduce the size gradually eg 18G until it fits.
10. resize2fs /dev/mapper/vg_hda-lv_root to resize the file system
11. do a reboot
12. do a df -h to see the new size on /

the above will work on a new disk or if you have any free space on another partition. simples!!

User avatar
moredruid
Expert
Posts: 791
Joined: Tue Jan 20, 2009 1:33 am
Location: Netherlands
Contact:

Re: running out of disk space on root partition? here's how.

Postby moredruid » Tue Mar 15, 2011 1:41 am

1. let's call the new drive /dev/sdc or if virtually extending your drive sdc1 (as i did)
2. fdisk /dev/sdc
3. n for new partition and go through all the defaults to use all the new space
4. w for write the partition table and reboot
5. fdisk -l to show your new partition (hopefully it's there!)
6. mkfs.ext3 /dev/sdc1 to make a ext3 file system on the new partition
7. pvcreate /dev/sdc1 to get the partition initialised
8. vgextend vg_hda /dev/sdc1 to add it to vg_hda (amahi's default lvm group)
9. lvextend -L +20G /dev/mapper/vg_hda-lv_root to add a 20gig disk. If you get errors here about not enough extents etc, just reduce the size gradually eg 18G until it fits.
10. resize2fs /dev/mapper/vg_hda-lv_root to resize the file system
11. do a reboot
12. do a df -h to see the new size on /
a bit of critique:
step 4 - you forget to set the partition type in fdisk: t for type, 8e for Linux LVM; then w to write the config
step 4 - reboot is not necessary; just run "partprobe /dev/sdc" (or the name of the drive you added).
step 6 - is unnecessary (pointless even, because you will redo the mkfs.ext3 action with the resize2fs action)
step 8 - you assume that vg_hda exists as a volume group. This may or may not be true depending on setup/installation method.
step 9 - run "vgdisplay vg_hda" (or the name of your own volume group) to see the number of free extents/space (in the line with free PE in the summary it displays) to see the maximum additional space you can assign to a logical volume.
step 11 - not necessary

extending a filesystem shouldn't give you downtime other than adding a physical disk. :geek:

I wouldn't be able to help my customers without all the online features, imagine them needing to stop all applications with each filesystem extension :o
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D2173656C7572206968616D41snlbxq' | dc
Galileo - HP Proliant ML110 G6 quad core Xeon 2.4GHz, 4GB RAM, 2x750GB RAID1 + 2x1TB RAID1 HDD

User avatar
lou1z
Posts: 206
Joined: Fri Jul 17, 2009 1:58 am

Re: running out of disk space on root partition? here's how.

Postby lou1z » Tue Mar 15, 2011 12:48 pm

point taken. it was the first time i'd extended / so i was being a little cautious in making sure everything was in place.
painless and went well so next time i'll try it without the reboots or formats.

Who is online

Users browsing this forum: No registered users and 12 guests