Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Dual boot with Ubuntu - cannot resize partition

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
geobeck
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Dual boot with Ubuntu - cannot resize partition

#1 Post by geobeck »

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.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Dual boot with Ubuntu - cannot resize partition

#2 Post by p.H »

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.

geobeck
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

#3 Post by geobeck »

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:~$

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Dual boot with Ubuntu - cannot resize partition

#4 Post by p.H »

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.

geobeck
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

#5 Post by geobeck »

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?

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Dual boot with Ubuntu - cannot resize partition

#6 Post by p.H »

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.

geobeck
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

#7 Post by geobeck »

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?

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Dual boot with Ubuntu - cannot resize partition

#8 Post by p.H »

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.

geobeck
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

#9 Post by geobeck »

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?

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Dual boot with Ubuntu - cannot resize partition

#10 Post by p.H »

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.

User avatar
Zjho
Posts: 48
Joined: 2016-09-15 17:46

Re: Dual boot with Ubuntu - cannot resize partition

#11 Post by Zjho »

Might be a lot easier to reinstall without using LVM.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Dual boot with Ubuntu - cannot resize partition

#12 Post by p.H »

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 ?

geobeck
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

#13 Post by geobeck »

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.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Dual boot with Ubuntu - cannot resize partition

#14 Post by GarryRicketson »

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.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Dual boot with Ubuntu - cannot resize partition

#15 Post by p.H »

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.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Dual boot with Ubuntu - cannot resize partition

#16 Post by GarryRicketson »

Ok, to be honest I don't know, I was just going by what the wiki says, sorry for being wrong again.

User avatar
Zjho
Posts: 48
Joined: 2016-09-15 17:46

Re: Dual boot with Ubuntu - cannot resize partition

#17 Post by Zjho »

p.H wrote: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 ?
Yes much less easy but Geobeck has made backups, is familiar with GParted and has a live Ubuntu stick to partition discs. No need to install everything each time. He would face usual multi-boot on one disc challenges the first time such as arranging that installing new distros doesn't move current distros boot files possibly by formatting a number of empty partitions or leaving unallocated space. To be clear i have not multi-booted Debian and Ubuntu on one disc, but should be doable without LVM, if he is restricted in space to one disc only (?). One distro per disc is safer and easier if possible. Not tried VMs as suggested by GarryRicketson though that sounds very convenient if system has sufficient resource. Multi-boot on one disc method took an elevated risk as to what happened when bootloaders got their respective updates when i last tried it years ago, seem to remember chainloaders (more complex) were suggested to keep boot orders but not tried that. LVM is intended more for servers using large arrays of discs iirc which doesn't appear to apply here. Appreciate your knowledge on LVMs p.H, i may need it one day.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Dual boot with Ubuntu - cannot resize partition

#18 Post by p.H »

Of course installing Debian and Ubuntu on the same disk without LVM is possible. In fact if you just need to install Debian and Ubuntu and that's it, LVM is not really useful. I find LVM convenient when I need to dynamically manage multiple volumes on one disk. Two examples :

- When available disk space is tight for the intended use, I can create multiple logical volumes without the fear that some may become undersized while others are oversized. I initially create the volumes with minimal sizes and leave a lot of unallocated space, so that I can easily extend volumes when needed.

- When I want to install, test and remove multiple systems and distributions. If I used plain partitions, this would end up leaving scattered unallocated areas all over the disk between remaining partitions. Creating a new partition or extending existing partitions would often require to move some partitions. With LVM it does not matter whether the free space is fragmented.

geobeck
Posts: 14
Joined: 2018-03-25 16:28
Location: Edmonton, Canada

Re: Dual boot with Ubuntu - cannot resize partition

#19 Post by geobeck »

For anyone following this discussion, I've been reading, and have found a couple of good references. The one that I find to be the most clearly written is from Digital Ocean:

https://www.digitalocean.com/community/ ... operations

There's also a good conceptual overview with some examples on Opensource.com:

https://opensource.com/business/16/9/li ... -guide-lvm

There's also the howto on the Linux Documentation Project, but I find the writing a little dry. It's comprehensive though, and includes everything you can do with the tool:

http://tldp.org/HOWTO/LVM-HOWTO/

I'll post my results when I've completed this project, probably next weekend.

Post Reply