Installer NetBSD avec une table de partitionnement GUID

À l'heure qu'il est, l'installeur NetBSD est capable de détecter une table de partitionnement GUID et de la manipuler. Manque de bol, cela provoque un core dumped sur ma machine...

Mais ce n'est pas grave, car tant que l'on peut avoir un shell sous la main, on devrait pouvoir s'en sortir. Comme je préfère tout de même le confort de mon portable, et disposer d'un terminal multiplexé, nous allons dans un premier temps configurer le réseau. Après avoir choisi le type de clavier, il faut sélectionner e: Utility menu, puis c: Configure network. Maintenant que nous sommes prêts, nous pouvons nous y aller en courant : a: Run /bin/sh.

Configuration réseau

Avant toute chose, quelques commandes pour rendre le clavier fonctionnel à un français qui abuse souvent de la touche backspace.

# stty erase ^H
# wsconsctl -w encoding=fr

Tout d'abord, nous allons créer un utilisateur non privilégié mais qui pourra tout de même se connecter en root. Il appartiendra donc au groupe wheel. Ensuite, nous démarrerons le service de shell sécurisé OpenSSH.

# useradd -g users -G wheel triaxx
# passwd triaxx
Changing password for triaxx.
New Password:
Retype New Password:
# service -v sshd onestart
sshd is located in /etc/rc.d
ssh-keygen 1024: SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX root@localhost (DSA)
ssh-keygen 521: SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX root@localhost (ECDSA)
ssh-keygen 256: SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX root@localhost (ED25519)
ssh-keygen 3072: SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX root@localhost (RSA)
Starting sshd.

Nous allons maintenant pouvoir installer le système depuis un environnement connu :

$ ssh triaxx@hydralisk
Password for triaxx@localhost:
$ export TERM=rxvt
$ tmux
$ su -
Password:

Partitionnement

Dans un premier temps, nous supprimer l'ancienne table de partition pour ensuite en créer une nouvelle :

# gpt destroy wd0
# gpt create wd0

L'avantage de GPT est qu'il permet d'ajouter un grand nombre (128) de partitions contraitement à une table de partition MBR qui ne permet de créer que 4 partitions primaires (et les partitions étendues, ça fait bidouille...). Ici, nous allons nous lâcher dans l'idée d'installer par la suite plusieurs systèmes auxquels nous accèderont via GNU GRUB. Il nous faut tout d'abord une petite partition d'un mégaoctet de type bios pour GNU GRUB.

# gpt add -a 4k -l grub -s 1m -t bios wd0
# gpt add -a 4k -l nbroot -s 24g -t ffs wd0
# gpt add -a 4k -l nboldroot -s 24g -t ffs wd0
# gpt add -a 4k -l nbdevroot -s 24g -t ffs wd0
# gpt add -a 4k -l nbhome -s 24g -t ffs wd0
# gpt add -a 4k -l nbswap -s 8g -t swap wd0
# gpt add -a 4k -l fbroot -s 24g -t fbsd-ufs wd0
# gpt add -a 4k -l fbswap -s 8g -t fbsd-swap wd0
# gpt add -a 4k -l obroot -s 24g -t 824CC7A0-36A8-11E3-890A-952519AD3F61 wd0
# gpt add -a 4k -l obswap -s 8g -t 824CC7A0-36A8-11E3-890A-952519AD3F61 wd0

Nous allons maintenant formater la partition racine, ainsi que celle devant accueillir les répertoires utilisateur, avec des systèmes de fichiers FFS2 et nous allons la monter pour pouvoir y installer les fichiers du système qui sont disponibles sous forme d'archives compressées.

# newfs -O2 NAME=nbsdroot
/dev/rdk1: 24576.0MB (50331648 sectors) block size 16384, fragment size 2048
        using 133 cylinder groups of 184.80MB, 11827 blks, 22976 inodes.
super-block backups (for fsck_ffs -b #) at:
160, 378624, 757088, 1135552, 1514016, 1892480, 2270944, 2649408, 3027872, 3406336, 3784800, 4163264, 4541728, 4920192, 5298656, 5677120, 6055584, 6434048, 6812512, 7190976, 7569440, 7947904, 8326368, 8704832, 9083296, 9461760, 9840224, 10218688, 10597152, 10975616,
................................................................................................................................................................................................................................................................................
# newfs NAME=nbsdhome
/dev/rdk4: 24576.0MB (50331648 sectors) block size 16384, fragment size 2048
        using 134 cylinder groups of 183.41MB, 11738 blks, 23168 inodes.
super-block backups (for fsck_ffs -b #) at:
32, 375648, 751264, 1126880, 1502496, 1878112, 2253728, 2629344, 3004960, 3380576, 3756192, 4131808, 4507424, 4883040, 5258656, 5634272, 6009888, 6385504, 6761120, 7136736, 7512352, 7887968, 8263584, 8639200, 9014816, 9390432, 9766048, 10141664, 10517280, 10892896,
................................................................................................................................................................................................................................................................................
# mount -v NAME=nbsdroot /mnt
exec: mount_ffs /dev/dk1 /mnt
/dev/dk1 on /mnt type ffs (local, fsid: 0xa800/0x78b, reads: sync 1 async 0, writes: sync 2 async 0)
# mkdir /mnt/home
# mount -v NAME=nbsdhome /mnt/home
exec: mount_ffs /dev/dk4 /mnt/home
/dev/dk4 on /mnt/home type ffs (local, fsid: 0xa804/0x78b, reads: sync 1 async 0, writes: sync 2 async 0)

Installation du système

Nous extrayons les différents set du système dans le répertoire monté correspondant à la partition racine de notre disque.

# for set in base comp etc games kern-GENERIC man misc modules rescue tests text ; do tar xJf /amd64/binary/sets/${set}.tar.xz -C /mnt ; done

Nous pouvons maintenant changer la racine de notre système de fichier pour configurer le système nouvellement installer sur le disque monté sur le répertoire /mnt. Au préalable, nous aurons besoin du fichier contenant la liste des serveurs DNS nécessaires à la résolution des requêtes de nom de domaine. Il est également nécessaire de créer les fichiers de périphériques à l'aide du script MAKEDEV fourni dans le répertoire /dev. Ensuite, nous pouvons installer le gestionnaire de paquet pkgin disponible sur notre dépôt personnel.

# cp /etc/resolv.conf /mnt/etc
# chroot /mnt
# cd /dev && sh MAKEDEV all
# PKG_PATH="http://pkg.triaxx.org/pub/pkgsrc/packages/NetBSD/amd64/9.0/hydralisk/All" pkg_add pkgin
===========================================================================
$NetBSD: MESSAGE,v 1.7 2017/01/09 07:01:33 sevan Exp $

You may wish to have the vulnerabilities file downloaded daily so that it
remains current. This may be done by adding an appropriate entry to the root
users crontab(5) entry. For example the entry

# Download vulnerabilities file
0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
# Audit the installed packages and email results to root
9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
            root >/dev/null 2>&1
      
will update the vulnerability list every day at 3AM, followed by an audit at
3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
accomplished instead by adding the following line to /etc/daily.conf:

fetch_pkg_vulnerabilities=YES
      
to fetch the vulnerability list from the daily security script. The system is
set to audit the packages by default but can be set explicitly, if desired (not
required), by adding the follwing line to /etc/security.conf:

check_pkg_vulnerabilities=YES
      
Both pkg_admin subcommands can be run as as an unprivileged user,
as long as the user chosen has permission to read the pkgdb and to write
the pkg-vulnerabilities to /var/db/pkg.

The behavior of pkg_admin and pkg_add can be customised with
pkg_install.conf.  Please see pkg_install.conf(5) for details.

If you want to use GPG signature verification you will need to install
GnuPG and set the path for GPG appropriately in your pkg_install.conf.
===========================================================================
pkgin-20.5.1: copying /usr/pkg/share/examples/pkgin/repositories.conf.example to /usr/pkg/etc/pkgin/repositories.conf
# sed -i -e 's,https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/$arch/9.0/All,http://pkg.triaxx.org/pub/pkgsrc/packages/NetBSD/$arch/9.0/hydralisk/All,' /usr/pkg/etc/pkgin/repositories.conf
# pkgin update
reading local summary...
processing local summary...
processing remote summary (http://pkg.triaxx.org/pub/pkgsrc/packages/NetBSD/amd64/9.0/hydralisk/All)...
pkg_summary.bz2

Nous installons maintenant le chargeur de démarrage GNU GRUB.

# pkgin install grub2
calculating dependencies...done.                             
                                               
5 packages to install:                                             
  libuuid-2.32.1 libffi-3.3nb2 python38-3.8.3nb1 freetype2-2.10.1 grub2-2.04nb1
                                               
0 to refresh, 0 to upgrade, 5 to install                           
37M to download, 118M to install                               
                       
proceed ? [Y/n]         
libuuid-2.32.1.tgz
libffi-3.3nb2.tgz 
python38-3.8.3nb1.tgz
freetype2-2.10.1.tgz
grub2-2.04nb1.tgz
installing libuuid-2.32.1...
installing libffi-3.3nb2...
installing python38-3.8.3nb1...
installing freetype2-2.10.1...
installing grub2-2.04nb1...
grub2-2.04nb1: copying /usr/pkg/share/examples/grub/00_header to /usr/pkg/etc/grub/00_header
grub2-2.04nb1: copying /usr/pkg/share/examples/grub/05_pkgsrc_theme to /usr/pkg/etc/grub/05_pkgsrc_theme
grub2-2.04nb1: copying /usr/pkg/share/examples/grub/10_netbsd to /usr/pkg/etc/grub/10_netbsd
grub2-2.04nb1: copying /usr/pkg/share/examples/grub/30_os-prober to /usr/pkg/etc/grub/30_os-prober
grub2-2.04nb1: copying /usr/pkg/share/examples/grub/40_custom to /usr/pkg/etc/grub/40_custom
grub2-2.04nb1: copying /usr/pkg/share/examples/grub/41_custom to /usr/pkg/etc/grub/41_custom
grub2-2.04nb1: copying /usr/pkg/share/examples/grub/README to /usr/pkg/etc/grub/README
grub2-2.04nb1: copying /usr/pkg/share/examples/grub/default.conf.sample to /usr/pkg/etc/grub/default.conf
===========================================================================
$NetBSD: MESSAGE,v 1.1 2012/07/29 21:44:13 gsutre Exp $

To actually install GRUB 2 to disk, use grub-install(8).  But do
not use it unless you understand what it actually does, for it may
lead to loss of data when used improperly.

Please visit the official web page of GRUB 2, for more information.
The URL is <http://www.gnu.org/software/grub/>.

More extensive documentation is available in the Info manual,
accessible using 'info grub'.

There are a number of important user-visible differences from the
first version of GRUB, now known as GRUB Legacy.  For a summary,
please see:

  info grub Introduction 'Changes from GRUB Legacy'
===========================================================================
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
marking grub2-2.04nb1 as non auto-removable
# mkdir /boot /grub
# sed -i -e 's,OS="\(.*\)NetBSD",OS="\1$(uname -rs)",' /usr/pkg/etc/grub/10_netbsd
# grub-mkconfig -o /grub/grub.cfg                                                                                                                                                                                                                                      
Generating grub configuration file ...
Found NetBSD kernel: /netbsd
done
# grub-install --no-floppy /dev/rwd0d
Installing for i386-pc platform.
Installation finished. No error reported.

Configuration minimale

Avant de démarrer le système, nous pouvons procéder à quelques finitions, et notamment éditer quelques fichiers de configuration. Afin de dissocier les fichiers de configuration fournis par le système de ceux que j'édite, j'ajoute une en-tête ASCII Art générée par figlet.

# pkgin install figlet
calculating dependencies...done.

1 package to install:
  figlet-2.2.5nb1

0 to refresh, 0 to upgrade, 1 to install
127K to download, 648K to install

proceed ? [Y/n] 
figlet-2.2.5nb1.tgz
installing figlet-2.2.5nb1...
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
marking figlet-2.2.5nb1 as non auto-removable

# figlet rc.conf | sed 's,^,# ,' > /etc/rc.conf && cat >> /etc/rc.conf << EOF

if [ -r /etc/defaults/rc.conf ]; then
  . /etc/defaults/rc.conf
fi

rc_configured=YES
rc_directories="/usr/pkg/etc/rc.d /etc/rc.d"

hostname="hydralisk.triaxx.org"

cgd=NO
ifconfig_re0="dhcp"
ip6mode="autohost"
ntpdate=YES
sshd=YES
syslogd=YES            syslogd_flags="-s -osyslog"
wscons=YES
EOF

Nous pouvons ajouter un utilisateur non privilégié. Celui-ci devra pouvoir se connecter en tant que root et utilisera le shell bash. Mais d'abord, il faut définir un mot de passe pour l'utilisateur root.

# passwd root
Changing password for root.
New Password:
Retype New Password:
# pkgin install bash
calculating dependencies...done.

1 package to install:
  bash-5.0.17

0 to refresh, 0 to upgrade, 1 to install
2780K to download, 8836K to install

proceed ? [Y/n] 
bash-5.0.17.tgz
installing bash-5.0.17...
bash-5.0.17: adding /usr/pkg/bin/bash to /etc/shells
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
marking bash-5.0.17 as non auto-removable
# useradd -m -g users -G wheel,operator,games -s /usr/pkg/bin/bash triaxx
# passwd triaxx
Changing password for triaxx.
New Password:
Retype New Password:

Nous devons également renseigner le fichier fstab qui liste les systèmes de fichier à monter. Dans notre cas, nous utilisons des disques concaténés qui nécessites une configuration.

# figlet ccd.conf | sed 's,^,# ,' > /etc/ccd.conf && cat >> /etc/ccd.conf << EOF

ccd0  63   none    NAME=ccdwd0     NAME=ccdwd1
ccd1  63   none    NAME=ccdhtc0    NAME=ccdhtc1
EOF
# mkdir /mnt/ccd0 /mnt/ccd1
# figlet fstab | sed 's,^,# ,' > /etc/fstab && cat >> /etc/fstab << EOF

NAME=nbsdroot  /           ffs     rw      1 1 
NAME=nbsdhome  /home       ffs     rw      1 2
/dev/ccd0a     /mnt/ccd0   ffs     rw      1 2 
/dev/ccd1a     /mnt/ccd1   ffs     rw      1 2 
NAME=nbsdswap  none        swap    sw,dp   0 0 
kernfs         /kern       kernfs  rw  
ptyfs          /dev/pts    ptyfs   rw  
procfs         /proc       procfs  rw  
tmpfs          /var/shm    tmpfs   rw,-m1777,-sram%25
EOF

Nous pouvons maintenant tester notre système nouvellement installé.

# exit
# umount /mnt/home
# umount /mnt
# shutdown -r now

Add a comment

HTML code is displayed as text and web addresses are automatically converted.

Add ping

Trackback URL : https://blog.triaxx.org/trackback/9

Page top