public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Michael Mol <mikemol@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Re: Gentoo install script
Date: Wed, 4 Jul 2012 16:06:56 -0400	[thread overview]
Message-ID: <CA+czFiBCqMpdWa8RLNhG7vBebxXp1PXu25XoAbBnMwkC=kVWyQ@mail.gmail.com> (raw)
In-Reply-To: <CAC3eR0gvwOHW6wxgsB2BHpYL8pxLyNEjVqvjZ6j3d-ZhMfAiDA@mail.gmail.com>

On Wed, Jul 4, 2012 at 1:20 AM, Kaddeh <kaddeh@gmail.com> wrote:
> Very well done, reminded me of some code that I wrote (poorly, I might add)
> but, I dug it up and found some changes that you might be able to implement
> instead of lines and lines of static configs.  That being said, take some of
> these changes into consideration.
>
> Dynamic detection of drives and partitions:
>
> # Get Existing Drives
> existing_drives=$(fdisk -l | grep /dev | grep -i disk | cut -c11-13)
>
> # Set default drive
> default_drive=$(fdisk -l | grep --max-count=1 /dev | cut -c11-13)
>
> echo -e "What drive do you want to partition? [$existing_drives]: \c"
> read drive
>
> and then creating the partition table later:
>
> # Make Drive Selection
> if [ "$drive" == "" ]
> then
> 	selected_drive=$default_drive
> else
> 	# Verify Drive Exists
> 	does_exist=$(fdisk -l | grep --max-count=1 -ci $drive)
>
> 	if [ "$does_exist" == "1" ]
> 	then
> 		selected_drive=$drive
> 	else
> 		echo -e "The selected drive" $drive "does not exist.  Using"
> $default_drive "instead."
> 		selected_drive=$default_drive
> 	fi
> fi
>
> num_partitions=$(fdisk -l | grep ^/dev | grep -ic $selected_drive)
>
> echo "There are" $num_partitions "partitions on" $selected_drive
>
> partitions=1
>
> # Clear existing partition file
> rm -rf partition_table
> touch partition_table
>
> while [ "$partitions" -le "$num_partitions" ]
> do
> 	# Find partition numbers
> 	edit_partitions=$(fdisk -l | grep ^/dev/$selected_drive | cut -c9)
> 	
> 	# Parse out extra partitons
> 	if [ "$partitions" == "1" ]
> 	then
> 		work_partition=$(echo -e $edit_partitions | cut -c$partitions)
> 		# Write to partition_table file
> 		echo -e "d\n$work_partition" >> partition_table
> 	else
> 		if [ "$partitions_cut" == "" ]
> 		then
> 			# If First Partition after partition 1, cut off $partitions + 1
> 			partitions_cut=$(($partitions+1))
> 		else
> 			partitions_cut=$(($partitions_cut+1))
> 		fi
> 		work_partition=$(echo -e $edit_partitions | cut -c$partitions_cut)
> 		# Write to partition_table file
> 		echo -e "d\n$work_partition" >> partition_table
> 		((partitions_cut += 1))
> 	fi
> 	((partitions += 1))
> 	
> done
>
> # build the rest of the table
> # Get Total System Memory
> total_mem=$(cat /proc/meminfo | grep -i memtotal | cut -c16- | sed s/\ // |
> sed s/kB//)
> swap_space=$(expr $(expr $total_mem + $total_mem) / 1024)
>
> # Write first partition to file
> echo -e "n\np\n1\n\n+100M\n" >> partition_table
>
> # Write Swap Space (double system memory)
> echo -e "n\np\n2\n\n+"$swap_space"M\n">> partition_table
>
> # Write / partition to file
> echo -e "n\np\n3\n\n\n" >> partition_table
>
> # Write partition setting to file and drive write
> echo -e "a\n1\nt\n2\n82\nw\n" >> partition_table
>
> # Set drive number variables
> boot_drive=$(echo $selected_drive"1")
> swap_drive=$(echo $selected_drive"2")
> root_drive=$(echo $selected_drive"3")
>
> # KEEP THIS COMMENTED OUT BELLOW HERE
> fdisk /dev/$selected_drive < partition_table
>
> Mainly due to the fact that you statically set the UUIDs of the drive that
> you want to use.
>
> Cheers,
> Kad

Thank you very much.

I'd gladly entertain a pull request if you'd like to integrate it. I'm
not doing much in the way of active development on the script until I
have either (or both) of my machines operational again; they're almost
there, but I'm a sticking point with the 3.3.8 kernel, got past that,
and have now discovered that stable genkernel and stable
gentoo-sources don't play well together. (Because stable genkernel is
using a slightly older version of busybox which doesn't know about
some moved kernel header files). That stuff is slowly moving on b.g.o,
and I'm slowly working around at home. It's only a matter of time, of
which nobody seems to have enough...

-- 
:wq



  reply	other threads:[~2012-07-04 20:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-28  2:13 [gentoo-user] Gentoo install script Michael Mol
2012-07-02  0:28 ` [gentoo-user] " Michael Mol
2012-07-04  5:20   ` Kaddeh
2012-07-04 20:06     ` Michael Mol [this message]
2012-07-04 16:53   ` Mark Knecht
2012-07-04 20:15     ` Michael Mol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+czFiBCqMpdWa8RLNhG7vBebxXp1PXu25XoAbBnMwkC=kVWyQ@mail.gmail.com' \
    --to=mikemol@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox