Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gentoo Install Script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
dinominant
Tux's lil' helper
Tux's lil' helper


Joined: 27 Oct 2006
Posts: 102

PostPosted: Tue Sep 12, 2017 5:17 am    Post subject: Gentoo Install Script Reply with quote

I have written a script which I use to automate most of the steps in the Gentoo handbook: https://github.com/nathanshearer/gentooinstall

Some of the features I find most useful are:
  • Cryptographic verification of the stage3 hash and signature
  • Foreign architecture support via qemu dynamic translation (i486, i686, x86_64, armv4, armv5, armv6, armv6hf, armv7, armv7hf, aarch64, ppc, ppc64)
  • Automatic partitioning and mounting of the destination block device
  • Automatic compilation of the kernel
  • Automatic installation of the bootloader
  • An armbian2gentoo wrapper script that converts an armbian image into a clean gentoo image

Using the script is very simple:
Code:
# gentooinstall -d /mnt/gentoo -t "Canada/Mountain"

Code:
# gentooinstall -d /mnt/gentoo -a armv7hf -t "Canada/Mountain"

Code:
# gentooinstall -b /dev/sdzz -p partition,mount
# gentooinstall -t "Canada/Mountain"
# chroot /mnt/gentoo /bin/bash
# ...customize your kernel as you like
# exit
# gentooinstall -p bootloader,fstab


Last edited by dinominant on Tue Jan 21, 2020 4:52 pm; edited 2 times in total
Back to top
View user's profile Send private message
koprimer
n00b
n00b


Joined: 29 Feb 2004
Posts: 64

PostPosted: Tue Sep 12, 2017 5:34 am    Post subject: Reply with quote

nice script, thanks for sharing
Back to top
View user's profile Send private message
sheep204
n00b
n00b


Joined: 28 Dec 2005
Posts: 31

PostPosted: Tue Sep 19, 2017 1:06 pm    Post subject: Re: Gentoo Install Script Reply with quote

dinominant wrote:
I've written a script which I use to automate most of the steps in the Gentoo handbook: https://github.com/nathanshearer/gentooinstall

Some of the key features I find most useful are:
  • Both stage3 hash and cryptographic verification (I always skipped those step during manual installs)
  • Foreign architecture support via qemu dynamic translation
  • An armbian2gentoo wrapper script that converts an armbian image into a clean gentoo image


Using the script is very simple:
Code:
# gentooinstall -d /mnt/gentoo -t "Canada/Mountain"

Code:
# gentooinstall -d /mnt/gentoo -a armv7hf -t "Canada/Mountain"


thanks for share and does this script compile kernel automaticly?
Back to top
View user's profile Send private message
shrike
Apprentice
Apprentice


Joined: 20 Feb 2004
Posts: 187
Location: Closer to home

PostPosted: Wed Sep 20, 2017 1:38 pm    Post subject: Reply with quote

dinominant,

Cool idea, armbian2gentoo. Thanks!

I have tried it with and without the -a option but there are errors as shown below. As my scripting skills are poor I have no idea where the problem is.


Code:
nehalem ~/pine64/gentooinstall-master # /root/pine64/gentooinstall-master/armbian2gentoo -a armv8 -i https://dl.armbian.com/pine64/Ubuntu_xenial_dev_nightly.7z
Downloading the armbian image...
/tmp/armbian2gentoo.4274/armbian.7z                             100%[======================================================>] 228.55M  2.81MB/s    in 88s     
Extracting the armbian image... done.
Finding the root file system... done.
Increasing the size of the root file system (to accommodate the gentoo install)...
e2fsck 1.43.3 (04-Sep-2016)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/loop0: 54873/103584 files (0.1% non-contiguous), 294691/414208 blocks
resize2fs 1.43.3 (04-Sep-2016)
Resizing the filesystem on /dev/loop0 to 2096640 (4k) blocks.
The filesystem on /dev/loop0 is now 2096640 (4k) blocks long.

Mounting the root filesystem at /tmp/armbian2gentoo.4274/root...
Moving armbian out of the way...
mv: cannot move '/tmp/armbian2gentoo.4274/root/oldroot' to a subdirectory of itself, '/tmp/armbian2gentoo.4274/root/oldroot/oldroot'
Installing Gentoo...

We are the Gentoo Community.
Power your systems and surrender your chips.
Your ideological and technological distinctiveness will be added to our own.
You will adapt to serve us.
Resistance is futile.

Downloading the stage 3 tarball...
Moving boot, fstab and the armbian kernel modules back into place...
mv: cannot move '/tmp/armbian2gentoo.4274/root/oldroot/etc/fstab' to '/tmp/armbian2gentoo.4274/root/etc/fstab': No such file or directory
Removing armbian...
Shrinking the root filesystem...
umount: /tmp/armbian2gentoo.4274/root/dev: mountpoint not found
umount: /tmp/armbian2gentoo.4274/root/proc: mountpoint not found
umount: /tmp/armbian2gentoo.4274/root/sys: mountpoint not found
e2fsck 1.43.3 (04-Sep-2016)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create? yes

Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/loop0: ***** FILE SYSTEM WAS MODIFIED *****
/dev/loop0: 921/509952 files (0.1% non-contiguous), 52567/2096640 blocks
resize2fs 1.43.3 (04-Sep-2016)
Resizing the filesystem on /dev/loop0 to 29179 (4k) blocks.
Begin pass 2 (max = 19488)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 64)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 151)
Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/loop0 is now 29179 (4k) blocks long.

Shrinking the partition...


Thanks,

shrike
Back to top
View user's profile Send private message
dinominant
Tux's lil' helper
Tux's lil' helper


Joined: 27 Oct 2006
Posts: 102

PostPosted: Thu Sep 21, 2017 12:04 am    Post subject: Re: Gentoo Install Script Reply with quote

sheep204 wrote:
thanks for share and does this script compile kernel automaticly?

It does have a kernel phase which installs and compiles gentoo-sources with its default kernel options. I don't have a bootloader phase with efistub/lilo/grub yet so that still has to be done manually.

shrike wrote:
I have tried it with and without the -a option but there are errors as shown below. As my scripting skills are poor I have no idea where the problem is.

I've added some better output for the gentooinstall script related to aarch64 and arm64. Currently it's an unsupported architecture, but armv7hf should work on those platforms until arm64 is working. I was able to run this command on my x86_64 host (which has qemu dynamic translation setup and working already):
Code:
armbian2gentoo -i https://dl.armbian.com/orangepipc/Ubuntu_xenial_default.7z -o test.img -p stage3,stage3digest,stage3hash,extract,dynamictranslation,deletestage3,resolvconf,mountchroot,portage,timezone,locale,password

Code:
gentooinstall # ./armbian2gentoo -i https://dl.armbian.com/orangepipc/Ubuntu_xenial_default.7z -o test.img -p stage3,stage3digest,stage3hash,extract,dynamictranslation,deletestage3,resolvconf,mountchroot,portage,timezone,locale,password
Downloading the armbian image...
/tmp/armbian2gentoo.18682/armbian.7z         100%[=============================================================================================>] 218.38M  9.63MB/s    in 23s     
Extracting the armbian image... done.
Finding the root file system... done.
Increasing the size of the root file system (to accommodate the gentoo install)...
e2fsck 1.43.3 (04-Sep-2016)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/loop1: 48717/90432 files (0.1% non-contiguous), 255232/361472 blocks
resize2fs 1.43.3 (04-Sep-2016)
Resizing the filesystem on /dev/loop1 to 2096128 (4k) blocks.
The filesystem on /dev/loop1 is now 2096128 (4k) blocks long.

Mounting the root filesystem at /tmp/armbian2gentoo.18682/root...
Moving armbian out of the way... done.
Installing Gentoo...

We are the Gentoo Community.
Power your systems and surrender your chips.
Your ideological and technological distinctiveness will be added to our own.
You will adapt to serve us.
Resistance is futile.

Downloading the stage 3 tarball...
/tmp/armbian2gentoo.18682/root/stage3-armv7a 100%[=============================================================================================>] 292.06M  14.6MB/s    in 23s     
/tmp/armbian2gentoo.18682/root/stage3-armv7a 100%[=============================================================================================>]   1.56K  --.-KB/s    in 0s     
Verifying the cryptographic signature of the stage3 hashes... Success.
Verifying the hash of the stage3 tarball... Success.
Extracting "/tmp/armbian2gentoo.18682/root/stage3-armv7a_hardfp-20161129.tar.bz2" to "/tmp/armbian2gentoo.18682/root"... Done.
Verifying kernel support for 'misc binaries'... Success.
Verifying that "/usr/bin/qemu-arm" is a static binary... Success.
Testing dynamic binary translation... Success.
Copying "/usr/bin/qemu-arm" into the installation to enable dynamic binary translation... Done.
Patching /etc/resolv.conf
!!! Section 'x-portage' in repos.conf has location attribute set to nonexistent directory: '/usr/portage'
!!! Section 'gentoo' in repos.conf has location attribute set to nonexistent directory: '/usr/portage'
!!! Invalid Repository Location (not a dir): '/usr/portage'
>>> Regenerating /etc/ld.so.cache...
!!! Invalid news item: /usr/portage/metadata/news/2017-08-19-hardened-sources-removal/2017-08-19-hardened-sources-removal.en.txt
!!!   line 5: News-Item-Format: 2.0
!!! Invalid news item: /usr/portage/metadata/news/2017-04-10-split-and-slotted-wine/2017-04-10-split-and-slotted-wine.en.txt
!!!   line 6: News-Item-Format: 2.0
!!! Invalid news item: /usr/portage/metadata/news/2017-07-16-systemd-rootprefix/2017-07-16-systemd-rootprefix.en.txt
!!!   line 5: News-Item-Format: 2.0

 * IMPORTANT: 11 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

