Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Extend Linux partition

Posted on 2011-03-10
7
Medium Priority
?
622 Views
Last Modified: 2012-05-11
Hello,
I tried to run the following commands:
dd if=/dev/zero of=/swapfile2 bs=1024 count=2097152
mkswap /swapfile2
swapon /swapfile2

and got back:


Complete!
[root@localhost Downloads]#     dd if=/dev/zero of=/swapfile2 bs=1024 count=2097152
dd: writing `/swapfile2': No space left on device
1023361+0 records in
1023360+0 records out
1047920640 bytes (1.0 GB) copied, 47.1536 seconds, 22.2 MB/s
[root@localhost Downloads]#     mkswap /swapfile2
Setting up swapspace version 1, size = 1047916 kB
[root@localhost Downloads]#     swapon /swapfile2
[root@localhost Downloads]# /swapfile2 swap swap defaults 0 0
bash: /swapfile2: Permission denied

[root@localhost Downloads]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2              3960348   3953756         0 100% /
/dev/sda3            1006916148    204412 954738248   1% /home
/dev/sda1                46633     17249     26976  40% /boot
tmpfs                  1455992         0   1455992   0% /dev/shm
.host:/              1452148732 829045272 623103460  58% /mnt/hgfs

How can i increase the size of the /dev/sda2 area?

Thank you
0
Comment
Question by:tamirmilo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 35096083
You cannot.  You are not using LVMs.  However, you could use /home partition.  That has a lot of capacity.  And make sure remove the file you created on the root partition.
0
 
LVL 8

Expert Comment

by:point_pleasant
ID: 35096471
Boot up from PartedMagic LiveCD and reize partitions. PartedMagic is one of the best partition manager.

http://partedmagic.com/doku.php
0
 
LVL 16

Expert Comment

by:Joseph Gan
ID: 35103680
First remove the /swapfile2 under root to free up root.
Then copy files under /home (about 200M) to root temperaly.
Repartition /dev/sda3 to be new /home and swap.
Copy files back to /home.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 12

Expert Comment

by:upanwar
ID: 35104801
There is one more tool to achieve your  goal with good how to.

http://www.howtoforge.com/partitioning_with_gparted   
0
 
LVL 12

Expert Comment

by:mccracky
ID: 35110156
To resize /dev/sda2 (which is a partition):
Use GParted to resize the partitions.  

You could use /home/swapfile2 as /home (/dev/sda3 partition) has lots of space.
0
 

Author Comment

by:tamirmilo
ID: 35110364
Thanks all.
 The problem that i have is that i am using vmware - and the linux CENTOS is starting too fast and i can not get into mode that will read boot disk. I tried to change settings in the *.vmx file but that did not help as well.
Also, the CENTOS installation that i have is not interactive and i can not set the required size (otherwise i would create a new install)
I will probably use the area under /home.

0
 
LVL 7

Accepted Solution

by:
jackiechen858 earned 2000 total points
ID: 35111994
It's easy to enlarge a Linux partition, epically a virtual Linux.

What you need to do is:

1. change the virtual disk size to make it bigger.
2. install another Linux VM,  then add the existing VM's disk file into the second Linux VM as secondary HD
3. boot the second VM, run
fdisk -l

you should see the secondary disk as something like /dev/sdb.
You can use tools like parted/cfdisk  to resize the partition, then extend the file system.

here are some notes I made to resize a EXT3 partition:

Example for a non-root partition /dev/sdb1 mounted on /srv/backup
•      Resize the harddrive in your virtualisation application
•      Umount the partitions that requires to be resized
o      umount /srv/backup
•      Make a Filesystem check in  your partition on that device
o      fsck -n /dev/sdb1
•      Now the partition is clean but it is still using Ext3. Ext3 can not be resize but ext2 can. So we need to convert the partition ext3 to ext2. The conversion is basically done disabling journal on ext3
o      tune2fs -O ^has_journal /dev/sdb1
•      Now we need to make another filesystem check on ext2 format
o      e2fsck -f /dev/sdb1
•      Delete partition /dev/xvdb1 and create it again with the new size
o      cfdisk /dev/sdb  
### this step is very important, cfdisk seem working better than parted to delete/recreate the sdb partition.


•      Do a filesystem check to make sure that everything is running smoothly
o      fsck -n /dev/sdb1
•      Run the resize command so ext2 knows about the enlarged size of the partition
o      resize2fs /dev/sdb1
•      Turn on journal again (Making it ext3)
o      tune2fs -j /dev/sdb1
•      Remount the parttion
o      mount /srv/backup
•      Check the size
o      df  -h






0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question