UmVirt Linux From Scratch v.0.1 =============================== New disk creation from directory tree archive --------------------------------------------- #1. Create 10GB drive dd if=/dev/zero of=ulfs.img bs=1G count=10 #2. Fdisk it fdisk ulfs.img #create new partition table >o >w #2. Fdisk it again fdisk ulfs.img #Create linux partition >n >p >[enter] >+8G #Create linux swap patrition >n >p >[enter] >[enter] >t >2 >82 #check >p Disk ulfs.img: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xe1fe7cb3 Device Boot Start End Blocks Id System ulfs.img1 2048 16779263 8388608 83 Linux ulfs.img2 16779264 20971519 2096128 82 Linux swap / Solaris #Write >w #3. Attach ulfs.img as block device kpartx -av ulfs.img add map loop0p1 (252:4): 0 16777216 linear /dev/loop0 2048 add map loop0p2 (252:5): 0 4192256 linear /dev/loop0 16779264 #4. Format linux partition on ulfs.img mkfs.ext4 /dev/mapper/loop0p1 #5. Make mount point directory mkdir /mnt/build_dir #6. Copy build_dir.tar.gz in /mnt directory #7. Mount linux partition mount /dev/mapper/loop0p1 /mnt/build_dir #8. Go to /mnt directory cd /mnt #9. Extract build_dir.tar.gz tar -xf build_dir.tar.gz #10. umount linux parttition umount /dev/mapper/loop0p1 #11. Detach ulfs.img block device kpartx -dv ulfs.img Install grub ------------ #1. Download grub.iso to boot in grub shell #2. Run qemu and boot from grub.iso qemu-system-x86_64 -boot d -cdrom grub.iso -drive file=ulfs.img,if=virtio > ls > ls (hd0,1)/boot/vmlinuz vmlinuz > linux (hd0,1)/boot/vmlinuz root=/dev/vda1 ro > boot #3. Login #4. Install grub... #...on virtio disk grub-install /dev/vda #...on IDE/SATA disk grub-install /dev/sda #5. Poweroff poweroff #3. Run qemu and boot from ulfs.img qemu-system-x86_64 -drive file=ulfs.img,if=virtio #5. Poweroff poweroff Backup ------ dd if=ulfs.img bs=16384 | gzip | dd of=ulfs.img.gz Restore ------- dd if=ulfs.img.gz | gunzip | dd of=ulfs.img.restored Convert from raw to qcow2 ------------------------- qemu-img convert ulfs.img ulfs.qcow2 -O qcow2 Snapshot via qemu ----------------- #help man qemu-img #creation/reset qemu-img create -f qcow2 -b ulfs.img ulfs_init.img #usage qemu-system-x86_64 -drive file=ulfs_init.img,if=virtio #commit qemu-img commit ulfs_init.img Work ---- 1. Config network ln -s /dev/null /etc/systemd/network/99-default.link #1.1 Static IP cat > /etc/systemd/network/10-eth-static.network << "EOF" [Match] Name= [Network] Address=192.168.0.2/24 Gateway=192.168.0.1 DNS=192.168.0.1 Domains= EOF #1.1. DHCP cat > /etc/systemd/network/10-eth-dhcp.network << "EOF" [Match] Name=eth0 [Network] DHCP=ipv4 [DHCP] UseDomains=true EOF 2. Put wget source package in /sources directory 3. Unpack wget 4. Compile wget 5. Install wget 6. Install other packages 6.1 Manualy ./configure --prefix=/usr make make install 6.1 Automaticaly wget --no-check-cerificate https://umvirt.com/linux/packages/0.1/mc/install -O - | bash * Compile & install mc package with all dependances.