LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2016, 05:38 AM   #1
Otherworlds
Member
 
Registered: Feb 2016
Posts: 49

Rep: Reputation: Disabled
Simple question: How do I resize my partitions using CLI?


Root@User# df -h

Filesystem Size Used Avail Use% Mounted on
dev/sda1 8.2G 2.3G 5.5G 30% /
udev 10M 0 10M 0% /dev
tmpfs 609M 8.4M 601M 2% /run
tmpfs 1.5G 68K 1.5G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1.5G 0 1.5G 0% /sys/fs/cgroup
dev/sda7 360M 2.1M 335M 1% /tmp
dev/sda8 131G 61M 124G 1% /home
dev/sda5 2.7G 296M 2.3G 12% /var
tmpfs 305M 4.0K 305M 1% /run/user/116
tmpfs 305M 8.0K 305M 1% /run/user/1000

Root@user# parted -l
Number Start End Size Type File System Flags
1 1049kb 9000MB 8999MB primary ext4 boot
2 9001MB 161GB 152GB extended
5 9001MB 12.0GB 2999MB logical ext4
6 12.0GB 18.9GB 6489MB logical Linux-swap(v1)
7 18.5GB 18.9GB 398MB logical ext4
8 18.9GB 161GB 142GB logical ext4

Hello everyone I would like to resize dev/sda8 to make another partition using the command line, can anyone please tell me how to do this? Thanks in advance!

Last edited by Otherworlds; 02-17-2016 at 08:45 PM.
 
Old 02-14-2016, 05:45 AM   #2
Otherworlds
Member
 
Registered: Feb 2016
Posts: 49

Original Poster
Rep: Reputation: Disabled
Root@User# df -h

Filesystem Size Used Avail Use% Mounted on
dev/sda1 8.2G 2.3G 5.5G 30% /
udev 10M 0 10M 0% /dev
tmpfs 609M 8.4M 601M 2% /run
tmpfs 1.5G 68K 1.5G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1.5G 0 1.5G 0% /sys/fs/cgroup
dev/sda7 360M 2.1M 335M 1% /tmp
dev/sda8 131G 61M 124G 1% /home
dev/sda5 2.7G 296M 2.3G 12% /var
tmpfs 305M 4.0K 305M 1% /run/user/116
tmpfs 305M 8.0K 305M 1% /run/user/1000

Root@user# parted -l
Number Start End Size Type File System Flags
1 1049kb 9000MB 8999MB primary ext4 boot
2 9001MB 161GB 152GB extended
5 9001MB 12.0GB 2999MB logical ext4
6 12.0GB 18.9GB 6489MB logical Linux-swap(v1)
7 18.5GB 18.9GB 398MB logical ext4
8 18.9GB 161GB 142GB logical ext4

Hello everyone I would like to resize dev/sda8 to make another partition using the command line, can anyone please tell me how to do this? Thanks in advance! I realize the numbers are sorta crunched up, I apologize it's just how it came it out...facepalm for double post mybad...

Last edited by Otherworlds; 02-17-2016 at 08:47 PM.
 
Old 02-14-2016, 06:56 AM   #3
Gary Baker
Member
 
Registered: Mar 2007
Location: Whitsett,NC
Distribution: Slackware 14.1 and MINT 17.1
Posts: 105

Rep: Reputation: 3
I would suggest the parted command. It is probably available in Ubuntu or mint.
 
Old 02-14-2016, 09:21 AM   #4
Otherworlds
Member
 
Registered: Feb 2016
Posts: 49

Original Poster
Rep: Reputation: Disabled
Yeah I actually am using parted, but when I press resizepart it asks for partition number? Then when I press 8, as I think that is the partition "/dev/sda8 logical" it then says that partition doesn't exsist??

Last edited by Otherworlds; 02-17-2016 at 08:48 PM.
 
Old 02-14-2016, 09:34 AM   #5
Otherworlds
Member
 
Registered: Feb 2016
Posts: 49

Original Poster
Rep: Reputation: Disabled
Got it I just needed to keep it selected at /dev/sda.... I been selecting /dev/sda8 and that's why it didn't work.. OK thanks tho!!!
 
Old 02-14-2016, 09:53 AM   #6
Otherworlds
Member
 
Registered: Feb 2016
Posts: 49

Original Poster
Rep: Reputation: Disabled
Hi again a new problem arose when I went to resize /dev/sda8 and rebooted my system, it popped me in emergency mode, is this normal?? I don't understand because I'm pretty sure /dev/sda8 is the bulk of free space that's avaliable on my hard drive.... Do I do something wrong? Luckily it's a virtual machine, but I'm desperately trying to learn how to partition so any help would be appreciated thanks again!!! Another note to add, when I partitioned with resize part using parted I put 50G End...

Last edited by Otherworlds; 02-14-2016 at 10:47 AM.
 
Old 02-14-2016, 11:03 AM   #7
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 49
Quote:
Originally Posted by Otherworlds View Post
Hi again a new problem arose when I went to resize /dev/sda8 and rebooted my system, it popped me in emergency mode, is this normal?? I don't understand because I'm pretty sure /dev/sda8 is the bulk of free space that's avaliable on my hard drive.... Do I do something wrong? Luckily it's a virtual machine, but I'm desperately trying to learn how to partition so any help would be appreciated thanks again!!! Another note to add, when I partitioned with resize part using parted I put 50G End...
I always use gparted. It's a gui.
It shows a diagram of your partitions on the disk, their locations and how much space is used up on each partition.
To make changes, you simply click the fields on the gui, input numbers for the sizes etc and then press 'apply'. Really simple to use.
Use 'apt-get install gparted' and have a look through it.
I saw a tutorial on parted and it's way too complicated.
 
Old 02-14-2016, 11:23 AM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,615

Rep: Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576
It appears that you made the partition smaller without first resizing the filesystem that was in it. First, you need to use parted again to expand sda8 back to its original size. Then run "fsck -f /dev/sda8" to check the filesystem. That should allow /home to be mounted again.

You cannot shrink a filesystem while it is mounted. It is best to boot your VM from separate media, either the gparted live CD or, my own favorite, SystemRescueCd, which includes gparted and a lot of other useful tools for recovery. Rather than parted, I suggest using gparted, which is really a very different tool (not just a GUI front end for parted) and is capable of resizing a partition and its filesystem at the same time. That's a lot easier than caclulating what size to make a filesystem so that it will fit into its new, smaller partition.
 
Old 02-14-2016, 12:09 PM   #9
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 4,706

Rep: Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506Reputation: 1506
This shows everything you'll ever need to know about gparted:
http://www.dedoimedo.com/computers/gparted.html
I'd also endorse the idea of getting SystemRescueCD. For me, having that in the cupboard is as essential as having backups.
 
Old 02-14-2016, 12:31 PM   #10
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Quote:
Originally Posted by DavidMcCann View Post
This shows everything you'll ever need to know about gparted:
http://www.dedoimedo.com/computers/gparted.html
I'd also endorse the idea of getting SystemRescueCD. For me, having that in the cupboard is as essential as having backups.
Just to add my tuppence, I use a bootable USB stick which I created and populate with YUMI - it contains useful software such as Gparted Live, MiniTool Partition Wizard, memtools86+, Boot Repair Disk, Macrium Reflect Free, Darik's Boot & Nuke etc. You can just add these ISOs to the stick as you go along using YUMI, which provides a menu interface at bootup to choose from the various ISOs. A very useful tool indeed.
 
Old 02-14-2016, 12:37 PM   #11
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
I should add to my post above that, in case anyone is wondering, I use the Linux software GParted Live for general work and resizing partitions with ext2/3/4 filesystems, while I use the Windows software MiniTools Partition Wizard for resizing partitions with NTFS filesystems. I know that theoretically both programs should cope with both sorts of filesystem, but I've had a much better success rate doing it that way.
 
Old 02-14-2016, 12:38 PM   #12
Otherworlds
Member
 
Registered: Feb 2016
Posts: 49

Original Poster
Rep: Reputation: Disabled
I'm really trying to just stick to the command line because I don't want a GPU enabled... I would use gparted as long as it doesn't require a GUI (correct me if I'm wrong, but I don't think I can use a GUI without a graphics card) I think rknichols already hinted it doesn't require a GUI, but for reassurance could I get some more feedback on this, thank you..
 
Old 02-14-2016, 12:43 PM   #13
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 49
Quote:
Originally Posted by hydrurga View Post
Just to add my tuppence, I use a bootable USB stick which I created and populate with YUMI - it contains useful software such as Gparted Live, MiniTool Partition Wizard, memtools86+, Boot Repair Disk, Macrium Reflect Free, Darik's Boot & Nuke etc. You can just add these ISOs to the stick as you go along using YUMI, which provides a menu interface at bootup to choose from the various ISOs. A very useful tool indeed.
On the Yumi bootloader, can you add a DVD copy of a Debian.iso?
If so, then I could select the .iso file and it would run the launcher to install an OS on my hard disk.
 
Old 02-14-2016, 12:56 PM   #14
hydrurga
Senior Member
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 18.2 MATE
Posts: 3,491
Blog Entries: 2

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Quote:
Originally Posted by Higgsboson View Post
On the Yumi bootloader, can you add a DVD copy of a Debian.iso?
If so, then I could select the .iso file and it would run the launcher to install an OS on my hard disk.
http://www.pendrivelinux.com/yumi-mu...ported-Distros

Debian Live is supported (although I also use a number of unsupported ISOs that work fine so don't shy away if your specific ISO is "unsupported").

@Otherworlds: Hoping you get resolution to your problem. You should be able to do everything you wanted to do with parted and resizefs but I'm not au-fait enough with those tools (yet) to advise you.

To be extra safe, you should first boot off a live cd/dvd/usb stick containing a partition backup program (I use Macrium Reflect Free because I come originally from a Windows background and that's what I'm used to) and backup any partitions that you are going to play with. In fact, backing up the whole disk, if possible, is a good idea.
 
Old 02-14-2016, 02:19 PM   #15
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,615

Rep: Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576Reputation: 1576
gparted does require a GUI. Sorry, wasn't aware you had no graphics card.

To do this without a GUI, first restore the original partition size and run "fsck -f /dev/sda8" to ensure the filesystem is OK.

Next, resize the filesytem to something a bit less than the target 50GB size:
Code:
resize2fs /dev/sda8 45G
Use parted or other partitioning tool to resize the partition to 50G.

Run "fsck -f /dev/sda8" again to make sure the filesystem is still within the partition.

Finally, run "resize2fs /dev/sda8" (without a size argument) to expand the filesystem to fill its 50GB partition.

You'll need to do all this while /home is unmounted. You cannot shrink a mounted filesystem. The multiple resize2fs operations are recommended because it is difficult to calculate the size to make the filesystem so that it will fill its new partition exactly. There is too much roundoff, discrepancy between GB and GiB, etc., and what you need is an exact number.

Last edited by rknichols; 02-14-2016 at 02:22 PM.
 
  


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
[SOLVED] Is it safe to resize my Slackware partitions after removing my Mint 10 partitions? Robert.Thompson Slackware 19 02-18-2011 12:47 PM
How to resize image in CLI with keeping palette and type as original ts4053 Linux - Software 1 01-05-2010 09:35 AM
[SOLVED] Very simple CLI question togo59 Linux - Newbie 7 12-14-2009 12:29 PM
simple CLI question about size of HD? Lleb_KCir Linux - General 4 06-10-2004 10:00 PM
Simple Newb Question: How do I check what version of Redhat is Installed from the CLI praefex Linux - General 1 01-27-2004 08:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:09 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration