Outils pour utilisateurs

Outils du site


blog

Debian reboot needed

/etc/needrestart/restart.d/

apt-get install reboot-notifier
dpkg -S /usr/sbin/needrestart 
needrestart: /usr/sbin/needrestart

/var/run/reboot-required

2025/03/24 15:06

Ansible - Ajouter un module

# python3 -m site --user-site
ansible --version
mkdir -p ~/.ansible/plugins/modules/net_tools/l
cp -a /usr/lib/python3.6/site-packages/ansible/modules/net_tools/ldap ~/.ansible/plugins/modules/net_tools/
 
# Créer le fichier à partir de https://github.com/ansible-collections/community.general/blob/main/plugins/modules/net_tools/ldap/ldap_search.py
vim ~/.ansible/plugins/modules/net_tools/ldap/ldap_search.py

Commenter les lignes suivantes :

extends_documentation_fragment:
    - community.general.ldap.documentation
ansible-doc ldap_search -M ~/.ansible/plugins/modules/net_tools/ldap
ansible-doc ldap_search
2025/03/24 15:06

Debian Preseed partman mode UEFI sans GPT mais avec MBR

Erreur

Debian No EFI partition was found

Exemple de conf OK en mode UEFI (testé avec Debian 10)

### Contents of the preconfiguration file
d-i debian-installer/language string en
d-i debian-installer/country string FR
d-i debian-installer/locale string en_US.UTF-8
d-i localechooser/supported-locales multiselect en_US.UTF-8, fr_FR.UTF-8

### Keyboard
d-i keyboard-configuration/xkb-keymap select fr
d-i keyboard-configuration/xkb-keymap select fr(latin9)
d-i console-keymaps-at/keymap select fr

# keymap is an alias for keyboard-configuration/xkb-keymap
#d-i keymap select fr(latin9)

### Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string debianxx
d-i netcfg/get_domain string localdomain
d-i netcfg/wireless_wep string
d-i debian-installer/add-kernel-opts string biosdevname=0 net.ifnames=0

### Other
d-i hw-detect/load_firmware boolean false

#### Apt mirror
d-i mirror/country string manual
d-i apt-setup/no_mirror boolean true

### Account setup
d-i passwd/root-login boolean false
d-i passwd/make-user boolean true
#d-i passwd/root-password password toor
#d-i passwd/root-password-again password toor
d-i passwd/user-fullname string Process
d-i passwd/username string jean
d-i passwd/user-password password P@ssw0rd
d-i passwd/user-password-again password P@ssw0rd

### Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string Europe/Paris
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string 192.168.20.34, 192.168.21.34

#### Partitioning
d-i partman-efi/non_efi_system boolean true                    
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto-lvm/new_vg_name string vgos
d-i partman-auto/disk string /dev/sda
d-i partman-auto/expert_recipe string                         \
      boot-root ::                                            \
              513 1024 1024 ext4                              \
                      $primary{ }                             \
                      $bootable{ }                            \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /boot }                     \
                      options/noatime{ noatime }              \
              .                                               \
              512 512 512 vfat                                \
                      $primary{ }                             \
                      method{ efi } format{ }                 \
                      mountpoint{ /boot/efi }                 \
                      options/noatime{ noatime }              \
              .                                               \
              2048 6144 6144 ext4                             \
                      $lvmok{ }                               \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ / }                         \
                      options/noatime{ noatime }              \
                      lv_name{ root }                         \
              .                                               \
              2048 4096 4096 ext4                             \
                      $lvmok{ }                               \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /var }                      \
                      options/noatime{ noatime }              \
                      lv_name{ var }                          \
              .                                               \
              1024 1024 1024 ext4                             \
                      $lvmok{ }                               \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /opt }                      \
                      options/noatime{ noatime }              \
                      lv_name{ opt }                          \
              .                                               \
              1024 1024 2048 ext4                             \
                      $lvmok{ }                               \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /var/log }                  \
                      options/noatime{ noatime }              \
                      lv_name{ log }                          \
              .                                               \
              2048 2048 2048 ext4                             \
                      $lvmok{ }                               \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /home }                     \
                      options/noatime{ noatime }              \
                      lv_name{ home }                         \
              .                                               \
              1024 1024 1024 linux-swap                       \
                      $lvmok{ }                               \
                      method{ swap } format{ }                \
                      lv_name{ swap }                         \
              .                                               \
              1024 -1 -1 ext4                                 \
                      $lvmok{ }                               \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /tmp/willbeautoremoved }    \
                      lv_name{ willbeautoremoved }            \
              .                                               \


d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-md/confirm boolean true
d-i partman/mount_style select uuid

### Base system installation
d-i base-installer/install-recommends boolean false

### Apt setup
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
apt-cdrom-setup apt-setup/cdrom/set-next  boolean false
d-i apt-setup/contrib boolean false
d-i apt-setup/use_mirror boolean false
d-i apt-setup/services-select multiselect

### Package selection
tasksel tasksel/first multiselect standard
d-i pkgsel/upgrade select safe-upgrade
popularity-contest popularity-contest/participate boolean false
d-i pkgsel/include string openssh-server # kbd console-data

### Grub
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean false
#d-i grub-installer/bootdev  string /dev/sda
# To install to the first device (assuming it is not a USB stick):
d-i grub-installer/bootdev string default

# Finish install
d-i finish-install/reboot_in_progress note
d-i cdrom-detect/eject boolean true

# Postinstall
d-i preseed/late_command string \
    in-target mkdir /root/.ssh ; \
    in-target mkdir /root/preseed ; \
    cp /cdrom/preseed/authorized_keys /target/root/.ssh/ ; \
    in-target chown -R root:root /root/ ; \
    in-target chmod -R go-rwx /root/.ssh/authorized_keys ; \
    in-target apt-get clean ; \
    cp /cdrom/preseed/* /target/root/preseed ; \
    in-target chmod +x /root/preseed/firstboot.sh ; \
    cp /cdrom/preseed/rc.local /target/etc/rc.local ; \
    echo "/var/tmp /tmp    none bind 0 0" >> /target/etc/fstab ; \
    in-target chmod +x /etc/rc.local ;
2025/03/24 15:06

Debian Preseed - Install automatique par fichier de réponse

Voir live-usb

Liens :

Plop

VPN

CD personnalisé:

apt-get install debconf-utils
debconf-get-selections --installer
mount -o loop /home/jean/iso/debian-8.2.0-amd64-CD-1.iso /mnt/iso/
rsync -a -H /mnt/iso/ /home/jean/dev/presseed/iso
umount /mnt/iso
chown jean: -R /home/jean/dev/presseed/iso                                      
chmod -R u+rwX /home/jean/dev/presseed/iso  
 
#fakeroot
rm irmod/ -rf
mkdir irmod
cd irmod
gzip -d < ../iso/install.amd/initrd.gz |cpio --extract --verbose --make-directories --no-absolute-filenames
/bin/cp -f ../preseed.cfg preseed.cfg
find . | cpio -H newc --create --verbose | gzip -9 > ../iso/install.amd/initrd.gz
#exit
cd ..
 
cd iso
md5sum $(find . -not -name "md5sum.txt" -follow -type f) > md5sum.txt
 
cd ..
genisoimage -o test.iso -r -J -no-emul-boot -boot-load-size 4  -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat ./iso
 
# Pour rendre "hybrid" l'iso, donc compatible USB en plus de CD/DVD
# Paquet syslinux-utils ou alors paquet syslinux
isohybrid test.iso

Pour le debug voir /var/log/installer/syslog

Note FRONTEND

DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
DEBIAN_FRONTEND=text
DEBIAN_FRONTEND=newt
DEBIAN_FRONTEND=gtk
 
FRONTEND_BACKGROUND=dark
Validation

Pour vérifier la syntaxe

sudo debconf-set-selections -c /path/to/preseed-debconf-file.txt

Preseed

# Preseed file for Debian
# Source http://wiki.deimos.fr/Automatiser_une_installation_de_Debian

### Contents of the preconfiguration file (for wheezy)
d-i debian-installer/language string en
d-i debian-installer/country string FR
d-i debian-installer/locale string en_US.UTF-8
d-i localechooser/supported-locales multiselect en_US.UTF-8, fr_FR.UTF-8

### Keyboard
d-i keyboard-configuration/xkb-keymap select fr
d-i keyboard-configuration/xkb-keymap select fr(latin9)
d-i console-keymaps-at/keymap select fr

# keymap is an alias for keyboard-configuration/xkb-keymap
#d-i keymap select fr(latin9)

### Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string

### Other
d-i hw-detect/load_firmware boolean false

### Apt mirror
#d-i mirror/protocol string http
#d-i mirror/country string manual
#d-i mirror/http/hostname string ftp.fr.debian.org
#d-i mirror/http/directory string /debian
#d-i mirror/http/proxy string
#d-i mirror/suite string wheezy
d-i mirror/protocol string ftp
d-i mirror/ftp/hostname string ftp.fr.debian.org
d-i mirror/ftp/directory string /debian
d-i mirror/ftp/proxy string

### Account setup
d-i passwd/root-login boolean false
d-i passwd/make-user boolean true
d-i passwd/root-password password toor
d-i passwd/root-password-again password toor
d-i passwd/user-fullname string Defab
d-i passwd/username string exploit
d-i passwd/user-password password toor
d-i passwd/user-password-again password toor
d-i passwd/user-uid string 1010

### Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string Europe/Paris
d-i clock-setup/ntp boolean true

### Partitioning
d-i partman-auto/choose_recipe select home
d-i partman-auto/method string regular
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-md/device_remove_md boolean true
# MARK
d-i partman-auto/disk string /dev/sda


# MARK
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-md/confirm boolean true
d-i partman/mount_style select uuid

### Base system installation
d-i base-installer/install-recommends boolean false

### Apt setup
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
# apt-cdrom-setup apt-setup/cdrom/set-next  boolean false
apt-cdrom-setup apt-setup/cdrom/set-next  boolean false
d-i apt-setup/contrib boolean true
d-i apt-setup/use_mirror boolean true
d-i apt-setup/services-select multiselect security, volatile
d-i apt-setup/security_host string security.debian.org
d-i apt-setup/volatile_host string volatile.debian.org

### Package selection
tasksel tasksel/first multiselect standard
d-i pkgsel/upgrade select safe-upgrade
popularity-contest popularity-contest/participate boolean false
d-i pkgsel/include string openssh-server build-essential vim curl wget sudo lm-sensors smartmontools openvpn

### Grub
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean false
# Due notably to potential USB sticks, the location of the MBR can not be
# determined safely in general, so this needs to be specified:
#d-i grub-installer/bootdev  string /dev/sda
# To install to the first device (assuming it is not a USB stick):
d-i grub-installer/bootdev  string default

# Finish install
d-i finish-install/reboot_in_progress note
d-i cdrom-detect/eject boolean true

# Postinstall
d-i preseed/late_command string \
    in-target mkdir /root/.ssh ; \
    in-target mkdir /root/preseed ; \
    in-target /bin/sh -c "echo '192.168.15.6 pkiweb.lan' >> /etc/hosts" ; \
    cp /cdrom/preseed/authorized_keys /target/root/.ssh/ ; \
    in-target chown -R root:root /root/ ; \
    in-target chmod -R go-rwx /root/.ssh/authorized_keys ; \
    in-target sed -i 's/PermitRootLogin yes/PermitRootLogin without-password/g' /etc/ssh/sshd_config ; \
    in-target /bin/sh -c "echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config'" ; \
    in-target apt-get clean ; \
    cp /cdrom/preseed/* /target/root/preseed ; \
    in-target chmod +x /root/preseed/firstboot.sh ; \
    in-target sed -i.bak "s%^exit 0%/root/preseed/firstboot.sh\x0aexit 0%" /etc/rc.local ;


Pb

Pb

/bin/preseed_command: return: line 23: Illegal number

Erreur.

Cette erreur survient à cause du retour ligne '\n'.

Solution Dans le cas présent, j'ai remplacé \n par \x0a

Exemple :

preseed.cfg
d-i preseed/late_command string \
        in-target sed -i.bak "s%^exit 0%/root/preseed/firstboot.sh\nexit 0%" /etc/rc.local ;
preseed.cfg
d-i preseed/late_command string \
        in-target sed -i.bak "s%^exit 0%/root/preseed/firstboot.sh\x0aexit 0%" /etc/rc.local ;
2025/03/24 15:06

Partition noatime

Linux kernel developer Ingo Molnár called atime perhaps the most stupid Unix design idea of all times. http://lwn.net/Articles/244829/

/etc/fstab

/dev/mapper/debian--vg-var /var            ext4    defaults        0       2
mount -o remount,noatime /var
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki