LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-19-2015, 06:14 PM   #1
hunterjoz1996
Member
 
Registered: Dec 2013
Location: Virginia Beach, VA
Distribution: Arch Linux
Posts: 59

Rep: Reputation: 6
Question Partitioning a Hard drive with a python script


Hello gang,
I am in the process of writing a sort of Arch Linux installer in python, as a side project. I am curious as to whether or not there are modules to partition the disks based on input that a user provides (size, label, etc.). If so, what is the name of the module and where can i find the documentation? If there are no such modules, which program works best? I am ideally looking for a program that is noninteractive, and can take information in gigabytes. Something along the lines of program --unit GiB --size 450. --label rootfs. Any suggestions are greatly appreciated. For an understanding of my code, you may view it at http://archinstall.codeplex.com Thank you very much in advance.
 
Old 03-19-2015, 07:27 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,020

Rep: Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630Reputation: 3630
There are some live cd sort of tests for memory and then they make ram drives based on that number.

I don't see any reason you can't make a python script to construct a partition structure. Does Arch have python by default?
 
Old 03-19-2015, 08:21 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Rewriting parted, gdisk or fdisk in python might not be the best idea. I would recommend to do all you user interface (that includes reading of a config file, or reading command line parameters) in Python, just as you wish. Calculate whatever is needed to get the number of sectors etc. And then execute a shell command like sfdisk to write the proper parameters to the partition table.

jlinkels
 
1 members found this post helpful.
Old 03-22-2015, 01:04 PM   #4
ttk
Senior Member
 
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware64
Posts: 1,038
Blog Entries: 27

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
OpenLMI's "lmi.shell" python module will do what you need.

https://pypi.python.org/pypi/openlmi-tools/0.10.4

http://docs.openlmi.org/en/latest/op...ge/python.html
 
  


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
Hard Drive Partitioning for Large Hard Drives Matir Linux - General 2 12-26-2006 05:55 AM
Help with partitioning hard drive jamie_fedora5 Linux - General 5 08-14-2006 10:18 AM
Partitioning a Hard Drive wwnexc Linux - Software 1 01-19-2006 12:02 AM
Partitioning a new hard drive soujrnr Linux - Software 2 12-09-2005 04:08 PM
partitioning my hard drive stearic Linux - Newbie 1 01-07-2001 10:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:23 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