3

I'm trying to resize my home partition, but I can't figure out how to do so. Move/Resize doesn't let me move the bar, and there's no space to extend it to. I can't unmount it because it says it's busy.

I saw talk of moving partitions around to be adjacent to extend into the free space, but how would that work? I can't move the unallocated space, and wouldn't moving my home partition before the unallocated space screw stuff up?

enter image description here

  • 2
    You cannot have a partition in two places on a disk. Well you actually can if you use LVM instead of plain partitioning, but nevertheless you will need to boot from something that is not using the partitions (e.g. a live system) before making any changes. – grochmal Jul 30 '16 at 23:42
  • but a live system of arch can't use gparted, can it? can my windows partition do the copying necessary? – sixth Jul 30 '16 at 23:55
  • Welcome to Stack Exchange.  It would appear that you have accidentally created two accounts.  You should use the contact form and select “I need to merge user profiles” to have your accounts merged.  In order to merge them, you will need to provide links to the two accounts.  For your information, they are unix.stackexchange.com/users/182319/sixth and unix.stackexchange.com/users/182327/sixth.  You’ll then be able to comment on answers to this question. – G-Man Jul 31 '16 at 9:13
1

Looking at the figure, you can't move the last three partitions. But you could create a new partition in the unallocated space, and copy your existing /home there, e.g., using rsync.

Once you've done that, you can free up the 23Gb on the end of the drive, making it (more) useful to extend your system disk.

Breaking it down a little:

  • create a new ext4 partition in the unallocated space (actually gparted makes a partition, you'll probably have to do a mkfs.ext4 or something like that to make the filesystem).
  • mount that temporarily (not as /home, but for example as /mnt)
  • use rsync (as root) to copy the whole /home tree, e.g.,

    rsync -va /home/ /mnt

  • modify your /etc/fstab to mount the new partition on /home (and a good idea to keep the old /home on a different path)

  • reboot
  • decommission the old partition after you're done verifying things, by unmounting it, removing the line from /etc/fstab and then deleting the partition with gparted.
  • Do I need to do any linking or mounting to make that work once I'd have copied over the files? and then are you recommending I just add the 23 gb to the root partition? because, from what I've read, that seems a bit much. – sixth Jul 31 '16 at 0:05
  • I don't recommend copying files from a running system. If some files are modified during the copy, you could end up with an inconsistent state. – Gilles Jul 31 '16 at 0:36
  • So then, in my fstab, I comment out the /home line, and duplicate it with the only change being the new UUID? so my new line looks like UUID=288ff8b3-f800-41bd-badd-68a928ff515c /home ext4 rw,relatime,data=ordered 0 2 – sixth Jul 31 '16 at 0:36
  • It's /home (if you prefer running system applications from /home, that's your problem). – Thomas Dickey Jul 31 '16 at 0:37
  • So what can I put for my new location on the old partition? i.e. what do I replace the old '/home' with? can it be anything? – sixth Jul 31 '16 at 0:42
1

A partition is a segment of the disk, not a combination of segments. Since the home partition is at the end of the disk, and the root partition is immediately before it, there's no room to extend the home partition.

You can extend mounted partitions, but not move mounted partitions around. So you should work from a live system.

You can move the home partition into the free space; then you'll be able to enlarge it to ~44GB. But rather than just move the partition, I recommend that you switch your Linux partitions to LVM (see also the Archi wiki). LVM is a partition system that's a lot more flexible than the basic MBR/UEFI system; its only downside is that it's specific to Linux, so it normally lives inside an MBR/UEFI partition. If you'd used LVM, you could have enlarged that home partition very easily.

From a live system:

  1. Run fdisk to:

    1. Remove the swap partition. We'll re-create it afterwards.
    2. Create a partition of type “Linux LVM” in the free space. Give it the number 5.
  2. Create an LVM physical volume on the new partition. An LVM physical volume is space on a disk for LVM partitions.

    pvcreate /dev/sda5
    
  3. Create an LVM volume group. A volume group relates physical volumes (disk segments) to logical volumes (containers for a filesystem or swap space). Here arch is the name of the group, feel free to pick a different name.

    vgcreate arch /dev/sda5
    
  4. Create logical volumes to move your root and home filesystems into LVM, and for the swap space. Make sure that the root and home volumes are at least as large as the existing filesystems. Beware that GParted is evil: it rounds filesystem sizes, so if you use what it displays, you risk losing a bit of data at the end, which could make the filesystem unrecoverable. Use the real size information.

    grep sda[67] /proc/partitions    # shows partition sizes in kB
    lvcreate -L "$(awk '$4=="sda6" {print $3}' /proc/partitions)k" -n root arch
    cat /dev/sda6 >/dev/arch/root
    lvcreate -L "$(awk '$4=="sda7" {print $3}' /proc/partitions)k" -n home arch
    cat /dev/sda7 >/dev/arch/home
    lvcreate -L 24g -n swap arch
    
  5. Mount the new location of the home and root partitions, to make sure that the copy is fine.

    mkdir /media/root /media/home
    mount /dev/arch/root /media/root
    mount /dev/arch/home /media/home
    # Check that both filesystems look fine
    
  6. Edit /etc/fstab and make sure that it's using valid references to your partitions. If you're using UUIDs or labels, you can keep using that. If you were using partition numbers, you must change that. You can use the LVM device locations, they're stable: /dev/arch/root and /dev/arch/home.

  7. I don't know how Arch Linux sets up its booting system. On some distributions, you need to regenerate the second-stage bootloader and the initramfs to include LVM support. On Arch, it seems that you need to add lvm2 to /etc/mkinitcpio.conf and regenerate the initramfs.

  8. You don't need the old space with the home and root partitions anymore. You can reuse them for LVM by creating an LVM physical volume in them (pvcreate /dev/sda6 /dev/sda7) and adding those physical volumes to the existing volume group (vgextend arch /dev/sda6 /dev/sda7). After that, if you ever want to extend your filesystems, you can call lvextend without worrying about location: it'll use free space anywhere in the volume group to extend the logical volume, then call resize2fs to enlarge the filesystem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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