Dual boot with Ubuntu - cannot resize partition

New to Debian (Or Linux in general)? Ask your questions here!

Dual boot with Ubuntu - cannot resize partition

Postby geobeck » 2018-10-05 01:13

I've been using Debian for a while, but I want to add Ubuntu in a dual boot configuration. However, I can't resize the space occupied by Debian because it's a logical volume. I've tried using GParted, but it can't seem to make any changes to the filesystems.

Is my best bet to blow away the entire drive, then partition after the fact? All my data is backed up, so that's an option.
geobeck
 
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

Postby p.H » 2018-10-05 07:14

geobeck wrote: I can't resize the space occupied by Debian because it's a logical volume.

Do you means an LVM logical volume ? A logical volume can be resized with the command lvresize, lvextend or lvreduce. Gparted cannot resize logical volumes. It is a PARTITION editor, nor a general volume manager. Logical volumes are not partitions.

Please post the output of "lsblk".

As usual, the filesystem inside the volume must be reduced with the proper command (resize2fs for ext4) BEFORE reducing the volume otherwise it will be unmountable and probably unfixable.
If the filesystem type is ext4, it cannot be reduced while mounted. So it must be unmounted first. If it used as the root filesystem, obviously it cannot be unmounted when the system is running so that must be done from another system (live, installer, other installed system...).
If the filesystem type is btrfs, it can be reduced while mounted with btrfs-filesystem.
If the filesystem type is xfs, it cannot be reduced at all. It must be dumped, recreated with a smaller size and restored.
p.H
 
Posts: 649
Joined: 2017-09-17 07:12

Re: Dual boot with Ubuntu - cannot resize partition

Postby geobeck » 2018-10-05 13:46

It's LVM. When I create partitions for my second distro, I'd like to share swap and home, so I guess I'll have to get rid of those logical volumes and create actual partitions.

My Ubuntu stick has the full live version, so maybe my best bet is to format the whole disk, partition it the way I want (a few GB for /swap, 50-100 GB per /, the rest /home), then install both distros from scratch. I'm also planning to create another partition for a potential third distro if I find one if I want to try.

Here's my lsblk output:

george@debian-george:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 244M 0 part /boot
└─sda3 8:3 0 930.8G 0 part
├─debian--george--vg-root 254:0 0 28G 0 lvm /
├─debian--george--vg-swap_1 254:1 0 7.9G 0 lvm [SWAP]
└─debian--george--vg-home 254:2 0 895G 0 lvm /home
sr0 11:0 1 1024M 0 rom
george@debian-george:~$
geobeck
 
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

Postby p.H » 2018-10-05 14:43

Be careful with sharing /home and swap. A shared swap prevents putting one system into hibernation and rebooting with the other. A shared home may cause trouble with user/group ID file permissions and incompatible version config files.
Also the installer may reformat the swap and change its UUID. Fortunately when swap is in a LV, the system uses the LV name instead of the UUID.

You do not need to get rid of logical volumes. You can reduce the home LV and create new LVs for the second /, swap, home...
Boot in rescue mode, unmount /home, reduce the filesystem with resize2fs, reduce the logical volume with lvreduce. Create new logical volumes as needed with lcreate.

Do not share the existing /boot partition. Debian/Ubuntu /boot is not intended to be shared. You do not need to create a /boot partition for Ubuntu.
p.H
 
Posts: 649
Joined: 2017-09-17 07:12

Re: Dual boot with Ubuntu - cannot resize partition

Postby geobeck » 2018-10-05 15:37

Thanks for the additional advice. Just to clarify: Do you mean lcreate or lvcreate? Looking through online documentation, lcreate appears to upload transcripts, whereas lvcreate is for creating logical volumes.

I also note that each volume on my drive seems to occupy its own volume group. Will I need to use vgcreate to create volume groups for my new volumes, or can they live on the existing home vg?
geobeck
 
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

Postby p.H » 2018-10-05 23:07

geobeck wrote:Do you mean lcreate or lvcreate?

lvcreate of course. It was a typo.

geobeck wrote:I also note that each volume on my drive seems to occupy its own volume group.

How do you see that ? From the output of lsblk it seems to me that all LVs belong to the same VG called "debian-george-vg". Check with lvs.

geobeck wrote:Will I need to use vgcreate to create volume groups for my new volumes

No. Besides, creating a new VG requires creating a new PV in a new partition.
p.H
 
Posts: 649
Joined: 2017-09-17 07:12

Re: Dual boot with Ubuntu - cannot resize partition

Postby geobeck » 2018-10-06 01:35

Ok, I was looking at the full name, "debian-george--vg-root" as the name of a volume group. I guess everything before --vg is the name of the volume group, and everything after is the name of the volume.

