LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Simple question: How do I resize my partitions using CLI? (https://www.linuxquestions.org/questions/linux-newbie-8/simple-question-how-do-i-resize-my-partitions-using-cli-4175572222/)

Otherworlds 02-14-2016 04:38 AM

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!

Otherworlds 02-14-2016 04:45 AM

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...

Gary Baker 02-14-2016 05:56 AM

I would suggest the parted command. It is probably available in Ubuntu or mint.

Otherworlds 02-14-2016 08:21 AM

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??

Otherworlds 02-14-2016 08:34 AM

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!!!

Otherworlds 02-14-2016 08:53 AM

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...

Higgsboson 02-14-2016 10:03 AM

Quote:

Originally Posted by Otherworlds (Post 5500040)
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.

rknichols 02-14-2016 10:23 AM

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.

DavidMcCann 02-14-2016 11:09 AM

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.

hydrurga 02-14-2016 11:31 AM

Quote:

Originally Posted by DavidMcCann (Post 5500090)
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.

hydrurga 02-14-2016 11:37 AM

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.

Otherworlds 02-14-2016 11:38 AM

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..

Higgsboson 02-14-2016 11:43 AM

Quote:

Originally Posted by hydrurga (Post 5500097)
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.

hydrurga 02-14-2016 11:56 AM

Quote:

Originally Posted by Higgsboson (Post 5500105)
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.

rknichols 02-14-2016 01:19 PM

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.


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