Moving /usr to its own filesystem/logical volume
Solution 1
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.
Solution 2
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.
Related videos on Youtube
user134706
###Actively looking for freelance work ###About Me: I'm a professional software developer and have spent my time building provisioning and web based self-service systems for IIS, Apache and Citrix XenServer, amongst other things. My Curriculum Vitae can be viewed on Stack Overflow Careers (might be a bit out of date). Stuff I like to listen to at last.fm You can get in touch here: kevin.e.kenny #@# gmail.com (you know what to do with the # and spaces). No Survey Emails Please. Also not ashamed to admit I like trains, mostly diesels, late Era 8 (BR Sectorisation) and Era 9 onwards :) I'm also interested in signalling if anyone from Network Rail is looking this far down ;)
Updated on September 18, 2022Comments
-
user134706 over 1 year
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?
-
Keith over 11 yearsJust 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.
-
user134706 over 11 years@Keith - I think I'm ok. I backed up the VM and tried this and fingers crossed it all looks ok.
-
sunnysideup over 11 years@Kev why don't you just resize
/
? -
user134706 over 11 years@UlrichDangel - mostly due to fear :). I did think about resizing
/
but moving/usr
to it's own LV seemed like the safest bet. -
sunnysideup over 11 years@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.
-
-
user134706 over 11 yearsAh, ok. Will revisit this, I guess that's the same problem mentioned in Keith's comment/link about Gentoo under my question?
-
Amitav Pajni over 11 yearsThis 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.
-
Nils over 11 years@MichaelHampton our problem was not with the OS, but with the system-software for the hardware (namely OMSA from Dell).