LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-21-2020, 06:18 PM   #1
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,044

Rep: Reputation: Disabled
[Call for testing] A script to make room for Slackware or Slint alongside another Linux


The attached script, also available here, shrinks the last partition of a drive to free some space on it.

This can allow to install Slackware or Slint on the same drive as another already installed Linux distribution.

Indeed this can be done by gparted, but being just a shell script it can be run directly from the Slackware or Slint installer. Incidentally being a command line application it is accessible to blind users through a Braille device or a console screen reader like speakup.

It only handles partitions formatted with an ext* file system that are the last one of the drive. I should work if the drive has a GPT or a DOS partition table. It tries hard to be fool proof.

Theory of operation:
  • List the partitions meeting the specs.
  • Let the user choose which one to shrink if several.
  • Check that the partition be not mounted, especially not as /
  • Let the user type the new (smaller) size of the partition in a range, as a number of gigabytes.
  • Check the file system.
  • Shrink the file system.
  • Shrink the partition.
I tested on Slint using the same versions of the software e2fsprogs and util-linux as in Slackware-current, built for Slint.

Please test and report any issue.

To get back the initial sizes of the file system and the partition you could run something like below. I assume that the drive is named /dev/sdb and that the partition has the number 4 and is named /dev/sdb4, adapt accordingly:
Code:
umount /dev/sdb4
e2fsck -f /dev/sdb4
echo ",+" | sfdisk  --no-tell-kernel --no-reread -N 4 /dev/sdb
partprobe
resize2fs /dev/sdb4
The options "--no-tell-kernel --no-reread" are only useful if you run the script from a partition on the same drive as the target.

EDIT. I added the partprobe command to make the kernel aware of the new layout, else resize2fs would say "nothing to do".

PS Indeed Slackware as Slint can be installed alongside Windows on the same drive (preferably in EFI mode to avoid interference between boot loaders in my opinion). I do not plan to provide a script to shrink a Windows volume, as it is doable and probably safer from Windows itself, cf.: https://docs.microsoft.com/en-us/win...a-basic-volume

PPS According to "man btrfs-resize" and "man resize_reiserfs" it should be possible to support btrfs and reiserfs file systems too (not xfs and f2fs if I understand well). I have zero experience with these, proposed patches are welcome. EDIT: the 'chfs' command is supposed to allow shrinking jfs2 file systems, but doesn't seem to be available for Linux. At least it's not provided by jfsutils.
Attached Files
File Type: txt shrinklastpart.txt (6.8 KB, 16 views)

Last edited by Didier Spaier; 07-25-2020 at 12:08 PM. Reason: PPS added.
 
Old 07-23-2020, 09:40 AM   #2
igadoter
Senior Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: many, primary Slackware
Posts: 2,717
Blog Entries: 1

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
What about lvm2? I went into problem yesterday - my fault I should first read something about lvm2 - configuration is four primary partitions - on partition 1 there is lvm2 installed on top of which is Devuan. I just tried very direct procedure: remove partition 1 create new and install system with setup. It completely failed. Afterthat I was unable to boot system with kerenel_panic to boot on unknown device. Luckily I was capable to reinstall Devuan. So the old configuration remains and I am stuck. But at least I can work.
 
Old 07-23-2020, 10:18 AM   #3
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,044

Original Poster
Rep: Reputation: Disabled
lvm is not (yet?) in the scope. As written in the script:
Quote:
# List the candidates targets for shrinking.
# We select the last partition of each drive that have an ext* file
# system and at least $MINFREE of free space, excluding zram, and also
# lvm and crypted or raid devices (lsblk displays the type 'lvm', 'crypt'
# raid or md<number> respectively instead of 'disk' for these)
# I didn't try to shrink a Xen virtual block device like /dev/xvd*, so
# let's exclude that for now.
This being said, I'd be glad for a patch allowing to handle lvm in the script. Same applies for raid and other extensions of the scope.

Last edited by Didier Spaier; 07-23-2020 at 10:19 AM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SLINT - The Slackware Internationalization Project Didier Spaier Slackware 448 02-13-2021 06:27 PM
[SOLVED] Strange NO Room left message when I have plenty of room on HDD BW-userx Linux - Hardware 4 12-14-2015 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration