How to install a linux system by copy disk partition

 If you can copy the whole disk, then do it, it works better.



1. copy your old alpine system partition as a iso file, especially make sure the `/boot` folder has files: `vmlinuxz-grsec` and `initramfs-grsec`. `dd if=/dev/sdb2 of=xx.iso`
2. use dd to copy that disk partiton to your new computer partition, a ext4 would be fine. `dd if=xx.iso of=/dev/sdb2`
3. i am using `lubuntu16_i386` system to work as a PE system, all you have to do is install lubuntu16_i386 to another partition of your disk. It will generate a not working version of grub boot menu for you, you can see "unknown linux distrubution" when you boot your computer. you need to fix it later.
4. boot into lubuntu16, `sudo su`, `vim /etc/grub.d/40_custom`, add following to the bottom:
    ```
    menuentry 'Alpine' {
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos5'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5  b22f8c27-ad74-4b25-a219-7c5a8d876451
        else
          search --no-floppy --fs-uuid --set=root b22f8c27-ad74-4b25-a219-7c5a8d876451
        fi
        linux /boot/vmlinuz-grsec root=/dev/sda5 rootfstype=ext4 modules=sd-mod,usb-storage,ext4
        initrd '/boot/initramfs-grsec'
    }
    ```

5. you can change the `40_custom` based on `/boot/grub/grub.cfg`, I just did a copy and modify from "Unknown Linux distribution" boot menu. You just have to make sure the partiton position is right.
6. after the modification, run `sudo update-grub`, it will update the real boot menu. (Sometimes you should also run `sudo grub-install /dev/xx`.)

> alpine says their system support new boot method, for example EFI, but I don't know how to config it: https://wiki.alpinelinux.org/wiki/Bootloaders

> if you can't see unknow distrubution, change 40_custom to something like this `menuentry 'Alpline' {\nset root='hd0,msdos5'\nlinux /boot/vmlinuz-grsec root=/dev/sda5\ninitrd '/boot/initramfs-grsec''`, run `update-grub`.

> lubuntu16 has gparted when you boot from usb, in there you can see your disk name and partition name in a clear way. But they will uninstall it after you install lubuntu16, what a stupid idea!

> `/boot` folder basically manages all stuff related to your machine boot issue, when you do a partition copy and paste, you have to make sure something is inside of that.