Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-19-2011, 03:25 PM   #1
LQ Newbie
Registered: Feb 2011
Posts: 2

Rep: Reputation: 0
Partitioning wildcards

I'm building a p2v script for work, and in order to make it work I need a noninteractive command that will create a partition out of all the remaining space on a disk.

Example, with a drive that ends with 8552:

parted /dev/sda mkpart primary 102 8552
Only, it's going to depend every time, what that 8552 is. What I really want is a wildcard to tell parted(or whatever noninteractive partitioning tool I'm using) just to allocate all the remaining free space. Something like:

parted /dev/sda mkpart primary 102 *

parted /dev/sda mkpart primary 102 -1
Except, of course, one that will work, as these do not.

Am I up the creek here? Has anyone here ever dealt with this?
Old 02-19-2011, 05:01 PM   #2
LQ Newbie
Registered: Mar 2009
Posts: 8

Rep: Reputation: 0

Yes, I've run into this before, the answer was to use fdisk under awk to extract the size, I'll dig thru my archives and post a snippet when I get a moment of time. Alternatively you may want to look int lshw if you know the device name of the storage you can get its total size there, where as cat /proc/parttions does not give you a size.
Old 02-19-2011, 05:42 PM   #3
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,329

Rep: Reputation: 254Reputation: 254Reputation: 254
When there is no unit mentioned it defaults to megabyte. But it's possible to specify a different unitn there, i.e. something like 100%
1 members found this post helpful.
Old 02-27-2011, 12:28 PM   #4
LQ Newbie
Registered: Feb 2011
Posts: 2

Original Poster
Rep: Reputation: 0
I found a solution. It's sloppy but it works.

END=`parted /dev/sda print | grep ^Disk | awk '{ print $3}' | sed -e 's/MB$//'`
parted /dev/sda mkpart primary 1 101 mkpart primary 102 $END
It'll have to do.



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
need help with wildcards yanivmomo Programming 4 05-24-2010 08:37 AM
need help with wildcards liorpana Programming 2 05-12-2010 09:45 AM
wildcards with find tramni1980 Slackware 2 10-03-2009 06:47 AM
using wildcards nadroj Linux - General 5 01-28-2007 09:39 PM
Wildcards dazdaz Linux - Newbie 3 01-23-2005 06:33 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration