* [gentoo-user] Bash script: make a convenient /mnt/gentoo tree for a new install or development
@ 2016-12-04 17:59 Gregory Woodbury
2016-12-04 18:17 ` Rich Freeman
0 siblings, 1 reply; 4+ messages in thread
From: Gregory Woodbury @ 2016-12-04 17:59 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 5174 bytes --]
The Gentoo Handbook provides detailed instructions for preparing a
/mnt/gentoo
file system tree for new installations. After having to dig through the
Handbook a
few times of doing new or re-installs of Gentoo using an existing Gentoo
install
as the base system, I wrote this script as a shortcut way to handle the
process
of doing the mounting of /mnt/gentoo either the first time or again after a
re-boot.
1. The device containing the new file-system for the chroot MUST be already
made with mkfs.
2. Read through the script and remove, add, or change directory creations
or
bind/rbind mounts for your environment.
3. This presumes that the sudo command is available and set up for group
wheel to have access to all commands with :NOPASSWD
and that you are a member of group wheel.
4. Newer file-system types, such as ext4 or btrfs, do not really care
about the
sequence of directories made in the root. (I just have this habit from
doing
things on systems that did care.)
5. Watch out for email line wrapping in inappropriate places.
6. Enjoy a hopefully easier experience.
------<cut here>-----------------------------------------------
#!/bin/bash
#
# script to mount the devices for a new chroot of /mnt/gentoo for building
a new system
#
# 2015-05-02 ggw first version
# 2016-01-23 ggw 2nd version
# 2016-02-06 ggw some additions
#
# function usage
function usage {
echo "usage: $0 <disk-dev>"
echo " where <disk-dev> is the partition to mount as /mnt/gentoo"
exit 1
}
# check for required argument and then its type
if [ $# -lt 1 ] # no argument given?
then
usage;
elif [ ! -b $1 ] # it is not a block device?
then
usage;
fi
# presume the argument is what it claims to be FIXME
# this needs sudo setup properly, too hard to really check for now
rEUID=`id -u` # who are we?
if [ $rEUID -eq 0 ] #root?
then
prefix=""
else
prefix="/usr/bin/sudo"
fi
# make sure /mnt/gentoo exists
if [ ! -d /mnt/gentoo ]
then
echo "WARNING: /mnt/gentoo does not exist!"
eval $prefix mkdir /mnt/gentoo
fi
# mount the block device to /mnt/gentoo
eval $prefix mount $1 /mnt/gentoo
if [ $? -ne 0 ]
then
echo "FAILURE: cound not mount device, code = " $?
exit 3
fi
# now mount the proc, dev and sys pseudo-filesystems
eval $prefix mkdir -p /mnt/gentoo/proc
eval $prefix mount -t proc proc /mnt/gentoo/proc
if [ $? -ne 0 ]
then
echo "FAILURE: could not add new proc filesystem to /mnt/gentoo"
exit 4
fi
eval $prefix mkdir -p /mnt/gentoo/dev
eval $prefix mount --rbind /dev /mnt/gentoo/dev
if [ $? -ne 0 ]
then
echo "FAILURE: cound not bind /dev to /mnt/gentoo/dev"
exit 5
fi
eval $prefix mkdir -p /mnt/gentoo/sys
eval $prefix mount --rbind /sys /mnt/gentoo/sys
if [ $? -ne 0 ]
then
echo "FAILURE: could not bind /sys to /mnt/gentoo/sys"
exit 6
fi
# check other root directories and make them if necessary
pushd /mnt/gentoo 2>&1 >/dev/null
umask 0002
if [ ! -d run ]; then eval $prefix mkdir run; fi
if [ ! -d boot ]; then eval $prefix mkdir boot; fi
if [ ! -d home ]; then eval $prefix mkdir home; fi
if [ ! -d bin ]; then eval $prefix mkdir bin; fi
if [ ! -d sbin ]; then eval $prefix mkdir sbin; fi
if [ ! -d etc ]; then eval $prefix mkdir etc; eval $prefix chgrp
wheel etc; fi
if [ ! -d lib64 ]; then eval $prefix mkdir lib64; fi
if [ ! -d lib32 ]; then eval $prefix mkdir lib32; fi
if [ `uname -m` == "x86_64" ]; then eval $prefix ln -s lib64 lib; fi
if [ ! -d tmp ]; then eval $prefix mkdir tmp; eval $prefix chmod
1777 tmp; fi
if [ ! -d usr ]; then eval $prefix mkdir usr; fi
if [ ! -d usr/bin ]; then eval $prefix mkdir usr/bin; fi
if [ ! -d usr/sbin ]; then eval $prefix mkdir usr/sbin; fi
if [ ! -d root ]; then eval $prefix mkdir root; eval $prefix chgrp
wheel root; eval $prefix chmod 0771 root; fi
if [ ! -d var ]; then eval $prefix mkdir var; fi
if [ ! -d opt ]; then eval $prefix mkdir opt; fi
if [ ! -d mnt ]; then eval $prefix mkdir mnt; fi
if [ ! -d media ]; then eval $prefix mkdir media; fi
if [ ! -d srv ]; then eval $prefix mkdir srv; fi
popd 2>&1 >/dev/null
# try rbind mounting of some standard mountpoints (2016-02-06)
eval $prefix mount --rbind /boot /mnt/gentoo/boot
eval $prefix mount --rbind /home /mnt/gentoo/home
findmnt -n /srv && eval $prefix mount --rbind /srv /mnt/gentoo/srv
# 2016-02-21 ggw for convenience, mount the distfiles collection
eval $prefix mkdir -p /mnt/gentoo/usr/portage/distfiles && eval $prefix
mount --rbind /usr/portage/distfiles /mnt/gentoo/usr/portage/distfiles
# so far, so good: tell user to mount any other needed filesystems befor
chroot'ing
echo "SUCCESS: mount any other desired filesystems before chroot'ing to new
instance"
exit 0
#sh vim: set noai textwidth=0 ft=bash
------<cut here>-----------------------------------------------
--
G.Wolfe Woodbury
redwolfe@gmail.com
[-- Attachment #2: Type: text/html, Size: 7324 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Bash script: make a convenient /mnt/gentoo tree for a new install or development
2016-12-04 17:59 [gentoo-user] Bash script: make a convenient /mnt/gentoo tree for a new install or development Gregory Woodbury
@ 2016-12-04 18:17 ` Rich Freeman
2016-12-04 20:13 ` Neil Bothwick
2016-12-04 20:14 ` John Covici
0 siblings, 2 replies; 4+ messages in thread
From: Rich Freeman @ 2016-12-04 18:17 UTC (permalink / raw
To: gentoo-user
On Sun, Dec 4, 2016 at 12:59 PM, Gregory Woodbury <redwolfe@gmail.com> wrote:
> The Gentoo Handbook provides detailed instructions for preparing a
> /mnt/gentoo
> file system tree for new installations. After having to dig through the
> Handbook a
> few times of doing new or re-installs of Gentoo using an existing Gentoo
> install
> as the base system, I wrote this script as a shortcut way to handle the
> process
> of doing the mounting of /mnt/gentoo either the first time or again after a
> re-boot.
IMO it would be a lot easier if we just had an install CD that
included nspawn. :) For whatever reason there seems to be a lack of
systemd-based rescue CDs out there. While I'm placing orders I'd like
ZFS on Linux support on it as well. :)
--
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Bash script: make a convenient /mnt/gentoo tree for a new install or development
2016-12-04 18:17 ` Rich Freeman
@ 2016-12-04 20:13 ` Neil Bothwick
2016-12-04 20:14 ` John Covici
1 sibling, 0 replies; 4+ messages in thread
From: Neil Bothwick @ 2016-12-04 20:13 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
On Sun, 4 Dec 2016 13:17:10 -0500, Rich Freeman wrote:
> IMO it would be a lot easier if we just had an install CD that
> included nspawn. :) For whatever reason there seems to be a lack of
> systemd-based rescue CDs out there. While I'm placing orders I'd like
> ZFS on Linux support on it as well. :)
I'll second that. I'd even go so far as to say I'd pay twice as much for
such a CD as I do for System Rescue Cd ;-)
--
Neil Bothwick
The best things in life are free, but the
expensive ones are still worth a look.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Bash script: make a convenient /mnt/gentoo tree for a new install or development
2016-12-04 18:17 ` Rich Freeman
2016-12-04 20:13 ` Neil Bothwick
@ 2016-12-04 20:14 ` John Covici
1 sibling, 0 replies; 4+ messages in thread
From: John Covici @ 2016-12-04 20:14 UTC (permalink / raw
To: gentoo-user
On Sun, 04 Dec 2016 13:17:10 -0500,
Rich Freeman wrote:
>
> On Sun, Dec 4, 2016 at 12:59 PM, Gregory Woodbury <redwolfe@gmail.com> wrote:
> > The Gentoo Handbook provides detailed instructions for preparing a
> > /mnt/gentoo
> > file system tree for new installations. After having to dig through the
> > Handbook a
> > few times of doing new or re-installs of Gentoo using an existing Gentoo
> > install
> > as the base system, I wrote this script as a shortcut way to handle the
> > process
> > of doing the mounting of /mnt/gentoo either the first time or again after a
> > re-boot.
>
> IMO it would be a lot easier if we just had an install CD that
> included nspawn. :) For whatever reason there seems to be a lack of
> systemd-based rescue CDs out there. While I'm placing orders I'd like
> ZFS on Linux support on it as well. :)
That would be nice, I have made one, but its customized a bit, but
using catalyst it did work.
--
Your life is like a penny. You're going to lose it. The question is:
How do
you spend it?
John Covici
covici@ccs.covici.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-04 20:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-04 17:59 [gentoo-user] Bash script: make a convenient /mnt/gentoo tree for a new install or development Gregory Woodbury
2016-12-04 18:17 ` Rich Freeman
2016-12-04 20:13 ` Neil Bothwick
2016-12-04 20:14 ` John Covici
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox