![画像](https://habrastorage.org/getpro/habr/post_images/edf/620/f8f/edf620f8fc5d88a79210b10870d92aab.png)
私自身、このインストール方法が最も適切だと考えています。 シンプルさの点で、柔軟性が高く、新しくインストールされたシステムには最新バージョンのパッケージがあり、システムが正常に動作するために必要なものはすべて、最初の起動前にインストールできます。 カットの下で、スクリプトのセットを提供します。
まず、新しいシステムのインストール元となるLinuxシステムが必要です。 LiveCDからインストールおよび実行されているディストリビューションはすべて実行されます。
ステップ0:ハードドライブの準備
まず、あなたの魂が望むようにディスクをマークする必要があります。 インターネットには多くの良い指示がありますが、私は通常GPartedグラフィックユーティリティを使用します。 ディストリビューションを再インストール/変更する場合、別のセクションで選択/ホームすることを強くお勧めします。これにより、データ転送によるwith核を回避できます。ディレクトリ内のすべてのパーティションをマウントします(たとえば、/ mnt / debian /)。 さらに、スクリプトの外部であっても、/ mnt / debianの代わりに$ TARGETを使用します。
## , /dev/sda1 - root, /dev/sda2 - home mkdir /mnt/debian mount /dev/sda1 /mnt/debian mkdir /mnt/debian/home mount /dev/sda2 /mnt/debian/home
ステップ1:基本システムの構築
スクリプトを機能させるには、debベースのすべてのディストリビューションのリポジトリにある動作可能なdebootstrapが必要です。 変数を修正したり、行をコメント/コメント解除することを恐れないでください。 #!/bin/bash ARCH=i386 #ARCH=amd64 ## 64- - 32- ## debian OS=debian DISTRO=wheezy #DISTRO=stable ## ubuntu #OS=ubuntu #DISTRO=oneiric ## TARGET=/mnt/debian ## cdrom : #debootstrap --include=sudo,nano,wget --arch $ARCH $DISTRO $TARGET file:/media/cdrom ## debootstrap --include=sudo,nano,wget --arch $ARCH $DISTRO $TARGET http://$OS.mirror.vu.lt/$OS/ ## , / mount -o bind /dev $TARGET/dev mount -o bind /sys $TARGET/sys
ステップ2:初期設定
パターンに従って$ TARGET / etc / fstabファイルを構成します。 # /etc/fstab: static file system information. # # Use 'vol_id --uuid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 # /dev/sda1 /boot ext2 defaults 0 0 /dev/sda2 / ext4 defaults 0 1 /dev/sda3 /home ext4 defaults 0 0 /dev/sda4 none swap sw 0 0
上記の例では、次のようになります。
# /etc/fstab: static file system information. # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/sda1 / ext4 defaults 0 1 /dev/sda2 /home ext4 defaults 0 0
そして、ファイル$ TARGET / etc / apt / sources.list。 生成する( debian 、 ubuntuのジェネレータ)か、テンプレートを使用することができます:
Debianのテンプレート
deb http://http.debian.net/debian $DISTRO main contrib non-free # deb-src http://http.debian.net/debian $DISTRO main deb http://security.debian.org $DISTRO/updates main contrib non-free # deb-src http://security.debian.org $DISTRO/updates main deb http://http.debian.net/debian-backports $DISTRO-backports main non-free # deb-src http://http.debian.net/debian-backports $DISTRO-backports main deb http://http.debian.net/debian $DISTRO-proposed-updates main contrib non-free # deb-src http://http.debian.net/debian $DISTRO-proposed-updates main
Ubuntuのテンプレート
deb http://ru.archive.ubuntu.com/ubuntu $DISTRO main universe restricted multiverse # deb-src http://ru.archive.ubuntu.com/ubuntu $DISTRO main universe deb http://security.ubuntu.com/ubuntu $DISTRO-security main universe restricted multiverse # deb-src http://security.ubuntu.com/ubuntu $DISTRO-security main universe deb http://ru.archive.ubuntu.com/ubuntu $DISTRO-updates main universe restricted multiverse # deb-src http://ru.archive.ubuntu.com/ubuntu $DISTRO-updates main universe deb http://ru.archive.ubuntu.com/ubuntu $DISTRO-proposed main universe restricted multiverse # deb-src http://ru.archive.ubuntu.com/ubuntu $DISTRO-proposed main universe deb http://ru.archive.ubuntu.com/ubuntu $DISTRO-backports main universe restricted multiverse # deb-src http://ru.archive.ubuntu.com/ubuntu $DISTRO-backports main universe deb http://archive.canonical.com/ubuntu $DISTRO partner deb http://extras.ubuntu.com/ubuntu $DISTRO main # deb-src http://extras.ubuntu.com/ubuntu $DISTRO main
ステップ3:他のすべて
これを行うには、chrootで次のスクリプトを実行します。 スクリプト名がpostinst.shで、$ TARGET /にある場合、次のように実行する必要があります。 env LANG=C env HOME=/root chroot $TARGET /bin/bash /postinst.sh
スクリプト自体:
#!/bin/bash ## apt-get update ## dpkg-reconfigure tzdata ## mount -t proc /proc /proc mount -a ## apt-get -y install popularity-contest ## , ## console-cyrillic , , UniCyr, «» apt-get -y install locales console-cyrillic dpkg-reconfigure locales dpkg-reconfigure console-cyrillic ## hostname, HOST='mysuperpc' echo "$HOST" > /etc/hostname echo -e "\n127.0.0.1 localhost $HOST" >> /etc/hosts ## , sudo USER='mynotsuperuser' echo ' ' adduser $USER usermod -a -G sudo $USER ## root echo ' root' passwd ## ARCH=i686 #: i386, i486, i686, amd64 ## Debian: apt-get -y install linux-base linux-image-$ARCH linux-headers grub ## Ubuntu: # apt-get -y install linux-image-generic linux-headers-generic ## apt-get -y install firmware-linux firmware-ralink firmware-realtek ## ## Debian: apt-get -y install xorg kde-full #KDE #apt-get -y install xorg kde # <= Lenny #apt-get -y install xorg gnome #apt-get -y install xorg xfce lxdm #XFCE #apt-get -y install xorg lxde lxdm #LXDE ## Debian, apt-get -y install pulseaudio apt-get -y install alsa-base alsa-tools alsa-utils alsa-oss ## Ubuntu: #apt-get -y install xorg kubuntu-desktop #KDE #apt-get -y install xorg ubuntu-desktop #Unity #apt-get -y install xorg gnome-shell gnome-themes-standard gnome-tweak-tool #Gnome3 #apt-get -y install xorg xubuntu-desktop #XFCE #apt-get -y install xorg lubuntu-desktop #LXDE
リブートする前に何か他のものを手動で配置する必要がある場合は、次のコマンドでいつでもchroot環境に入ることができます。
env LANG=C env HOME=/root chroot $TARGET /bin/bash
以上です。 半自動インストール用のスクリプトの完全なセットをgithubに投稿したので、プルリクエストの形式で提案や改善を記入することをためらわないでください。