Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My Fedora 17 (x64 - running on VMware Workstation 8) root filesystem is running out of space (this was an install using the default layout as suggested by the Fedora installer):

# df -h
Filesystem                    Size  Used Avail Use% Mounted on
rootfs                         18G   17G  937M  95% /
devtmpfs                      1.5G     0  1.5G   0% /dev
tmpfs                         1.5G  224K  1.5G   1% /dev/shm
tmpfs                         1.5G   51M  1.5G   4% /run
/dev/mapper/vg_bloss-lv_root   18G   17G  937M  95% /
tmpfs                         1.5G   51M  1.5G   4% /run
tmpfs                         1.5G     0  1.5G   0% /sys/fs/cgroup
tmpfs                         1.5G     0  1.5G   0% /media
/dev/sda2                     485M   85M  376M  19% /boot

The bulk of the space is taken up by the /usr directory. I have added a 40GB disk to the virtual machine (/dev/sdb) and wish to move /usr to its own logical volume.

LVM is a bit new to me but I think I've worked out the steps to add this disk using LVM:

fdisk /dev/sdb 
# (create a new 0x8e LVM partition type using all of the disk)

pvcreate /dev/sdb1
vgextend vg_bloss /dev/sdb1
lvcreate -l +100%FREE -n lv_usr vg_bloss /dev/sdb1
mkfs -t ext4 /dev/vg_bloss/lv_usr
# mount fs
mkdir /mnt/usr
mount -t ext4 /dev/vg_bloss/lv_usr /mnt/usr

I was then going to use the following steps to move /usr onto this new filesystem:

cp -aR /usr/* /mnt/usr
umount /mnt/usr
# add relevant mount entry in /etc/fstab:
# /dev/mapper/vg_bloss-lv_usr /usr    ext4    defaults    1 1
mv /usr /usr_old
mkdir /usr
mount -t ext4 /dev/vg_bloss/lv_usr /usr
reboot

Then when I'm happy that /usr seems intact and behaving normally I'll just delete it to free up space on /.

Does this look sane?

share|improve this question
    
Just FYI, you may have to deal with getting /usr mounted early in the boot sequence, before udev, since udev now requires /usr to be mounted before it starts. The Gentoo HOWTO has more info on this. –  Keith Sep 3 '12 at 11:41
    
@Keith - I think I'm ok. I backed up the VM and tried this and fingers crossed it all looks ok. –  Kev Sep 3 '12 at 12:09
1  
@Kev why don't you just resize /? –  Ulrich Dangel Sep 3 '12 at 12:16
    
@UlrichDangel - mostly due to fear :). I did think about resizing / but moving /usr to it's own LV seemed like the safest bet. –  Kev Sep 3 '12 at 12:30
3  
@Kev the easiest and simplest way is just to resize /, e.g. lvresize -L+40G /dev/mapper/vg_bloss-lv_root, resize2fs /dev/mapper/vg_bloss-lv_root - that's it. no reboot required - nothing. –  Ulrich Dangel Sep 3 '12 at 12:34
show 1 more comment

2 Answers 2

up vote 2 down vote accepted

Your sequence of instructions look correct, but note that I have only eyeballed them, not tested them.

As noted by others, separating /usr is not supported by all distributions, and even if it is officially supported now, the support may be dropped because there is very little demand for it any more with modern disk sizes. So I do not recommend splitting out /usr. Instead, enlarge the root filesystem.

I believe that VMware lets you enlarge an existing disk. So do that. Then create a new partition on the disk (primary or logical, as you wish); you can use fdisk or gparted or any other partitioning tool. Give the partition the type 8e (Linux LVM). Let's say that the new partition is /dev/sda9; create a physical volume on it, and add it to the existing volume group:

pvcreate /dev/sda9
vgextend vg_bloss /dev/sda9

Next, extend the logical volume, and enlarge the filesystem.

lvextend vg_bloss/lv_root /dev/sda9
resize2fs /dev/mapper/vg_bloss-lv_root

If you can't enlarge the disk, I still recommend growing the filesystem. Spreading a filesystem over multiple physical disks is often a bad idea because if either disk breaks, you lose your data; here, over virtual disks, it doesn't matter. So put the new physical volume in the existing volume group, and grow the logical volume and the filesystem as above.

share|improve this answer
add comment

Do not put /usr into an own volume or mountpoint.

We just changed our standard filesystem-layout where we previously had /usr mounted as separate LV.

The problems got bigger and bigger, since the number of init-processes that use /usr is constantly growing. There are even plans to drop /bin and /sbin in favour of /usr/bin and /usr/sbin.

So our solution was to resize / to a new size bigger than / and /usr before.

/ and /usr should be pretty static, after you installed all needed rpms.

share|improve this answer
    
Ah, ok. Will revisit this, I guess that's the same problem mentioned in Keith's comment/link about Gentoo under my question? –  Kev Sep 4 '12 at 14:41
    
This is no longer an issue with Fedora since /usr is now designed to be run from a separate mount point. Other distributions will probably follow suit in the next few years. –  Michael Hampton Feb 7 '13 at 5:51
    
@MichaelHampton our problem was not with the OS, but with the system-software for the hardware (namely OMSA from Dell). –  Nils Feb 7 '13 at 21:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.