So if I resize the /home filesystem, then resize the -home volume, I'll have available space. Will that space still be within the debian-george volume group, or will it be unallocated?
geobeck
 
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

Postby p.H » 2018-10-06 08:36

geobeck wrote:Ok, I was looking at the full name, "debian-george--vg-root" as the name of a volume group. I guess everything before --vg is the name of the volume group, and everything after is the name of the volume.

Note that -vg is part of the VG name : "debian-george-vg".
LV device nodes have two names derived from the VG and LV names :
- /dev/vgname/lvname
- /dev/mapper/vgname-lvname (hyphens in vgname and lvname are doubled to distinguish them from the dash used as separator between vgname and lvname - so my advice is avoid using them, and use underscores instead)
Note that these are actually symlinks pointing to the real device nodes /dev/dm-N.

geobeck wrote:So if I resize the /home filesystem, then resize the -home volume, I'll have available space. Will that space still be within the debian-george volume group, or will it be unallocated?

You do not seem to understand the basics of LVM yet.
A VG has one or more PVs, which are usually partitions but can also be RAID arrays, encrypted devices... All the space of these PVs belong to the VG. A PV cannot be shared between VGs.
LVs created in the VG use space from PVs belonging to the VG.

If you reduce a LV, the space is returned to its VG free space pool and can be used to create or extend LVs in the same VG. This free space is unallocated from the point of view of the VG, but is allocated from the point of view of the partition table, because it belongs to the partition used as a PV. So it cannot be used to create a new partition.
p.H
 
Posts: 649
Joined: 2017-09-17 07:12

Re: Dual boot with Ubuntu - cannot resize partition

Postby geobeck » 2018-10-06 11:32

I guess I should read through the LVM documentation a few times to make sure I've got it. But the main question is that if the newly-freed space I get from resizing the home volume is still part of the same volume group, will the new distro be able to use it? Or will the new distro not see the same vg because it was created by the first distro?
geobeck
 
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

Postby p.H » 2018-10-06 11:58

It depends on the installer, even though a VG is not distribution-specific. I have been quite disappointed by the poor LVM capabilities of a recent Ubuntu live/installer (don't know which version/flavour exactly), but after creating LVs by hand with lvcreate the installer could use them.
p.H
 
Posts: 649
Joined: 2017-09-17 07:12

Re: Dual boot with Ubuntu - cannot resize partition

Postby Zjho » 2018-10-06 12:59

Might be a lot easier to reinstall without using LVM.
User avatar
Zjho
 
Posts: 36
Joined: 2016-09-15 17:46

Re: Dual boot with Ubuntu - cannot resize partition

Postby p.H » 2018-10-07 10:26

But then when you need to modify the partitions, things become much less easy...
Or are you suggesting to reinstall everything each time you want to add or remove a system ?
p.H
 
Posts: 649
Joined: 2017-09-17 07:12

Re: Dual boot with Ubuntu - cannot resize partition

Postby geobeck » 2018-10-07 12:31

That was my original plan. But if both distros can see the logical volumes as easily as they can see partitions, learning to use LVM looks like a much more sensible way to go, rather than reinstalling everything afterward (although everything is backed up, of course) and fighting with the bloody Broadcom drivers in Debian again.
geobeck
 
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

Postby GarryRicketson » 2018-10-07 12:44

There is going to be another obstacle, minor, but something to consider when setting up a multi boot system, and using LVM:
https://wiki.debian.org/LVM
/boot
Grub and ?LiLo are not compatible with LVM, so /boot should be outside the storage disk managed by LVM.


Another alternative, instead of "dual boot", or "multi boot", which is extremely inconvenient, because, you have to shutdown your Debian system, and then
boot with the other system, and after your done, when you want Debian again,
the same,...you can only run 1 OS at a time like that.
Using a virtual machine, or virtual environment you can be running Debian,
start a VM that is Ubuntu, and have both running at the same time. No need to reinstall anything, nor resize or mess with your LVM set up,... Maybe something to think about ?
https://wiki.debian.org/QEMU
====================
https://wiki.debian.org/KVM
Last edited by GarryRicketson on 2018-10-07 12:53, edited 1 time in total.
User avatar
GarryRicketson
 
Posts: 5193
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Dual boot with Ubuntu - cannot resize partition

Postby p.H » 2018-10-07 12:52

Debian wiki wrote:Grub and LiLo are not compatible with LVM

This claim is obsolete : the current GRUB version (aka GRUB 2) supports LVM. Only the deprecated version (aka GRUB 1, GRUB legacy) does not.
p.H
 
Posts: 649
Joined: 2017-09-17 07:12

Next

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable