LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-02-2010, 06:26 AM   #1
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 357

Rep: Reputation: 38
Using parted


I am using parted to partition a hard disk

Code:
scarecrow:~ # parted /dev/sdb
GNU Parted 2.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s                                                           
(parted) print                                                            
Model: SanDisk U3 Cruzer Micro (scsi)
Disk /dev/sdb: 15695871s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End        Size       File system  Name     Flags


(parted) mkpart                                                           
Partition name?  []? primary                                              
File system type?  [ext2]? ext4                                           
Start?                                                                   
End?
What values should I use for Start and End to make sure I make use of the maximum space available?
 
Old 11-02-2010, 07:18 AM   #2
alfredo10
Member
 
Registered: Sep 2010
Location: Algarve
Distribution: Linux Multiboot
Posts: 271

Rep: Reputation: 14
Hi!
Not a direct answer; but if you have GNOME: most distributions are containing GParted (if not, it's easy to install) - the best (graphical) partition program I know.
alfredo
 
Old 11-02-2010, 07:44 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,858

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
BTW if you want to remove the U3 specific software / partition you will need to use either:
http://sourceforge.net/projects/u3-tool/ ( I have not tried this yet)
or the windows tool
http://www.u3.com/uninstall/
 
Old 11-02-2010, 07:50 AM   #4
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 357

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by michaelk View Post
BTW if you want to remove the U3 specific software / partition you will need to use either:
http://sourceforge.net/projects/u3-tool/ ( I have not tried this yet)
or the windows tool
http://www.u3.com/uninstall/
Thanks. No, I am just trying to format it like a plain old hard disk.
 
Old 11-02-2010, 08:30 AM   #5
module0000
Member
 
Registered: Feb 2010
Location: USA
Distribution: RHEL
Posts: 36

Rep: Reputation: 15
Quote:
Disk /dev/sdb: 15695871s
Sector size (logical/physical): 512B/512B
Start should be 1, and end should be 15695871

PS: Change from a gpt table to msdos table, then you will see size written as you expect.
 
Old 11-02-2010, 08:33 AM   #6
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 357

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by module0000 View Post
Start should be 1, and end should be 15695871

PS: Change from a gpt table to msdos table, then you will see size written as you expect.
I tried a and 15695871. parted complains. What I want to know should some space be preserved for the partition table info in the beginning of the disk, like say the first 512 sectors?

I do not want to use msdos partition table.
 
Old 11-02-2010, 09:33 AM   #7
module0000
Member
 
Registered: Feb 2010
Location: USA
Distribution: RHEL
Posts: 36

Rep: Reputation: 15
I don't know about the gpt part table, it may require more/less, but the msdos part table(not just for windows...it's what you use for linux/unix on most setups) is precisely 512 bytes...or 1 sector with your setup.

Start at 2 and move forward until parted stops complaining. Let us know how it works out.
 
Old 11-02-2010, 10:56 PM   #8
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 357

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by module0000 View Post
I don't know about the gpt part table, it may require more/less, but the msdos part table(not just for windows...it's what you use for linux/unix on most setups) is precisely 512 bytes...or 1 sector with your setup.

Start at 2 and move forward until parted stops complaining. Let us know how it works out.
Finally found out the mystery behind GPT. Take a look at http://en.wikipedia.org/wiki/File:GU...ble_Scheme.svg

GPT writes both the partition information at the beginning and end of the disk, so you need to reserve space for the table both at the beginning and end of disk.

The simple formula for the usable area is (units in sectors):
Start=34s
End=Total sectors - 34s


Here's a screenprint again (I wonder why I am still getting aligning problems):
Code:
scarecrow:~ # parted /dev/sdc
GNU Parted 2.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s                                                           
(parted) print                                                            
Model: SanDisk U3 Cruzer Micro (scsi)
Disk /dev/sdc: 15695871s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart                                                           
Partition name?  []?                                                      
File system type?  [ext2]? ext4                                           
Start? 34                                                                 
End? 15695837                                                             
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore                                                     
(parted) print                                                            
Model: SanDisk U3 Cruzer Micro (scsi)
Disk /dev/sdc: 15695871s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End        Size       File system  Name  Flags
 1      34s    15695837s  15695804s

Last edited by the_gripmaster; 11-02-2010 at 11:02 PM. Reason: Added screenprint
 
1 members found this post helpful.
Old 02-22-2012, 07:30 PM   #9
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 357

Original Poster
Rep: Reputation: 38
Came back to using parted again today and this is how to properly create a partition using parted and getting rid of the alignment error:

Code:
root@loadtest01:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mktable gpt                                                      
(parted) mkpart                                                           
Partition name?  []? primary                                              
File system type?  [ext2]? linux-swap                                     
Start? 0%                                                                 
End? 100%                                                                 
(parted) print                                                            
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 17.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  17.2GB  17.2GB               primary

(parted) align-check                                                      
alignment type(min/opt)  [optimal]/minimal? optimal                       
Partition number? 1                                                       
1 aligned
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
parted ciberrust Red Hat 2 07-19-2009 03:29 AM
Help using parted gauntalus Linux - Software 5 12-26-2004 03:40 PM
I need some help now, using Parted Ofvitinn Linux - Hardware 3 09-19-2004 08:28 PM
parted alaios Linux - General 5 04-29-2004 12:13 PM
Can parted do this? szf2 Linux - Newbie 1 10-24-2003 03:03 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration