Originalmente escrito para o Ubuntu 12.04 LTS (precisa), este passo a passo foi atualizado e testado para o Ubuntu 12.10 (quântica), 13,04 (raring) e 13,10 (picante).
Esta configuração utiliza Ubuntu do (na verdade, do Debian)
live-boot
initramfs os scripts o, squashfs
sistema de arquivos , aufs
sistema de arquivos, e VirtualBox para fornecer várias características vantajosas: - A unidade flash só é lido na inicialização, enquanto o ambiente ao vivo corre inteiramente a partir de RAM graças a
aufs
-sparing seu stick USB do ataque I / O de um sistema em execução - O recurso de snapshot do VirtualBox faz para um método fantástico de controle de versão para a imagem do sistema compactado
-
Um sistema muito maior do que seria normalmente caber na mídia
removível (e que se encaixam na RAM) pode ser construído graças à
compressão de
squashfs
(Também-no interesse da divulgação, este post vai provavelmente ver alguns ajustes aqui e ali, como eu refinar o meu processo.)
Materiais:
- Máquina host VM (w / Oracle VirtualBox)
- VM # 1: 15GB + HDD ("Build Box")
- VM # 2: 8 GB + HDD ("Box Thumb")
- Máquina física ("Target")
- Pendrive USB de 2GB +
- Ubuntu 13.10 Servidor ISO
- Pave seus dois VMs (Build Box & Thumb Box) e sua máquina de destino (Target)
- Para construir um kernel personalizado com suporte embutido AUFS e SquashFS
- Instale o kernel para Box Thumb e Target
- Adicionar imagens initrd live-inicialização para Box Thumb e Target
- Instale software / atualização em Thumb Box, conforme necessário
- Apare e esmagar o sistema de arquivos a partir de Thumb Box em uma imagem squashfs
- Empurre a imagem para baixo ao Target
- Reinicie o computador de destino para a imagem atualizada
- Repita os passos 5-8 para modificar o sistema de arquivos Ubun2RAM esmagado (alterações de configuração, atualização / adicionar / remover software, etc.)
- Para abrir espaço para a construção do sistema de arquivos esmagado antes da transferência (e para aproveitar o espaço que squashfs vai economizar), sistema de arquivos da VM de destino deve ser 3-4 vezes o tamanho do USB colá-la será empurrado para.
- Pavimentar todas as máquinas com a opção de sistema mínimo Instalar a partir do menu Modos (F4) na tela de inicialização do Ubuntu ISO.
- As instalações da Caixa Thumb e alvo não requerem uma partição swap. A partição singular em cada um deve ser configurado com um
ext3
sistema de arquivos. Você pode optar por utilizar uma partição swap em mídias distintas, no entanto, se desejar. - Dica: Quando pavimentação da máquina de destino, você pode instalar o Ubuntu para o stick USB Você não precisa de um disco rígido nesta máquina, você pode iniciar a partir de mídia portátil para a RAM. Você certamente pode tirar proveito de armazenamento conectado na máquina de dentro de seu sistema Ubun2RAM, mas o próprio sistema básico pode viver inteiramente no stick USB.
- Todos os 3 de as máquinas podem ser pavimentada a partir do VirtualBox; você só precisa fazer um proxy VMDK para o seu stick USB para que você possa iniciar a partir dele em uma VM nua a fim de preparar-la. (Eu tenho uma configuração de máquina sem armazenamento de sua própria apenas o proxy VMDK.)
- Eu achei que o
bc
pacote é agora necessária para a construção dos kernels picantes.
Construir Box:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
| # get build tools sudo apt-get install fakeroot
build-essential crash kexec-tools makedumpfile kernel-wedge
kernel-package git-core libncurses5 libncurses5-dev libelf-dev asciidoc
binutils-dev bc -y # get dependencies sudo apt-get build-dep linux -y # clone the kernel repo (and go have some coffee) git clone git: //kernel .ubuntu.com /ubuntu/ubuntu-saucy .git saucy cd saucy # get a list of kernels git tag -l # choose which kernel you wish to build, then use it in the checkout command below # checkout a kernel branch into a working branch git checkout -b work Ubuntu-3.11.0-12.19 # build the necessary control scripts, as Ubuntu git kernels do not include them by default fakeroot debian /rules clean # configure your kernel make menuconfig # set AUFS (Ubuntu 3rd party drivers) and SquashFS (File systems -> Miscellaneous) as built-in # set processor governor to 'ondemand' (Power management and ACPI options -> CPU Frequency scaling) # parallel build; change this to 1+(number of processors) based on your machine specs export CONCURRENCY_LEVEL=3 # build your kernel fakeroot make -kpkg --initrd --append-to-version=-saucy-custom kernel-headers kernel-image |
01
02
03
04
05
06
07
08
09
10
11
12
13
| # get live-boot and squashfs stuff sudo apt-get install live-boot live-boot-initramfs-tools squashfs-tools -y # pull down your kernel and headers packages from Build Box # install them sudo dpkg -i linux-image-*.deb sudo dpkg -i linux-headers-*.deb # reboot into your new kernel so that it is used when we update-grub below! # create /etc/grub.d/50_ramsession # make it executable sudo chmod +x /etc/grub .d /50_ramsession # set GRUB_DEFAULT='Ubun2RAM' in /etc/default/grub # rebuild the grub bootloader menu to include Ubun2RAM sudo update-grub |
1
2
3
4
5
6
7
8
| #!/usr/bin/env bash cat <<EOF # ram session; disable apparmor and boot read/write squashfs/aufs combo from /live/filesystem.squashfs menuentry 'Ubun2RAM' --class ubuntu --class gnu-linux --class gnu --class os { linux /boot/vmlinuz- $( uname -r) BOOT=LIVE boot=live toram=filesystem.squashfs rw quiet splash nonetworking apparmor=0 security= "" $vt_handoff initrd /boot/initrd .img-$( uname -r) } EOF |
01
02
03
04
05
06
07
08
09
10
11
| # get squashfs tools sudo apt-get install squashfs-tools -y # pull down your kernel and headers packages from Build Box # install them sudo dpkg -i linux-image-*.deb sudo dpkg -i linux-headers-*.deb #
install/update whatever software you want at this point (start here if
you already have a working Ubun2RAM and you're just updating it) # next, we make the file system image (do this each time you update or install software) sh makeimage.sh # push your squashed file system image to the USB stick when you're done installing stuff sh pushimage.sh |
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| #!/usr/bin/env bash # usage: makeimage.sh [staging folder] [device] # default value for staging folder STAGING= /var/squashfs # pull staging folder from command line arguments if any if [ $1 ]; then STAGING=$1 shift fi # make the staging folder if it doesn't exist [ !-d ${STAGING} ] && sudo mkdir -p ${STAGING} # if staging folder is on a device, mount it [ $1 ] && sudo mount $1 ${STAGING} # copy the system into the staging folder, excluding unnecessary parts sudo rsync -avxW --delete / ${STAGING} \ --exclude= /proc/ * --exclude= /tmp/ * --exclude= /dev/ * --exclude= /sys/ * \ --exclude= /boot/ * --exclude= /etc/mtab --exclude= /live \ --exclude= /var/cache/apt/archives/ *.deb --exclude= /var/run \ --exclude= /var/mail --exclude= /var/lock --exclude= /var/backups \ --exclude= /var/tmp \ --exclude=${STAGING} # remove the root mount from the squashed /etc/fstab sudo sed -i '/^[^ ]\+ \/ /d' ${STAGING} /etc/fstab # increase the device number of the NIC in squashed /etc/network/interfaces sudo sed -i 's/eth1/eth2/' ${STAGING} /etc/network/interfaces # trim logs from staging folder [ -n "$STAGING" ] && sudo find ${STAGING} /var/log - type f -iregex '.*\.[0-9].*' - exec rm - v {} \; [ -n "$STAGING" ] && sudo find ${STAGING} /var/log - type f -iname '*.gz' - exec rm - v {} \; [ -n "$STAGING" ] && sudo find ${STAGING} /var/log - type f | while read file ; do echo -n '' | sudo tee $ file ; done # make the squashfs file from the staging folder contents sudo mksquashfs ${STAGING} filesystem.squashfs -noappend -always-use-fragments # if we mounted a device for staging, unmount it [ $1 ] && sudo umount $1 |
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
| #!/usr/bin/env bash # usage: pushimage.sh [destination device] [mount point] # default values DEST= /dev/sdb1 WHERE= /mnt # pull destination device from command line arguments if any if [ $1 ]; then DEST=$1 shift fi # pull mount point from command line arguments if any [ $1 ] && WHERE=$1 # mount the device sudo mount ${DEST} ${WHERE} # send the squashed file system to the device sudo rsync -rvW --progress filesystem.squashfs ${WHERE} /live/ # unmount the device sudo umount ${DEST} |
0 comentários
Postar um comentário