The officially official Devuan Forum!

You are not logged in.

#1 Today 01:45:25

zapper
Member
Registered: 2017-05-29
Posts: 1,191  

[SOLVED] resizing after a diskclone to recover reclaimed space

I have done the following:

cfdisk /dev/sda in live image or w/e
partprobe

and now my lvmvg matches the luks volume size.

However, I am trying to rezize my home partition volume and it keeps saying stuff like there is nothing to add.

I have 476.6G of 1.8 TB being used currently used, so I know there is something wrong

Can someone help me out here?

CLI instructions required btw.


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!

Online

#2 Today 06:27:38

wert
Member
Registered: 2025-10-30
Posts: 8  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

my bet:

you cloned small one to big one. But old small's  mbr/gpt header still effective.
you should update that old mbr/gpt header.
look at fdisk/gdisk 's recovery and/or expert menu.
may be helpers in there.

Disclaimer: i dont know lvm stuff single bit.
this is my tiny gpt util. feel free to modify as your need and others guys also so.

#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>

#define SIG		0x5452415020494645UL
#define HDR		0x5c
#define MBR		510
#define OS_EFI	0xEF
#define OS_GPT	0xEE
#define OS		450
#define LBA		0x200UL
#define ALL		0x400UL

struct part {
	long	t[2];		//type
	long	g[2];		//guid
	long	f;			//first LBA
	long	l;			//last  LBA
	long	a;			//attrs
	char	n[72];		//name;
} __attribute__ ((packed));

struct gpt {// NOTICE!: LBA's are zero based.
	long		s;		//sign
	int			r;		//rev
	int			h;		//headersize: 0x5c
	unsigned	hc;		//header crc32
	int			res;
	long		c;		//currentLBA
	long		b;		//backupLBA
	long		f;		//firstUsableLBA
	long		l;		//lastUsableLBA
	long		g[2];	//guid
	long		p;		//partition table LBA
	int			n;		//#part
	int			e;		//sizeof(struct part)
	unsigned	pc;		//part table crc32
	char	res2[420];
} __attribute__ ((packed));

static unsigned long	crc, crctab[256], poly = 0xEDB88320L;
static int				ii, jj;

unsigned crc32 (unsigned char *block, unsigned len){
   crc  = 0xFFFFFFFF;
   for (ii = 0; ii < len; ii++) crc = ((crc >> 8) & 0x00FFFFFF) ^ crctab[(crc ^ *block++) & 0xFF];
   return (crc ^ 0xFFFFFFFF);
}

void crc32tab(void){
	for (ii = 0; ii < 256; ii++){
		crc = ii;
		for (jj = 8; jj > 0; jj--){
			if(crc & 1)	crc = (crc >> 1) ^ poly;
			else		crc >>= 1;
		}
		crctab[ii] = crc;
	}
}

static struct gpt   *hd;
static struct part	*pr;
static char         buf[ALL];
static int          disk_fd, partindex, parttype;
static long         disksize, partstart, partsize;

