LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-09-2007, 09:01 PM   #1
bcg121
LQ Newbie
 
Registered: Oct 2007
Location: Pennsylvania
Posts: 19

Rep: Reputation: 0
Move /dev/hda2 to end of disk and grow /dev/hda1


My root partition is on /dev/hda1 and my swap partition is on /dev/hda2.

I want to write a script that will move the swap partition to the end of the disk (or delete it and recreate it at the end of the disk) and then resize the root partition to fill the entire space in between. Script should not require any user input. Disk can be any size from 2GB to 40GB. Script will be executed while booted from SystemRescueCD.

How can I do this? I assume parted could be used in the resize step. Any help would be much appreciated. Thanks.
 
Old 11-09-2007, 09:16 PM   #2
dtcs
LQ Newbie
 
Registered: Jul 2005
Distribution: Slackware, Debian
Posts: 28

Rep: Reputation: 15
I assume you need to do this many times.
Yes parted would be a good choice maybe the only.
Write a simple bash script and call parted with predefined flags to handle the disk manipulation.
 
Old 11-09-2007, 09:24 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
The swap is easy - swapoff, recreate it, mkswap, swapon.
I do a lot of fiddling with partitions. There is no way I'd use a script - too bloody dangerous if you get the maths wrong.
 
Old 11-09-2007, 09:31 PM   #4
bcg121
LQ Newbie
 
Registered: Oct 2007
Location: Pennsylvania
Posts: 19

Original Poster
Rep: Reputation: 0
Yes, I need to do this many times. Basically I'm looking to do Example 1 from the GNU Parted manual (http://rush.ict.pwr.wroc.pl/docs/parted-1.4.16/USER), but without needing a user to input the start and end for the mkpartfs and the resize. The disk size can differ, so the start and end could change.
 
Old 11-09-2007, 09:51 PM   #5
bcg121
LQ Newbie
 
Registered: Oct 2007
Location: Pennsylvania
Posts: 19

Original Poster
Rep: Reputation: 0
Some docs say that negative numbers in parted count from the end of the disk. Would something like the following work?

parted move 2 -125 -0
parted resize 1 0.063 -125

Would this move the swap partition in the previously cited Example to 125 megabytes from the end of the disk, and then resize the root partition to fill up the rest?
 
  


Reply



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
dd if=/dev/urandom of=/dev/hda2 bs=1M doesn't work Melsync Linux - General 16 05-19-2014 06:36 PM
Moving /boot from /dev/hda2 to /dev /hda3 Neo-Leper Linux - General 12 07-20-2007 10:20 PM
merging /dev/hda2 and /dev/hda3 aggiridharan Linux - General 2 01-06-2006 01:31 AM
Grub Dual Boot /dev/sda1 /dev/hda1 jono268 Debian 4 01-14-2005 04:54 AM
swap, /dev/hda2 by /dev/hands :) kaN5300 Slackware 2 09-13-2004 03:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:13 PM.

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