Creating LVM Virtual Drives

driveicons

Now that we have a raid array created, we are going to create some virtual drives. Why virtual drives? Well, we have one large terabyte drive right now, and if we just put folders in there, it can quickly get cumbersome. You have no control on size of those folders, and permissions can be more difficult. And if you try to share this drive, you can’t assign different drive letters in windows to different folders, just one to the drive. One other issue is file system. I am going to use just a basic file system here, but in the past I have created different file systems based on the type of use ie. large video files, small text files, etc. Making those decisions is beyond the scope of this tutorial, and I have decided that for my purposes now, it doesn’t matter that much. You can decided differently.

What we will discuss is using LVM. This enables you to set up virtual drives that can contain different file systems, and that can be grown and shrunk (usually) to fit the space needs of the system. We will look at maintenance of these file systems at a later tutorial. Here we will create a backup, and a pictures virtual drive. We will not use the full terabyte of space, so that we can grow these as needed, or add another for say music at another time.

I will once again be doing this on an ubuntu system, but the use of these tools is fairly standard across linux distributions.
Continue reading

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.