You are not logged in.

#1 2024-05-02 21:48:19

user7z
Member
Registered: 2024-02-26
Posts: 22

[SOLVE]UNBOOTABLE SYSTEM AFTER SHRINKING The filesystem & PARTITION!!

I dive into shrinking my system that is on /dev/nvme0n1 with 2 partitions one 300MB for /efi and the other for my root & home , follow archwiki guide here here
i run the following commands :

1_resize2fs /dev/nvme0n1p1 240G
2_parted /dev/nvme0n1
3_ in the( parted) prompt i run :
      resizepart 1 240GB
After booting my system the fsck check  failed and put me to the  maintenance shell and ask me to manually run it when i do i see this importante message : the filesystem size(accrding to the superblock) is 62914560 blocks , the physical size of the device is 58516694 blocks , either the superblock or the partition table is likely to be corrupt .
For the partition table i have the lazytime option there with the realtime default , my system eas installed via archinstall script with uki enabled and my own partitioninig layout that id mention up , some help here guys i am not comfortable to rienstalling that system

Last edited by user7z (2024-05-03 12:13:28)

Offline

#2 2024-05-03 06:28:04

-thc
Member
Registered: 2017-03-15
Posts: 525

Re: [SOLVE]UNBOOTABLE SYSTEM AFTER SHRINKING The filesystem & PARTITION!!

Did you happen to read the note in the wiki regarding the two uses of "GB" as unit?

You resized your filesystem to 240 GiB (Gebibyte) which leads to

240 * 1024 * 1024 * 1024 = 257698037760 bytes = 503316480 sectors

You re-partitioned your disk to 240 GB (Gigabyte, billions of bytes) via parted to

240 (roughly) * 1000 * 1000 * 1000 = 239684378624 bytes

To recover your system you have to resize the partition again.

1. Boot from the arch live medium
2. Start "fdisk /dev/nvme0n1"
3. Run "p" - write down all sector numbers - note the wrong size of your partition (fdisk also uses Gebibytes)
4. Delete the partition 1 (careful: fdisk's default is the last partition)
5. Create an new partition 1 - the start sector should be the same as before
6. for the size enter "+503316480"
    fdisk detects a filesystem signature - do not delete it!
7. Run "p" again - the size of partition 1 should now be shown as 240G
8. Only if you are sure everything is correct - run "w"
9. Reboot

Offline

#3 2024-05-03 06:37:46

seth
Member
Registered: 2012-09-03
Posts: 52,485

Re: [SOLVE]UNBOOTABLE SYSTEM AFTER SHRINKING The filesystem & PARTITION!!

G in resize2fs is equivalent to GiB in parted
https://man.archlinux.org/man/core/e2fs … ESCRIPTION

suffixed by one of the following units designators: 'K', 'M', 'G', 'T' […] for power-of-two kilobytes, megabytes, gigabytes, terabytes or 512 byte sectors respectively

The manpage used to be a bit more ranting explicit about that, but was likely at some point "sanitized" and now this can be easily overlooked…

Edit: F5…

Last edited by seth (2024-05-03 06:38:15)

Offline

#4 2024-05-03 06:49:50

frostschutz
Member
Registered: 2013-11-15
Posts: 1,425

Re: [SOLVE]UNBOOTABLE SYSTEM AFTER SHRINKING The filesystem & PARTITION!!

With parted, you have to double-check everything since any change is written to the disk immediately without additional prompts... it also uses weird units by default, so... it's easy to make mistakes.

parted doesn't take a SIZE argument, it's END, so the partition ends at 240GB into the disk, regardless where the partition starts. In this case its the first partition so assuming MiB alignment, it will be smaller than 240GB by 1MiB.

With parted if you want to make a partition of a specific size, you have to do the math yourself (start + size to get the correct end).

resizepart 240GiB would be wrong too since that's not the size. if the start is 1 MiB then you'll have to resizepart to 245761 MiB to get a 240 GiB ( 240 * 1024 = 245760 MiB ) large partition. if the start is something else (where is the 300MB EFI partition located?) then you'll have to adapt... use 'unit mib' (or unit s, unit b) and 'print free' to make parted show partition start end size properly, as well as free segments

Last edited by frostschutz (2024-05-03 06:57:40)

Offline

#5 2024-05-03 12:08:01

user7z
Member
Registered: 2024-02-26
Posts: 22

Re: [SOLVE]UNBOOTABLE SYSTEM AFTER SHRINKING The filesystem & PARTITION!!

For the note in the wiki i read it but i didnt understand it and there wasnt any formula there.
i did solve the problem with approach you said i left some of my filesystem blocks outside the partirion!!! I did the approach using parted and actually the units are very uncomfortable , the math says the partition sould be 257.698.. but practicly 258 isnt enough i give it arround 258.4 to reclaime all of the outside lefted blocks. Its working know but i well use gdisk to ensure the sizes are correctly sice iam not comfortable with fdisk on gpt partirion table ,

Offline

#6 2024-05-03 12:15:54

user7z
Member
Registered: 2024-02-26
Posts: 22

Re: [SOLVE]UNBOOTABLE SYSTEM AFTER SHRINKING The filesystem & PARTITION!!

frostschutz wrote:

With parted, you have to double-check everything since any change is written to the disk immediately without additional prompts... it also uses weird units by default, so... it's easy to make mistakes.

parted doesn't take a SIZE argument, it's END, so the partition ends at 240GB into the disk, regardless where the partition starts. In this case its the first partition so assuming MiB alignment, it will be smaller than 240GB by 1MiB.

With parted if you want to make a partition of a specific size, you have to do the math yourself (start + size to get the correct end).

resizepart 240GiB would be wrong too since that's not the size. if the start is 1 MiB then you'll have to resizepart to 245761 MiB to get a 240 GiB ( 240 * 1024 = 245760 MiB ) large partition. if the start is something else (where is the 300MB EFI partition located?) then you'll have to adapt... use 'unit mib' (or unit s, unit b) and 'print free' to make parted show partition start end size properly, as well as free segments

Yeah for i while i think that my fulesystem has been corrupted , well i had to increase the size mathematically 257.6.. practically less a little bit than 258.4

Offline

#7 2024-05-03 14:09:48

user7z
Member
Registered: 2024-02-26
Posts: 22

Re: [SOLVE]UNBOOTABLE SYSTEM AFTER SHRINKING The filesystem & PARTITION!!

The message of -thc giving how the math works so future users who encounter that working accordingly i well add if using gpt partition i recommend using gdisk over its sister fdisk

Last edited by user7z (2024-05-03 14:12:17)

Offline

#8 2024-05-03 14:15:46

seth
Member
Registered: 2012-09-03
Posts: 52,485

Re: [SOLVE]UNBOOTABLE SYSTEM AFTER SHRINKING The filesystem & PARTITION!!

https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
The difference is whether "giga" (or rather "G" or "GB") is interpreted as 2^30 or 10^3

Offline

Board footer

Powered by FluxBB