>>> Regenerating /etc/ld.so.cache...


Configuring pkg...

 * Updating /etc/localtime with /usr/share/zoneinfo/UTC

>>> Regenerating /etc/ld.so.cache...
 * Generating locale-archive: forcing # of jobs to 1
 * Generating 2 locales (this might take a while) with 1 jobs
 *  (1/2) Generating en_US.ISO-8859-1 ...                                                                                                                                    [ ok ]
 *  (2/2) Generating en_US.UTF-8 ...                                                                                                                                         [ ok ]
 * Generation complete
Setting LANG to en_US.utf8 ...
Run ". /etc/profile" to update the variable in your shell.
>>> Regenerating /etc/ld.so.cache...
BAD PASSWORD: it is based on a dictionary word
Moving boot, fstab and the armbian kernel modules back into place...
Removing armbian...
Shrinking the root filesystem...
e2fsck 1.43.3 (04-Sep-2016)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create? yes

Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/loop1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/loop1: 233313/482304 files (0.0% non-contiguous), 499963/2096128 blocks
resize2fs 1.43.3 (04-Sep-2016)
Resizing the filesystem on /dev/loop1 to 986260 (4k) blocks.
Begin pass 2 (max = 150027)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 64)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 31981)
Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/loop1 is now 986260 (4k) blocks long.

Shrinking the partition...
Back to top
View user's profile Send private message
tom_brown
n00b
n00b


Joined: 28 Aug 2018
Posts: 3

PostPosted: Sun Sep 02, 2018 10:35 am    Post subject: Reply with quote

Thanks for the script!!! But do I need a certain Kernel or do you recommend one? Are there any specs I need?
Back to top
View user's profile Send private message
dinominant
Tux's lil' helper
Tux's lil' helper


Joined: 27 Oct 2006
Posts: 102

PostPosted: Fri Sep 14, 2018 3:38 pm    Post subject: Reply with quote

tom_brown wrote:
Thanks for the script!!! But do I need a certain Kernel or do you recommend one? Are there any specs I need?


Any kernel should work. I typically either use a vanilla-sources kernel then build in whatever drivers I need to boot leaving the rest enabled as modules. I have plans on adding support for my kernelseeds script https://github.com/nathanshearer/kernelseeds but until that is completed I just skip the kernel phase and do that step manually.
Back to top
View user's profile Send private message
zux0x3a
n00b
n00b


Joined: 18 Aug 2018
Posts: 37

PostPosted: Mon Sep 24, 2018 12:53 pm    Post subject: Reply with quote

nice
Back to top
View user's profile Send private message
dinominant
Tux's lil' helper
Tux's lil' helper


Joined: 27 Oct 2006
Posts: 102

PostPosted: Fri Dec 28, 2018 8:24 am    Post subject: Reply with quote

I have been using this scrypt for over a year now, and I think it is time to set the version to 1.0.0.0.

I still have many items on my todo list for this script which I plan to add in the future:
  • Additional bootloader configurations (for uefi systems with kernel stub andor refind)
  • A more capable kernel configuration in addition to the default config
  • An assimilation option which will merge the armbian2gentoo functionality into the main script, allowing conversion of arbitrary images into Gentoo images
Back to top
View user's profile Send private message
sheep204
n00b
n00b


Joined: 28 Dec 2005
Posts: 31

PostPosted: Wed Aug 14, 2019 3:01 am    Post subject: Reply with quote

dinominant wrote:
I have been using this scrypt for over a year now, and I think it is time to set the version to 1.0.0.0.

I still have many items on my todo list for this script which I plan to add in the future:
  • Additional bootloader configurations (for uefi systems with kernel stub andor refind)
  • A more capable kernel configuration in addition to the default config
  • An assimilation option which will merge the armbian2gentoo functionality into the main script, allowing conversion of arbitrary images into Gentoo images


hi,I used this script for several times.I think the partition should be mounted before the script is executed, otherwise there will be an error with insufficient partition capacity.
Back to top
View user's profile Send private message
dinominant
Tux's lil' helper
Tux's lil' helper


Joined: 27 Oct 2006
Posts: 102

PostPosted: Tue Jan 21, 2020 4:45 pm    Post subject: Reply with quote

sheep204 wrote:
hi,I used this script for several times.I think the partition should be mounted before the script is executed, otherwise there will be an error with insufficient partition capacity.


Thanks for the feedback. I have now updated it to version 2 which now automatically mounts and partitions if the destination is empty, among other improvements.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum