{"id":168153,"date":"2020-01-10T08:42:17","date_gmt":"2020-01-10T00:42:17","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=168153"},"modified":"2019-12-31T10:42:46","modified_gmt":"2019-12-31T02:42:46","slug":"fedora-live-cd","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/fedora-live-cd.html","title":{"rendered":"\u542f\u52a8\u4e00\u4e2a Fedora Live CD"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4f5c\u4e3a\u4f7f\u7528 DVD \u548c USB \u9a71\u52a8\u5668\u6765\u5b58\u50a8\u4f60\u7684 Live CD \u955c\u50cf\u662f\u4e00\u4e2a\u66ff\u4ee3\u65b9\u6848\uff0c\u4f60\u53ef\u4ee5\u4e0a\u4f20\u5b83\u4eec\u5230\u4e00\u4e2a\u4e0d\u592a\u53ef\u80fd\u4e22\u5931\u6216\u635f\u574f\u7684 iSCSI \u670d\u52a1\u5668\u4e2d\u3002\u8fd9\u4e2a\u6307\u5357\u5411\u4f60\u5c55\u793a\u5982\u4f55\u52a0\u8f7d\u4f60\u7684 Live CD \u955c\u50cf\u5230\u4e00\u4e2a ISCSI \u670d\u52a1\u5668\u4e0a\uff0c\u5e76\u4f7f\u7528 iPXE \u542f\u52a8\u52a0\u8f7d\u7a0b\u5e8f\u6765\u8bbf\u95ee\u5b83\u4eec\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Live CD \u5bf9\u4e8e\u5f88\u591a\u4efb\u52a1\u662f\u5f88\u6709\u7528\u7684\uff0c\u4f8b\u5982:<\/p>\n

\u5c06\u64cd\u4f5c\u7cfb\u7edf\u5b89\u88c5\u5230\u4e00\u4e2a\u786c\u76d8\u9a71\u52a8\u5668
\n\u4fee\u590d\u4e00\u4e2a\u542f\u52a8\u52a0\u8f7d\u7a0b\u5e8f\u6216\u6267\u884c\u5176\u5b83\u6551\u63f4\u6a21\u5f0f\u64cd\u4f5c
\n\u4e3a Web \u6d4f\u89c8\u63d0\u4f9b\u4e00\u4e2a\u76f8\u9002\u5e94\u7684\u6700\u5c0f\u73af\u5883
\n\u2026\u4ee5\u53ca\u66f4\u591a\u7684\u4e1c\u897f\u3002<\/p>\n

\u4e0b\u8f7d\u4e00\u4e2a Live CD \u955c\u50cf<\/strong><\/div>\n
\r\n$ MY_RLSE=27\r\n$ MY_LIVE=$(wget -q -O - https:\/\/dl.fedoraproject.org\/pub\/archive\/fedora\/linux\/releases\/$MY_RLSE\/Workstation\/x86_64\/iso | perl -ne '\/(Fedora[^ ]*?-Live-[^ ]*?\\.iso)(?{print $^N})\/;')\r\n$ MY_NAME=fc$MY_RLSE \r\n$ wget -O $MY_NAME.iso https:\/\/dl.fedoraproject.org\/pub\/archive\/fedora\/linux\/releases\/$MY_RLSE\/Workstation\/x86_64\/iso\/$MY_LIVE\r\n<\/pre>\n

\u4e0a\u9762\u7684\u547d\u4ee4\u4e0b\u8f7d Fedora-Workstation-Live-x86_64-27-1.6.iso<\/span> Fedora Live \u955c\u50cf\uff0c\u5e76\u4fdd\u5b58\u4e3a fc27.iso\u3002\u66f4\u6539 MY_RLSE \u7684\u503c\u6765\u4e0b\u8f7d\u5176\u5b83\u6863\u6848\u7248\u672c\u3002\u6216\u8005\uff0c\u4f60\u53ef\u4ee5\u6d4f\u89c8 https:\/\/getfedora.org\/ \u6765\u4e0b\u8f7d\u6700\u65b0\u7684 Fedora live \u955c\u50cf\u3002\u5728 21 \u4e4b\u524d\u7684\u7248\u672c\u4f7f\u7528\u4e0d\u540c\u7684\u547d\u540d\u7ea6\u5b9a\uff0c\u5fc5\u9700\u5728\u8fd9\u91cc\u624b\u52a8\u4e0b\u8f7d\u3002\u5982\u679c\u4f60\u624b\u52a8\u4e0b\u8f7d\u4e00\u4e2a Live CD \u955c\u50cf\uff0c\u8bbe\u7f6e MY_NAME<\/span> \u53d8\u91cf\u4e3a\u4e0d\u5e26\u6709\u6269\u5c55\u540d\u7684\u6587\u4ef6\u7684\u57fa\u672c\u540d\u79f0\u3002\u7528\u6b64\u65b9\u6cd5\uff0c\u4e0b\u9762\u90e8\u5206\u4e2d\u547d\u4ee4\u5c06\u5f15\u7528\u6b63\u786e\u7684\u6587\u4ef6\u3002<\/p>\n

\u8f6c\u6362 Live CD \u955c\u50cf<\/strong><\/div>\n

\u4f7f\u7528 livecd-iso-to-disk<\/span> \u5de5\u5177\u6765\u8f6c\u6362 ISO \u6587\u4ef6\u4e3a\u4e00\u4e2a\u78c1\u76d8\u955c\u50cf\uff0c\u5e76\u6dfb\u52a0 netroot <\/span>\u53c2\u6570\u5230\u5d4c\u5165\u7684\u5185\u6838\u547d\u4ee4\u884c\uff1a<\/p>\n

\r\n$ sudo dnf install -y livecd-tools\r\n$ MY_SIZE=$(du -ms $MY_NAME.iso | cut -f 1)\r\n$ dd if=\/dev\/zero of=$MY_NAME.img bs=1MiB count=0 seek=$(($MY_SIZE+512)) \r\n$ MY_SRVR=server-01.example.edu \r\n$ MY_RVRS=$(echo $MY_SRVR | tr '.' \"\\n\" | tac | tr \"\\n\" '.' | cut -b -${#MY_SRVR}) \r\n$ MY_LOOP=$(sudo losetup --show --nooverlap --find $MY_NAME.img) \r\n$ sudo livecd-iso-to-disk --format --extra-kernel-args netroot=iscsi:$MY_SRVR:::1:iqn.$MY_RVRS:$MY_NAME $MY_NAME.iso $MY_LOOP \r\n$ sudo losetup -d $MY_LOOP\r\n<\/pre>\n
\u4e0a\u4f20 Live \u955c\u50cf\u5230\u4f60\u7684\u670d\u52a1\u5668<\/strong><\/div>\n

\u5728\u4f60\u7684 ISCSI \u670d\u52a1\u5668\u4e0a\u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\u6765\u5b58\u50a8\u4f60\u7684 live \u955c\u50cf\uff0c\u968f\u540e\u4e0a\u4f20\u4f60\u4fee\u6539\u7684\u955c\u50cf\u5230\u5176\u4e2d\u3002<\/p>\n

\u5bf9\u4e8e 21 \u53ca\u66f4\u9ad8\u53d1\u5e03\u7248\u672c\uff1a<\/p>\n

\r\n$ MY_FLDR=\/images \r\n$ scp $MY_NAME.img $MY_SRVR:$MY_FLDR\/\r\n<\/pre>\n

\u5bf9\u4e8e 21 \u4ee5\u524d\u53d1\u5e03\u7248\u672c\uff1a<\/p>\n

\r\n$ MY_FLDR=\/images \r\n$ MY_LOOP=$(sudo losetup --show --nooverlap --find --partscan $MY_NAME.img) \r\n$ sudo tune2fs -O ^has_journal ${MY_LOOP}p1 \r\n$ sudo e2fsck ${MY_LOOP}p1 \r\n$ sudo dd status=none if=${MY_LOOP}p1 | ssh $MY_SRVR \"dd of=$MY_FLDR\/$MY_NAME.img\" \r\n$ sudo losetup -d $MY_LOOP\r\n<\/pre>\n
\u5b9a\u4e49 iSCSI \u76ee\u6807<\/strong><\/div>\n

\u5728\u4f60\u7684 iSCSI \u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a<\/p>\n

\r\n$ sudo -i \r\n# MY_NAME=fc27 \r\n# MY_FLDR=\/images \r\n# MY_SRVR=`hostname` \r\n# MY_RVRS=$(echo $MY_SRVR | tr '.' \"\\n\" | tac | tr \"\\n\" '.' | cut -b -${#MY_SRVR}) \r\n# cat << END > \/etc\/tgt\/conf.d\/$MY_NAME.conf \r\n\r\n    backing-store $MY_FLDR\/$MY_NAME.img\r\n    readonly 1\r\n    allow-in-use yes \r\n<\/target> \r\nEND \r\n# tgt-admin --update ALL\r\n<\/pre>\n
\u521b\u5efa\u4e00\u4e2a\u53ef\u542f\u52a8 USB \u9a71\u52a8\u5668<\/strong><\/div>\n

iPXE <\/span>\u542f\u52a8\u52a0\u8f7d\u7a0b\u5e8f\u6709\u4e00\u4e2a sanboot <\/span>\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u8fde\u63a5\u5e76\u542f\u52a8\u6258\u7ba1\u4e8e\u4f60 ISCSI \u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u7684 live \u955c\u50cf\u3002\u5b83\u53ef\u4ee5\u4ee5\u5f88\u591a\u4e0d\u540c\u7684\u683c\u5f0f\u7f16\u8bd1\u3002\u6700\u597d\u7684\u5de5\u4f5c\u683c\u5f0f\u4f9d\u8d56\u4e8e\u4f60\u6b63\u5728\u8fd0\u884c\u7684\u786c\u4ef6\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u8bf4\u660e\u5411\u4f60\u5c55\u793a\u5982\u4f55\u5728\u4e00\u4e2a USB \u9a71\u52a8\u5668\u4e0a\u4ece syslinux<\/span> \u4e2d \u94fe\u5f0f\u52a0\u8f7d iPXE\u3002<\/p>\n

\u9996\u5148\uff0c\u4e0b\u8f7d iPXE\uff0c\u5e76\u4ee5\u5b83\u7684 lkrn \u683c\u5f0f\u6784\u5efa\u3002\u8fd9\u5e94\u8be5\u4f5c\u4e3a\u4e00\u4e2a\u5de5\u4f5c\u7ad9\u4e0a\u7684\u666e\u901a\u7528\u6237\u5b8c\u6210\uff1a<\/p>\n

\r\n$ sudo dnf install -y git \r\n$ git clone http:\/\/git.ipxe.org\/ipxe.git $HOME\/ipxe \r\n$ sudo dnf groupinstall -y \"C Development Tools and Libraries\"\r\n$ cd $HOME\/ipxe\/src \r\n$ make clean \r\n$ make bin\/ipxe.lkrn \r\n$ cp bin\/ipxe.lkrn \/tmp\r\n<\/pre>\n

\u63a5\u4e0b\u6765\uff0c\u51c6\u5907\u4e00\u4e2a\u5e26\u6709\u4e00\u4e2a MSDOS \u5206\u533a\u8868\u548c\u4e00\u4e2a FAT32 \u6587\u4ef6\u7cfb\u7edf\u7684 USB \u9a71\u52a8\u5668\u3002\u4e0b\u9762\u7684\u547d\u4ee4\u5047\u8bbe\u4f60\u5df2\u7ecf\u8fde\u63a5\u5c06\u8981\u683c\u5f0f\u5316\u7684 USB \u9a71\u52a8\u5668\u3002\u6ce8\u610f\uff1a\u4f60\u8981\u683c\u5f0f\u6b63\u786e\u7684\u9a71\u52a8\u5668\uff01<\/p>\n

\r\n$ sudo -i \r\n# dnf install -y parted util-linux dosfstools \r\n# echo; find \/dev\/disk\/by-id ! -regex '.*-part.*' -name 'usb-*' -exec readlink -f {} \\; | xargs -i bash -c \"parted -s {} unit MiB print | perl -0 -ne '\/^Model: ([^(]*).*\\n.*?([0-9]*MiB)\/i && print \\\"Found: {} = \\$2 \\$1\\n\\\"'\"; echo; read -e -i \"$(find \/dev\/disk\/by-id ! -regex '.*-part.*' -name 'usb-*' -exec readlink -f {} \\; -quit)\" -p \"Drive to format: \" MY_USB\r\n# umount $MY_USB? \r\n# wipefs -a $MY_USB \r\n# parted -s $MY_USB mklabel msdos mkpart primary fat32 1MiB 100% set 1 boot on \r\n# mkfs -t vfat -F 32 ${MY_USB}1\r\n<\/pre>\n

\u6700\u540e\uff0c\u5728 USB \u9a71\u52a8\u5668\u4e0a\u5b89\u88c5\u5e76\u914d\u7f6e syslinux \uff0c\u6765\u94fe\u5f0f\u52a0\u8f7d iPXE\uff1a<\/p>\n

\r\n# dnf install -y syslinux-nonlinux \r\n# syslinux -i ${MY_USB}1 \r\n# dd if=\/usr\/share\/syslinux\/mbr.bin of=${MY_USB} \r\n# MY_MNT=$(mktemp -d) \r\n# mount ${MY_USB}1 $MY_MNT \r\n# MY_NAME=fc27 \r\n# MY_SRVR=server-01.example.edu \r\n# MY_RVRS=$(echo $MY_SRVR | tr '.' \"\\n\" | tac | tr \"\\n\" '.' | cut -b -${#MY_SRVR}) \r\n# cat << END > $MY_MNT\/syslinux.cfg\r\nui menu.c32\r\ndefault $MY_NAME\r\ntimeout 100\r\nmenu title SYSLINUX\r\nlabel $MY_NAME\r\n    menu label ${MY_NAME^^}\r\n    kernel ipxe.lkrn\r\n    append dhcp && sanboot iscsi:$MY_SRVR:::1:iqn.$MY_RVRS:$MY_NAME\r\nEND \r\n# cp \/usr\/share\/syslinux\/menu.c32 $MY_MNT \r\n# cp \/usr\/share\/syslinux\/libutil.c32 $MY_MNT \r\n# cp \/tmp\/ipxe.lkrn $MY_MNT \r\n# umount ${MY_USB}1\r\n<\/pre>\n

\u901a\u8fc7\u7b80\u5355\u5730\u7f16\u8f91 syslinux.cfg<\/span> \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u9644\u52a0\u7684\u83dc\u5355\u9879\uff0c\u4f60\u5e94\u8be5\u80fd\u591f\u4f7f\u7528\u8fd9\u540c\u4e00\u4e2a USB \u9a71\u52a8\u5668\u6765\u7f51\u7edc\u542f\u52a8\u9644\u52a0\u7684 ISCSI \u76ee\u6807\u3002<\/p>\n

\u8fd9\u4ec5\u662f\u52a0\u8f7d IPXE \u7684\u4e00\u79cd\u65b9\u6cd5\u3002\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728\u4f60\u7684\u5de5\u4f5c\u7ad9\u4e0a\u5b89\u88c5 syslinux \u3002\u518d\u4e00\u79cd\u9009\u9879\u662f\u7f16\u8bd1 iPXE \u4e3a\u4e00\u4e2a EFI \u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5e76\u76f4\u63a5\u653e\u7f6e\u5b83\u5230\u4f60\u7684 ESP \u4e2d\u3002\u53c8\u4e00\u79cd\u9009\u9879\u662f\u7f16\u8bd1 iPXE \u4e3a\u4e00\u4e2a PXE \u52a0\u8f7d\u5668\uff0c\u5e76\u653e\u7f6e\u5b83\u5230\u4f60\u7684\u80fd\u591f\u88ab DHCP \u5f15\u7528\u7684 TFTP \u670d\u52a1\u5668\u3002\u6700\u4f73\u7684\u9009\u9879\u4f9d\u8d56\u4e8e\u7684\u73af\u5883<\/p>\n

\u6700\u540e\u8bf4\u660e<\/strong><\/div>\n

\u5982\u679c\u4f60\u4ee5 IPXE \u7684 EFI \u683c\u5f0f\u7f16\u8bd1 IPXE \uff0c\u4f60\u53ef\u80fd\u60f3\u6dfb\u52a0 \u2013filename \\EFI\\BOOT\\grubx64.efi<\/span> \u53c2\u6570\u5230 sanboot \u547d\u4ee4\u3002
\n\u80fd\u591f\u521b\u5efa\u81ea\u5b9a\u4e49 live \u955c\u50cf\u3002\u66f4\u591a\u4fe1\u606f\u53c2\u8003\u521b\u5efa\u548c\u4f7f\u7528 live CD\u3002
\n\u53ef\u4ee5\u6dfb\u52a0 \u2013overlay-size-mb<\/span> \u548c \u2013home-size-mb<\/span> \u53c2\u6570\u5230 livecd-iso-to-disk<\/span> \u547d\u4ee4\u6765\u521b\u5efa\u6c38\u4e45\u5b58\u50a8\u7684 live \u955c\u50cf\u3002\u7136\u800c\uff0c\u5982\u679c\u4f60\u6709\u591a\u4e2a\u5e76\u53d1\u7528\u6237\uff0c\u4f60\u5c06\u9700\u8981\u8bbe\u7f6e\u4f60\u7684 ISCSI \u670d\u52a1\u5668\u6765\u7ba1\u7406\u72ec\u7acb\u7684\u6bcf\u4e2a\u7528\u6237\u7684\u53ef\u5199\u8986\u76d6\u3002\u8fd9\u4e0e \u201c\u5982\u4f55\u6784\u5efa\u4e00\u4e2a\u7f51\u7edc\u542f\u52a8\u670d\u52a1\u5668\uff0c\u90e8\u5206 4\u201d \u4e00\u6587\u6240\u793a\u7c7b\u4f3c\u3002
\nLive \u955c\u50cf\u5728\u5b83\u4eec\u7684\u5185\u6838\u547d\u4ee4\u884c\u4e2d\u652f\u6301\u4e00\u4e2a persistenthome <\/span>\u9009\u9879\uff08\u4f8b\u5982\uff0c persistenthome=LABEL=HOME<\/span>\uff09\u3002\u4e0e\u7ecf\u8fc7 CHAP \u8eab\u4efd\u9a8c\u8bc1\u7684 iSCSI \u76ee\u6807\u4e00\u8d77\u4f7f\u7528\uff0c\u5bf9\u4e8e\u4e2d\u5fc3\u63a7\u5236\u4e3b\u76ee\u5f55\uff0cpersistenthome<\/span> \u9009\u9879\u4e3a NFS \u63d0\u4f9b\u4e00\u4e2a\u6709\u8da3\u7684\u66ff\u4ee3\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Live CD \u5bf9\u4e8e\u5f88\u591a\u4efb\u52a1\u662f\u5f88\u6709\u7528\u7684\uff0c\u4f8b\u5982: \u5c06\u64cd\u4f5c\u7cfb\u7edf\u5b89\u88c5\u5230\u4e00\u4e2a\u786c\u76d8\u9a71\u52a8\u5668 \u4fee\u590d\u4e00\u4e2a\u542f\u52a8\u52a0\u8f7d\u7a0b\u5e8f\u6216\u6267\u884c\u5176\u5b83 […]<\/p>\n","protected":false},"author":1890,"featured_media":168224,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-168153","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/168153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1890"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=168153"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/168153\/revisions"}],"predecessor-version":[{"id":168767,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/168153\/revisions\/168767"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/168224"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=168153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=168153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=168153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}