LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
 
Search this Thread
Old 01-04-2013, 08:17 AM   #1
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Rep: Reputation: 16
Question Partition layout


Hi,
I am trying to use parted in bash script to create partition table using percentage of the total disk space.
I want to use % so do not have to change script for different HDD size.
I get the total disk size this way:
Code:
DEV=/dev/sda 
 HDDSZ=$( parted -s $DEV unit B print | grep "^Disk $DEV:" | cut -f 3 -d " " | tr -d B )
Then how can i use parted in the script.
Thanks for your quick prompt

Last edited by NetRock; 01-07-2013 at 06:18 AM.
 
Old 01-04-2013, 08:28 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970
Any chance of a little background on your need to do this in the first place? It seems like a pretty weird layout. 1gbfor /boot is a waste for one thing... and why no LVM? Where on earth does 0.31% come from? Why is the extended partition left 89% empty?

It looks like parted scripts can take a % sign anyway, so there's no need to calculate the percentages yourself in the first place.

Code:
parted -s $DEV unit MB mkpart primary 0% 1%

http://linux.die.net/man/8/parted
 
Old 01-04-2013, 09:15 AM   #3
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
Thanks for your reply.

Last edited by NetRock; 01-07-2013 at 06:18 AM.
 
Old 01-04-2013, 09:18 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970
Can you respond to the questions in my post, or any of the contents at all? Just posting more information isn't exactly engaging in a discussion.
 
Old 01-04-2013, 09:33 AM   #5
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
Chris, Sorry about that.
Well, i know i need to change the layout, this layout was used for many years and given to me, perhaps you can share your idea to the best way as how to manage the size for sda1 to sda8 with respect to their file system.
But my concern is to get the script working first and then the layout can be changed with your suggestions.
i do not wish to use LVM at this time.
i appreciate your help.
Thanks
 
Old 01-04-2013, 09:35 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970
well as above, you can put percentages into the parted script, so how does that work?
 
Old 01-04-2013, 09:37 AM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Whatever fits the task best
Posts: 16,210
Blog Entries: 2

Rep: Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425Reputation: 4425
Quote:
Originally Posted by NetRock View Post
where 1075MB comes from since i have 1025MB in the script.
parted internally doesn't work with MB, it works with cylinders, so partitions will be aligned to the next cylinder, IIRC.
 
Old 01-04-2013, 09:38 AM   #8
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
I use this command to know where begins the first sector:

Quote:
parted /dev/sda unit s p free

Disk /dev/sda: 1048576000s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
34s 1048576000s 1048576000s Free Space
 
Old 01-04-2013, 09:55 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970
why do you care where the first sector is?
 
Old 01-04-2013, 09:59 AM   #10
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
to create partitions correctly aligned ....!!
 
Old 01-04-2013, 10:00 AM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970Reputation: 1970
parted should do this for you if you use percentages I'd presume.

Note that kickstart or other installer toosl do this trivially, that might be a better option anyway.
 
  


Reply


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
Best partition Layout Laodiceans Slackware 9 08-06-2010 07:55 PM
Modifying partition layout & partition order rm_-rf_windows Linux - General 3 06-28-2007 05:16 AM
partition layout pilatus666 Linux - Newbie 4 06-06-2006 01:44 AM
partition layout vs performance? kostian Linux - General 3 11-08-2004 07:34 PM
Partition Layout for a Samba PDC....? tarballed Linux - General 16 05-09-2003 01:05 PM


All times are GMT -5. The time now is 03:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration