lgstd 发表于 2016-6-19 12:41:35

能不能实现不通过virtualbox安装ubuntu,而是直接安装到vhd中?

2011niumao 发表于 2016-6-21 10:37:17

lgstd 发表于 2016-6-19 12:41
能不能实现不通过virtualbox安装ubuntu,而是直接安装到vhd中?

当然可以。先在Win系统下准备一个新的固定大小的vhd,分好分区,推荐只分一个分区。
接着如同普通硬盘安装,启动到ubuntu的安装iso系统中,在该系统中利用 kpartx -av 命令把vhd挂到loop设备上,一般是/dev/mapper/loop1p1 .
接下来正常按装,但选择设备时候选择loop设备挂载根。至于引导,可以不安装或者选择引导设备是 /dev/loop1. 如果有出错就选择不安装grub引导器。也不设置 swap 。
安装完成后写好引导。再下载(第一楼KLOOP链接)个已经制作好的可以引导固定vhd的引导文件,两个,是vmlinuz-版本号 initrd.img-版本号 。使用他们引导进入vhd系统就可以了。

进入VHD以后可以自己制作最新版本的可以引导固定vhd的内核初始镜像文件。

2011niumao 发表于 2016-6-21 10:37:23

lgstd 发表于 2016-6-19 12:41
能不能实现不通过virtualbox安装ubuntu,而是直接安装到vhd中?

当然可以。先在Win系统下准备一个新的固定大小的vhd,分好分区,推荐只分一个分区。
接着如同普通硬盘安装,启动到ubuntu的安装iso系统中,在该系统中利用 kpartx -av 命令把vhd挂到loop设备上,一般是/dev/mapper/loop1p1 .
接下来正常按装,但选择设备时候选择loop设备挂载根。至于引导,可以不安装或者选择引导设备是 /dev/loop1. 如果有出错就选择不安装grub引导器。也不设置 swap 。
安装完成后写好引导。再下载(第一楼KLOOP链接)个已经制作好的可以引导固定vhd的引导文件,两个,是vmlinuz-版本号 initrd.img-版本号 。使用他们引导进入vhd系统就可以了。

进入VHD以后可以自己制作最新版本的可以引导固定vhd的内核初始镜像文件。

lgstd 发表于 2016-6-21 14:33:13

2011niumao 发表于 2016-6-21 10:37
当然可以。先在Win系统下准备一个新的固定大小的vhd,分好分区,推荐只分一个分区。
接着如同普通硬盘安 ...

谢谢回复,我试试看

lgstd 发表于 2016-6-21 14:33:19

2011niumao 发表于 2016-6-21 10:37
当然可以。先在Win系统下准备一个新的固定大小的vhd,分好分区,推荐只分一个分区。
接着如同普通硬盘安 ...

谢谢回复,我试试看

lgstd 发表于 2016-6-21 14:33:23

2011niumao 发表于 2016-6-21 10:37
当然可以。先在Win系统下准备一个新的固定大小的vhd,分好分区,推荐只分一个分区。
接着如同普通硬盘安 ...

谢谢回复,我试试看!!

lgstd 发表于 2016-6-21 14:33:28

2011niumao 发表于 2016-6-21 10:37
当然可以。先在Win系统下准备一个新的固定大小的vhd,分好分区,推荐只分一个分区。
接着如同普通硬盘安 ...

谢谢回复,我试试看!!!!!!

sherylynn 发表于 2016-8-24 01:07:17

您的百度云链接访问不了了

2011niumao 发表于 2016-8-26 21:24:38

本帖最后由 2011niumao 于 2016-8-26 21:26 编辑

https://pan.baidu.com/s/1pLJ9W3T

湛蓝阴影 发表于 2016-8-31 09:58:59

链接和附件都不能下载了

wdtx 发表于 2016-10-18 09:55:24

装个Linux Mint18试试,学习学习

tushen 发表于 2016-10-19 20:36:39

下载了,解压缩好像有问题。

is286 发表于 2016-10-27 10:44:04

支持不支持ubuntu 最新版?

wx13650035186 发表于 2016-10-28 12:24:39

本人很感谢这位大师,在他提供的附件帮助下本人于16年10月28号成功制作基于UBUNTU14.04的VHD启动本人QQ2840390592欢迎讨论

2012aric 发表于 2016-11-14 12:24:36

2011niumao 发表于 2016-8-26 21:24
https://pan.baidu.com/s/1pLJ9W3T

失效了

Srainbow 发表于 2016-11-16 13:40:16

@2011niumao,
使用ubuntu 16.04 制作的vhd

dmesg出错很多错误:
[ 7147.802795] blk_update_request: I/O error, dev loop0, sector 32577304
[ 7153.748500] blk_update_request: I/O error, dev loop0, sector 32533824
[ 7154.788273] blk_update_request: I/O error, dev loop0, sector 32533864
[ 7161.006307] blk_update_request: I/O error, dev loop0, sector 32358800
[ 7164.173713] blk_update_request: I/O error, dev loop0, sector 32577344
[ 7169.450030] blk_update_request: I/O error, dev loop0, sector 32533904
[ 7170.855654] blk_update_request: I/O error, dev loop0, sector 32577384
[ 7177.540130] blk_update_request: I/O error, dev loop0, sector 32358840
[ 7179.834922] blk_update_request: I/O error, dev loop0, sector 32577424
[ 7187.615629] blk_update_request: I/O error, dev loop0, sector 32358880


楼主能看下,怎么解决 这种问题吗?

2011niumao 发表于 2016-11-16 16:03:59

Srainbow 发表于 2016-11-16 13:40
@2011niumao,
使用ubuntu 16.04 制作的vhd



不会。目前看不影响使用,不用管它。

jgckb 发表于 2016-12-15 15:28:15

说的好,一定回复~











static/image/common/sigline.gif
蓝品盾卫浴扶手

ge 发表于 2016-12-15 17:48:37

有没有简单点的?这个引导的系统菜单我是看不懂!

aoqy 发表于 2017-1-16 08:01:30

大神,有没有可能支持android?

2011niumao 发表于 2017-1-16 11:57:51

aoqy 发表于 2017-1-16 08:01
大神,有没有可能支持android?

android与linux差别太大,应该做不到了。但是android有类似于ubuntu的live系统的做法,也不需要vhd吧。

aoqy 发表于 2017-1-16 16:34:54

2011niumao 发表于 2017-1-16 11:57
android与linux差别太大,应该做不到了。但是android有类似于ubuntu的live系统的做法,也不需要vhd吧。

技术上如果能做到,倒是有LIVE系统不可比拟的一些好处,例如:重启可以保留状态,另外不同的系统可以在同一个U盘中。

2011niumao 发表于 2017-1-16 20:36:21

本帖最后由 2011niumao 于 2017-1-17 20:30 编辑

发布两个ISO,就是把live系统制作成iso文件了。请到一楼第一个链接下载。
有基于ghostplant简化的ubuntu1604版本和完整ubuntu1604两种版本。
用户名密码,root密码都是ubuntu .UBT-small.iso文件系统与vhd squashfs系统一致,都是ubuntu-1604,更新到最新(4.4.0-59)。
        用户名 密码 root密码都是ubuntu。        有如下用法:

1.        可以直接从VirtualBox启动,并且可以EFI启动和传统bios-mbr启动。

2.        可以和发行版live-cd一样通过grub4dos,grub2启动
        (需要把casper/initrd.img casper/vmlinuz先提取出来 )。

3.        可以把ISO文件放到/grub/IMGS目录下,利用网友制作的自动ISO菜单直接启动
        (只限于grub4dos启动)。

4.        启动后可以使用主目录的UCloner中的UCloner_CN或UCloner_EN(双击),
        依照提示操作,将/cdrom/casper/中的文件UBT-small.squashfs 恢复到硬盘分区。

5.        也可以预先在WINDOWS系统下准备好一个固定大小的vhd虚拟磁盘,
        例如名字为UBT-small.vhd,
        进行初始化和建立一个分区,格式化并将其标记为活动分区。
        (右键我的电脑--管理--创建vhd--初始化--建立简单卷--标记为活动分区)

        再启动到UBT-small的ISO系统(或live系统)中,打开一个终端,进入到vhd文件所在目录,
        运行
        sudo kpartx -av UBT-small.vhd
        记住其显示的输出,里面有类似于 /dev/mapper/loop2p1 型字段。

      图形界面打开主目录的UCloner子目录,双击UCloner_CN(UCloner_EN),
        依提示操作,将/cdrom/casper/中文件UBT-small.squashfs恢复到某个固定大小VHD硬盘的分区,
        此时弹出对话框中 / 分区手动填写,如 /dev/mapper/loop2p1(与kpartx命令的输出一致) .
        文件系统手动填写ext4 ,其他空白。然后一直下一步或输入y回车让其恢复系统。

        注意,grub2应该空白,等待系统恢复完毕以后再手动安装。
        安装grub2的参考命令:
        sudo mount /dev/mapper/loop2p1 /mnt
        sudo grub-install--root-directory=/mnt/dev/loop2

wdtx 发表于 2017-1-17 09:34:57

aoqy 发表于 2017-1-16 16:34
技术上如果能做到,倒是有LIVE系统不可比拟的一些好处,例如:重启可以保留状态,另外不同的系统可以在同 ...

到这里http://www.phoenixos.com/download
下载一个凤凰系统,其实就是安卓系统,exe格式的,安装很简单,装完会自动添加启动菜单,

对PC兼容很好,驱动很全,我的联想本装完,声、显、网卡Wifi都自动驱动了

aoqy 发表于 2017-1-17 12:48:18

试试看吧

2011niumao 发表于 2017-1-18 10:44:26

grub2有一个命令 loopback 可以满足只用一个VHD文件的要求。一个菜单样式menuentry " UBT-small.vhd " --classubuntu {
        insmod gzio
        insmod part_msdos
        insmod part_gpt
        insmod ext2
        insmod ntfs
        insmod probe
        set vhdfile="/ubt/UBT-small.vhd"
        set root=(hd0,1)
        search --no-floppy -f --set=aabbcc$vhdfile
        set root=${aabbcc}
        probe -u --set=ddeeff ${aabbcc}
        loopback loop0 $vhdfile
        linux        (loop0,1)/vmlinuz root=UUID=${ddeeff} rwkloop=$vhdfilekroot=/dev/mapper/loop0p1
        initrd        (loop0,1)/initrd.img
}对于不分区的img文件,(loop0,1)应该改用(loop0)。

devilma 发表于 2017-1-19 12:46:17

不错的说,学习了。。。。

2011niumao 发表于 2017-1-22 10:51:28

alanyih 发表于 2017-1-21 17:10
This seems to work!
"reboot.pro/topic/20603-linux-from-vhd-how-to/page-3#entry201757"

the original local-file has a mistaken,the sentence“if [ -z "$kloop" ]; then"is placed in the front of the function local_mount_root().It should beplaced after the sentence "local_premount" of the functionlocal_mount_root(),like such
local_mount_root()
{
        local_top
        local_device_setup "${ROOT}" root
        ROOT="${DEV}"

        # Get the root filesystem type if not set
        if [ -z "${ROOTFSTYPE}" ]; then
                FSTYPE=$(get_fstype "${ROOT}")
        else
                FSTYPE=${ROOTFSTYPE}
        fi

        local_premount

if [ -z "$kloop" ]; then
........All is OK.

2011niumao 发表于 2017-1-22 10:55:54

本帖最后由 2011niumao 于 2017-1-22 11:00 编辑

The new local_mount_root() in the file /usr/share/initramfs-tools/scripts/local :local_mount_root()
{
        local_top
        local_device_setup "${ROOT}" root
        ROOT="${DEV}"

        # Get the root filesystem type if not set
        if [ -z "${ROOTFSTYPE}" ]; then
                FSTYPE=$(get_fstype "${ROOT}")
        else
                FSTYPE=${ROOTFSTYPE}
        fi

        local_premount

if [ -z "$kloop" ]; then

        if [ "${readonly}" = "y" ] && \
           [ -z "$LOOP" ]; then
                roflag=-r
        else
                roflag=-w
        fi

        # FIXME This has no error checking
        [ -n "${FSTYPE}" ] && modprobe ${FSTYPE}

        checkfs ${ROOT} root

        # FIXME This has no error checking
        # Mount root
        mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
        mountroot_status="$?"
        if [ "$LOOP" ]; then
                if [ "$mountroot_status" != 0 ]; then
                        if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
                                panic "
Could not mount the partition ${ROOT}.
This could also happen if the file system is not clean because of an operating
system crash, an interrupted boot process, an improper shutdown, or unplugging
of a removable device without first unmounting or ejecting it.To fix this,
simply reboot into Windows, let it fully start, log in, run 'chkdsk /r', then
gracefully shut down and reboot back into Windows. After this you should be
able to reboot again and resume the installation.
(filesystem = ${FSTYPE}, error code = $mountroot_status)
"
                        fi
                fi
       
                mkdir -p /host
                mount -o move ${rootmnt} /host

                while [ ! -e "/host/${LOOP#/}" ]; do
                        panic "ALERT!/host/${LOOP#/} does not exist.Dropping to a shell!"
                done

                # Get the loop filesystem type if not set
                if [ -z "${LOOPFSTYPE}" ]; then
                        eval $(fstype < "/host/${LOOP#/}")
                else
                        FSTYPE="${LOOPFSTYPE}"
                fi
                if [ "$FSTYPE" = "unknown" ] && [ -x /sbin/blkid ]; then
                        FSTYPE=$(/sbin/blkid -s TYPE -o value "/host/${LOOP#/}")
                        [ -z "$FSTYPE" ] && FSTYPE="unknown"
                fi

                if [ ${readonly} = y ]; then
                        roflag=-r
                else
                        roflag=-w
                fi

                # FIXME This has no error checking
                modprobe loop
                modprobe ${FSTYPE}

                # FIXME This has no error checking
                mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "/host/${LOOP#/}" ${rootmnt}

                if [ -d ${rootmnt}/host ]; then
                        mount -o move /host ${rootmnt}/host
                fi
        fi

fi

        ##############################################
        #                kloop by niumao            #
        ##############################################

if [ -n "$kloop" ]; then

        ### reset the value of the root variable
        HOSTDEV="${ROOT}"
        NEWROOT="${rootmnt}"
        [ -n "$kroot" ] && ROOT="$kroot"
        [ -n "$kroot" ] || ROOT="/dev/loop0"
        export ROOT
        realroot="$ROOT"
       
        ###auto probe the fs-type of the partition in which vhd-file live and mount it/host
        mkdir -p /host
        if [ -z "$hostfstype" ]; then
                hostfstype="$(blkid -s TYPE -o value "${HOSTDEV}")"
                [ -z "$hostfstype"-o "${hostfstype}" = "ntfs" ] && hostfstype="ntfs-3g"
        fi
        [ "${hostfstype}" = "ntfs-3g" ] || modprobe ${hostfstype}
        mount -t ${hostfstype} -o rw${HOSTDEV}/host
       
        ### mount the vhd-file on a loop-device
        if [ "${kloop#/}" !="${kloop}" ]; then              
                modprobeloop
                kpartx -av /host$kloop
                [ -e "$realroot" ] || sleep 3
        fi

        ### probe lvm on vhd-file
        if [ -n "$klvm" ];then
                modprobe dm-mod
                vgscan
                vgchange-ay$klvm
                [ -e "$realroot" ] ||sleep 3
        fi

        if [ "${readonly}" = "y" ] ; then
                roflag="-r"
        else
                roflag="-w"
        fi
       
        ### mount the realroot / in vhd-file on $NEWROOT
        if [ -z "${kloopfstype}" ]; then
                kloopfstype="$(blkid -s TYPE -o value "$realroot")"
                [ -z "${kloopfstype}" ] && kloopfstype="ext4"
        fi
        [ -e "$realroot" ] || sleep 3
        mount    ${roflag} -t "${kloopfstype}"$realroot $NEWROOT
       
        ### mount /host in initrd to /host of the realrootfs
        if ["${hosthidden}" != "y" ] ; then
                [ -d "${NEWROOT}"/host ] || mkdir -p ${NEWROOT}/host
                mount --move /host   ${NEWROOT}/host
        fi
fi

        ##############################################
        #        kloop by niumao ended           #
        ##############################################

}   

2011niumao 发表于 2017-2-19 12:05:14

引导squashfs的Fedora ARCH Mageia opensuse

本帖最后由 2011niumao 于 2017-2-19 12:07 编辑

发布一个可以引导squashfs只读文件系统的新版kloop,下载一楼链接里面mydracut-squashfs.zip。里面有使用说明。本版加入了一种新的引导模式,用来引导squashfs只读文件系统。(使用了overlay机制)
方法与KLOOP的方法一样,还是分为两步。
第一步,编译安装修改过的ntfs-3g。
(不修改则无法防止关机时候在卸载根设备前先卸载根设备文件所在的底层分区)。
第二步,制作内存镜像盘initrd 或initramfs。做法与KLOOP一样。
制作好后将其改名(例如initrd-fedora),与vmlinuz-XXXX(改名为vmlinuz-feodra)与squashfs文件
(例如 Fedora25.squashfs)放在同一个目录(例如casper1)下。


引导菜单,引导时候只需要root 与squashfs两个参数,root的值是squashfs文件所在分区,
squashfs的值是squashfs文件的带路径的名字。例子:

grub4dos菜单:
title 启动LIVE-Fedora
find --set-root --ignore-floppies --ignore-cd/casper1/vmlinuz-fedora
uuid ()
kernel /casper1/vmlinuz-fedora root=UUID=%?% squashfs=/casper1/Fedora25.squashfs
initrd/casper1/initrd-fedora

grub2菜单:
menuentry "live-Fedora "--class fedora{
        insmod gzio
        insmod part_msdos
        insmod part_gpt
        insmod ext2
        insmod ntfs
        insmod probe
        set sfsfile="/casper1/Fedora25.squashfs"
        set root=(hd0,1)
        search --no-floppy -f --set=aabbcc$sfsfile
        set root=${aabbcc}
        probe -u --set=ddeeff ${aabbcc}
        linux        /casper1/vmlinuz-fedora   root=UUID=${ddeeff} squashfs=$sfsfilerw nompath nodmraid
        initrd        /casper1/initrd-fedora

附录===备份现有linux系统为squashfs系统的命令与恢复命令
需要linux系统安装好squashfs-tool,以及rsync。以Fedora25为例子。假设根设备为/dev/sda12。备份feodra25到/dev/sda9的目录casper1下,备份名字为Fedora25.squashfs。
su
cd /tmp
mkdir mm tt
mount /dev/sda12 mm
mount /dev/sda9 tt
mksquashfs mm tt/casper1/Fedora25.squashfs -b 262144 -comp xz -e tmp/mm tmp/tt

恢复命令
假设启动到了squashfs系统中后,要把Fedora25.squashfs恢复到硬盘/dev/sda12中,可以如下操作:
su
cd /tmp
mkdir mm tt
mount /host/casper1/Fedora25.squashfs mm
mount /dev/sda12 tt
rsync -SHavmm/*tt/
等恢复完毕后再通过修改grub4dos的menu.lst或grub2的菜单来设置引导即可。
页: 1 2 3 4 5 6 7 8 [9] 10 11 12 13 14 15 16 17 18
查看完整版本: 从 固定VHD与只读squashfs引导LINUX, UBUNTU ARCH Fedora Opensuse Mageia五种