Resizing a logical volume

I backup my photos from an iMac to a Ubuntu linux box with a simple rsync command.

rsync --exclude=".*" -ave ssh /my/masters userId@x.x.x.y:/media/pictures

This will copy everything new from /my/masters to the backup machine at /media/pictures without copying any “dot” files. This also does not delete anything from the new machine.

Anyway, I was doing the rsync, but ran out of space on the backup box. A ctrl-z, and now I need to make more space. I am running ext3, so it should be just a few commands. First I unmounted (umount) the filesystems just to be sure. Then :

lvextend -L +40G /dev/vg/pictures

This will grow the logical volume by 40 gig. Next we need to resize the filesystem to fill up the space.

resize2fs /dev/vg/pictures

I have done this before, but this time I got a message to run e2fsck first.

e2fsck -f /dev/vg/pictures

This finished without issue, and I then ran the resize2fs command and it finished after a couple of minutes. Remount the filesystem, a “df” and it confirms that there is more space available.

I removed the last file copied to make sure it wasn’t wrecked somehow, and then kicked off the rsync again. It just picked up where it left off.

I need more space.

So after I talked about my backup strategy, I went and started my command to sync my pictures. I went to checkup on it, and it was stuck. I checked, and I was out of space. Oh oh. I stopped the sync. Now what? Well, the drives are sporting LVM2, and I had extra space available, so I just added some.

First add some more space to the volume:
# lvextend -L +1G /dev/vgnas/pictures

Then tell ext3 about the extra space.
# resize2fs /dev/vgnas/pictures

Thats it. I did it live, without unmounting. I then went back to my rsync command, and it continued right where it left off. Sometimes I really like linux.