static char
parttypes[5][16] = {
		{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //unused
		{ 0x28, 0x73, 0x2a, 0xc1, 0x1f, 0xf8, 0xd2, 0x11, 0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b }, //efi
		{ 0xe3, 0xbc, 0x68, 0x4f, 0xcd, 0xe8, 0xb1, 0x4d, 0x96, 0xe7, 0xfb, 0xca, 0xf9, 0x84, 0xb7, 0x09 }, //lin64
		{ 0xaf, 0x3d, 0xc6, 0x0f, 0x83, 0x84, 0x72, 0x47, 0x8e, 0x79, 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4 }, //lin
		{ 0xb6, 0x7c, 0x6e, 0x51, 0xcf, 0x6e, 0xd6, 0x11, 0x8f, 0xf8, 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b }, //freebsd UFS
};

long time(long*);

int main(int ac, char* av[]){
	if(ac != 7){
		printf("Usage: %s  disk  disksize  parttype  partindex  partstart  partsize \n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
			av[0],
			"disk       : /dev/sdX",
			"disksize   : disk size (as LBA)",
			"parttype   : numeric type of partition",
			"partindex  : part index (0 based)",
			"partstart  : part start LBA (0 based)",
			"partsize   : part size (as LBA)"
		);
		printf("Supported part types:\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
			"0 -> unused/free",
			"1 -> EFI",
			"2 -> linux x86_64 root",
			"3 -> linux fs",
			"4 -> freebsd ufs"
		);

		return 0;
	}

	time(NULL);

	disk_fd		= open(av[1], O_RDWR);
	disksize	= strtol(av[2], NULL, 10);
	parttype	= atoi(av[3]);
	partindex	= atoi(av[4]);
	partstart = strtol(av[5], NULL, 10);
	partsize	= strtol(av[6], NULL, 10);

	if(!disksize){
		read(disk_fd, buf, LBA);  //load pmbr
		read(disk_fd, buf, LBA);  //load gpt
		read(disk_fd, buf + LBA, LBA);  //load parts
		hd = (struct gpt*) buf;
		pr = (struct part*) (buf + LBA);
		printf("current  %ld  bakup  %ld  firstUsable  %ld lastUsable %ld  part %ld #parts %d entrysize %d hdrsize %d\n", hd->c, hd->b, hd->f, hd->l, hd->p, hd->n, hd->e, hd->h);

		for(ii=0; ii<4; ii++){
			printf("type  %lx %lx  firstUsable  %ld lastUsable %ld \n", pr[ii].t[0], pr[ii].t[1], pr[ii].f, pr[ii].l);
		}

		return 0;
	}

	crc32tab();

	buf[OS]		= OS_GPT;
	*(unsigned*)(buf + OS + 4)	= 1;
	*(unsigned*)(buf + OS + 8)	= 1;
	buf[MBR]	= 0x55;
	buf[MBR+1]	= 0xaa;
	crc = write(disk_fd, buf, LBA); //update pmbr
	printf("io1 %lu \n", crc);

	crc = read(disk_fd, buf, LBA);  //load gpt
	printf("io2 %lu \n", crc);
	crc = read(disk_fd, buf + LBA, LBA);  //load parts
	printf("io3 %lu \n", crc);

	memset(buf, 0, LBA);
	hd = (struct gpt*) buf;
	pr = (struct part*) (buf + LBA);

	hd->s = SIG;
	hd->r = 0x10000;
	hd->h = HDR;

	hd->c = 1;
	hd->b = hd->c; //disksize; backup disabled for simplicity

	hd->f = hd->c + 2;
	hd->l = disksize - 2; //son sektor bakup'a rezerve.

	hd->g[0] = time(NULL);
	hd->g[1] = time(NULL);

	hd->p = hd->c + 1;
	hd->n = 4;
	hd->e = 128;

	memcpy(pr[partindex].t, &parttypes[parttype], 16);
	pr[partindex].g[0] = time(NULL);
	pr[partindex].g[1] = time(NULL);
	pr[partindex].f = partstart;
	pr[partindex].l = partstart + partsize - 1;
	pr[partindex].a = 0;
/* once pc hesaplanmali! */
	hd->pc = crc32((unsigned char*)pr, hd->n * hd->e);
	hd->hc = crc32((unsigned char*)hd, hd->h);

	crc = lseek(disk_fd, LBA, SEEK_SET); //goto gpt
	printf("io4 %lu \n", crc);
	crc = write(disk_fd, buf, LBA); //update gpt
	printf("io4 %lu \n", crc);
	crc = write(disk_fd, buf+LBA, LBA); //update part table
	printf("io6 %lu \n", crc);
	sync();

	close(disk_fd);
	if(errno) perror("");

	return 0;
}

Last edited by wert (Today 06:44:07)

Offline

#3 Today 06:54:09

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,546  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

@zapper: I'm guessing you need to resize the "home" logical volume to use up all the volume group space, and you then need to enlarge the filesystem inside the logical volume to fill all available logical volume space.

Possibly it all can be done in a sinlge command, something like:

# lvresize -l 100%VG -r $LVM

where you replace $LVM with the identity fo the logical volume.

A backup might be handy.

Offline

#4 Today 12:53:56

zapper
Member
Registered: 2017-05-29
Posts: 1,191  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

@ralph Hmm not working...

@Vert yes I did clone a smaller to a bigger. I forget if e2fsck, partimage, partclone or something else is needed


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!

Online

#5 Today 13:15:31

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,546  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

??? Did the command actually say "Hmm not working..." ???

Offline

#6 Today 13:17:48

zapper
Member
Registered: 2017-05-29
Posts: 1,191  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

@ralph more or less it didn't work I mean.

Funny thing is, I did this long ago and got it to work. I forget the guide I found though.

Its online somewhere, but... I can't find it easily.


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!

Online

#7 Today 13:20:37

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,546  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

Ah, so you don't want help. Fair enough.

Offline

#8 Today 13:21:29

zapper
Member
Registered: 2017-05-29
Posts: 1,191  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

@ralph not even close to the truth, I don't know why you said that


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!

Online

#9 Today 13:25:09

zapper
Member
Registered: 2017-05-29
Posts: 1,191  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

here is some more info:
nvme0n1           259:0    0   1.8T  0 disk 
├─nvme0n1p1       259:1    0   300M  0 part  /boot
└─nvme0n1p2       259:2    0   1.8T  0 part 
  └─lvmvg         254:0    0   1.8T  0 crypt
    ├─user-root 254:1    0    25G  0 lvm   /
    └─user-home 254:2    0 451.6G  0 lvm   /home


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!

Online

#10 Today 13:30:12

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,546  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

In order for me to assist I will need to sight the exact result/response from the command I suggest; not some hand-wavy "it didn't work" or anything wiffle waffle ... I need to the exact response.

Offline

#11 Today 13:47:06

zapper
Member
Registered: 2017-05-29
Posts: 1,191  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

@ralph

Fair enough, but would showing you vgdisplay, pvdisplay, help

EDIT: I figured out the next step,

had to do this:

lvextend -L +100%FREE /dev/mapper/matrix-home

with gparted disabling luks encryption temporarily

Now I need to go from there.

its now in the physical volume but not yet the virtual volume, etc...

EDIT ONE MORE:

It still doesn't show in my file manager or home the change. yet.

Last edited by zapper (Today 14:13:36)


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!

Online

#12 Today 14:17:44

zapper
Member
Registered: 2017-05-29
Posts: 1,191  

Re: [SOLVED] resizing after a diskclone to recover reclaimed space

Actually, I think my file manager is having a glitch or something because everywhere else indicates it has been raised to the correct amount of memory.

EDIT: Maybe its not the file manager, because I tried doing lvextend -l +100%FREE to my volume and it acted like it had the old amount of storage... very weird.

Very peculiar indeed...

/dev/volume/home seems to have 1.79TB (lsblk command)

but home folder only has 443GB when I check it with lvextend +100%FREE (spacefm)

Very peculiar...

EDIT FIGURED IT OUT!

resize2fs /dev/myvolume/home was the final touch.

cfdisk /dev/sda in live image or w/e
partprobe
lvextend -L +100%FREE /dev/mapper/matrix-home
#####must be in devuan after gparted unlocks luks (did so via usb persistent install)
resize2fs /dev/matrix/home

That's how I did it.  SOLVED.

Last edited by zapper (Today 14:40:58)


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!

Online

Board footer