Solved

Extend Linux partition

Posted on 2011-03-10
7
616 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
awk sed 8 110
Linux script delete files 3 58
Linux Real Time Memory on Distinct 24 Cycle 7 44
CLI command keep running after close 7 56
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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