1

I want to move an empty disc space from one partition to another. Is this possible?

In the below image, I have free space under /local (/dev/sda3). I want to allocate this space to / which is on /dev/sda2.

How can I do this?

lsblk output

1
  • 2
    Please avoid using images in questions if at all possible, as images are not search engine friendly, whereas text is. Simply copy and paste the text then mark it as code with the {} button. Commented Apr 6, 2016 at 21:05

1 Answer 1

0

Doing what you're asking is not easy, but I have two solutions that I hope might help you out.

You have two disks. The first disk has /boot and / as primary partitions, and the third primary partition sda3 takes up all the remaining space and is let over to LVM. You have a second disk that is also let over to LVM in the same VG. Your problem is that to increase the size of the primary partition sda2, you have to move the beginning of sda3. Maybe maybe something like gparted could do that, but frankly I'm not sure. (On Ubuntu the / partition is already in LVM, so one only has the problem with the /boot, which isn't a big problem.)

So, first possibility: reduce /local by at least 10G to free up space in your VG. Use pvmove to move all the extents off of sda3 on to sdb. Once sda3 is no longer used, you can use something like gparted to delete sda3 and extend sda2.

BTW I prefer the outputs of lvs vgs and pvs, the last of which will show you (with less headscratching) when sda3 is no longer used.

Second possibility: decide on a subtree of / to externalize on another LV. I would probably decide on /usr. Reduce /local by at least the size of that subtree to free up space in your VG. Create a new LV called /usr, copy the files, unmount /usr, rename /usr to /usr.bak, mkdir /usr, remount /usr from your new LV, make sure everything is working (reboot etc.), then you can delete /usr.bak and so free up your space. For this solution you'll probably have to work a lot in single mode, and working without access to the binaries in /usr is an interesting exercise :)

3
  • I'm not too familiar with LVM, but it looks to me that the 79G of /local is 7G from /dev/sda3 and 72G from /dev/sdb. Thus, at most 7G can be shifted out for use in /dev/sda2. Unless it also is muted into an LVM I suppose. Commented Apr 6, 2016 at 23:36
  • Thanks both of you. Honestly it is way over my head. I have to find someone to do this for me. Thank you for your responses. Commented Apr 7, 2016 at 1:41
  • @RalphRönnquist Exactly, I said to reduce by "at least 10G" but I was taking a margin.So, yes, with option 1 sda2 can be extended by at most 7G. @Arvind yes also, if you do not feel comfortable with this it is best to get help, and also make backups! Reducing a filesystem is a two- or even three-step process that can easily delete data if you mix up the the steps or take wrong values. While I'm at it, try du -x --max-depth=1 / to see where your data is, maybe it's all in /home, that would be an excellent candidate for my second option, with less problems than /usr.
    – Law29
    Commented Apr 7, 2016 at 5:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .