{"id":10,"date":"2010-01-07T18:03:46","date_gmt":"2010-01-07T18:03:46","guid":{"rendered":"http:\/\/www.otioti.com\/?p=3"},"modified":"2013-03-05T18:25:47","modified_gmt":"2013-03-05T18:25:47","slug":"howto-clonezilla-pxe-on-gentoo","status":"publish","type":"post","link":"https:\/\/www.otioti.com\/?p=10","title":{"rendered":"HowTo: Clonezilla &amp; PXE on Gentoo"},"content":{"rendered":"<p>Clonezilla is for me the best cloning HD opensource project I know. It&#8217;s similar to Norton Ghost, but Clonezilla is free. We could use clonezilla two ways: Clonezilla LiveCD y Clonezilla Server Edition.<\/p>\n<p>Clonezilla LiveCD let us create image partitions or whole hard disk and save it on another directory using Samba, ssh or nfs. Also, we could clone from disk to disk.<\/p>\n<p>Clonezilla LiveCD let us install Clonezilla as a service in our network. Problem? Clonezilla only works on Debian, CentOS, Fedora, Red Hat or Ubuntu. Gentoo not supported. And i don&#8217;t want to reinstall my server-router-firewall \ud83d\ude42<\/p>\n<p>So, my idea is install a TFTP service in that server, copy kernel, initrd and filesystem images from LiveCD to tftp directory and configure a PXE service using TFTP<\/p>\n<p>Ok, let&#8217;s go. First, download Clonezilla LiveCD:<a href=\"http:\/\/clonezilla.org\/download\/sourceforge\/\" target=\"_blank\"> http:\/\/clonezilla.org\/download\/sourceforge\/<\/a><\/p>\n<p>Mount ISO:<\/p>\n<pre>mount -o loop \/home\/user\/clonezilla-livecd.iso \/mnt\/cdrom<\/pre>\n<p>We need to install DHCP and TFTP Services:<\/p>\n<pre> # emerge -v dhcp tftp-hpa syslinux<\/pre>\n<p>Next, we&#8217;ve cofigure DHCP server:<\/p>\n<pre>authoritative;<\/pre>\n<pre>default-lease-time 600;<\/pre>\n<pre>max-lease-time 7200;<\/pre>\n<pre>ddns-update-style interim;<\/pre>\n<pre>allow booting;<\/pre>\n<pre>allow bootp;<\/pre>\n<pre>option domain-name \"yourcompany.net\";<\/pre>\n<pre>option subnet-mask 255.255.255.0;<\/pre>\n<pre>option broadcast-address 192.168.1.255;<\/pre>\n<pre>option domain-name-servers 192.168.1.1;<\/pre>\n<pre>option routers 192.168.1.1;<\/pre>\n<pre>subnet 192.168.1.0 netmask 255.255.255.0 {<\/pre>\n<pre>   range 192.168.1.100 192.168.1.200;<\/pre>\n<pre>   option broadcast-address        192.168.1.255;<\/pre>\n<pre>   option netbios-name-servers     192.168.1.10;<\/pre>\n<pre>   option routers                  192.168.1.1;<\/pre>\n<pre>   # For bootp - pxe clients<\/pre>\n<pre>   range dynamic-bootp 192.168.1.201 192.168.1.230;<\/pre>\n<pre>   next-server 192.168.1.1;<\/pre>\n<pre>   filename \"\/pxelinux.0\";<\/pre>\n<pre>}<\/pre>\n<p>For example, i configured my dhcp service next way:<\/p>\n<ol>\n<li>All my clients get dynamic IP from 192.168.1.100 to 192.168.1.200<\/li>\n<li>My gateway will be the same server, 192.168.1.1<\/li>\n<li>Configure PXE:\n<ol>\n<li><em>range dynamic-bootp<\/em>: We&#8217;ll give from 192.168.1.201 to 192.168.1.230 for all PXE clients.<\/li>\n<li><em>next-server<\/em>: IP of server which have kernel images and tftp service, router<\/li>\n<li><em>filename:<\/em> Path to PXE Loader, \/ by default.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>Next, let&#8217;s configure tftpd service. First, edit \/etc\/conf.d\/in.tftpd:<\/p>\n<pre># \/etc\/init.d\/in.tftpd\n\n# Path to server files from\n# Depending on your application you may have to change this.\n# This is commented out to force you to look at the file!\nINTFTPD_PATH=\"\/images\"\nINTFTPD_USER=\"nobody\"\n\n# For more options, see in.tftpd(8)\n# -R 4096:32767 solves problems with ARC firmware, and obsoletes\n# the \/proc\/sys\/net\/ipv4\/ip_local_port_range hack.\n# -s causes $INTFTPD_PATH to be the root of the TFTP tree.\n# -l is passed by the init script in addition to these options.\nINTFTPD_OPTS=\"-u ${INTFTPD_USER} -l -vvvvvv -p -c -s ${INTFTPD_PATH}\"<\/pre>\n<p>Next, create \/images directory:<\/p>\n<pre>mkdir -p \/images<\/pre>\n<p>So next, copy pxelinux.0 loader from syslinux package.<\/p>\n<pre>cp  \/usr\/lib\/syslinux\/pxelinux.0 \/images\/<\/pre>\n<p>Create \/images\/pxelinux.cfg directory.<\/p>\n<pre>mkdir \/images\/pxelinux.cfg<\/pre>\n<pre>chown nobody:nobody \/images<\/pre>\n<p>Edit default configuration to load kernel and parameters. We could copy file from Clonezilla LiveCD, \/isolinux\/isolinux.cfg, but next you&#8217;ll see a simple configuration example, and it&#8217;s OK for starting:<\/p>\n<pre>vim \/images\/boot\/pxelinux.cfg\/default\ndefault local\ntimeout 70\nprompt 0\nnoescape 1\nMENU MARGIN 5\nMENU BACKGROUND bg.png\n\n# Set the color for unselected menu item and timout message\nMENU COLOR UNSEL 7;32;41 #c0000090 #00000000\nMENU COLOR TIMEOUT_MSG 7;32;41 #c0000090 #00000000\nMENU COLOR TIMEOUT 7;32;41 #c0000090 #00000000\nMENU COLOR HELP 7;32;41 #c0000090 #00000000\n\nsay **********************************************\nsay Welcome to Clonezilla.\nsay www.yourcompany.net\nsay **********************************************\n\n# Do NOT allow client to edit the parameters\n#ALLOWOPTIONS 0\n\n# simple menu title\nMENU TITLE YOUR_COMPANY_NAME (http:\/\/www.yourcompany.net)\n\nlabel clonezilla\n  MENU DEFAULT\n  MENU LABEL Clonezilla live\n\n  kernel vmlinuz\n  append initrd=initrd.img boot=live union=aufs fetch=tftp:\/\/tftp_server_ip\/filesystem.squashfs vga=791 noswap noprompt ocs_lang=en_US.UTF-8 ocs_live_keymap=NONE\n\nlabel local\n  # MENU DEFAULT\n  MENU HIDE\n  MENU LABEL Local operating system (if available)\n  # MENU PASSWD\n  # 2 method to boot local device:\n  # (1) For localboot 0, it is decided by boot order in BIOS, so uncomment the follow 1 line if you want this method:\n  # localboot 0\n  # (2) For chain.c32, you can assign the boot device.\n  # Ref: extlinux.doc from syslinux\n  # Syntax: APPEND [hd|fd] []\n  # [] is optional.\n  # Ex:\n  # Second partition (2) on the first hard disk (hd0);\n  # Linux would *typically* call this \/dev\/hda2 or \/dev\/sda2, then it's \"APPEND hd0 2\"\n  #\n  kernel chain.c32\n  append hd0\n  TEXT HELP\n  Boot local OS from first hard disk if it's available\n  ENDTEXT<\/pre>\n<p>Next, we need copy kernel, initramfs filesystem images from LiveCD to \/images\/ on our server:<\/p>\n<pre>  cp \/mnt\/cdrom\/live\/vmlinuz \/images\/vmlinuz\n  cp \/mnt\/cdrom\/live\/initrd.img \/images\/initrd.img\n  cp \/mnt\/cdrom\/live\/filesystem.squashfs \/images\/filesystem.squashfs<\/pre>\n<p>Last, run services:<\/p>\n<pre>  \/etc\/init.d\/in.tftp start\n  \/etc\/init.d\/dhcp start\n  rc-update add in.tftp default\n  rc-update add dhcp default<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Clonezilla is for me the best cloning HD opensource project I know. It&#8217;s similar to Norton Ghost, but Clonezilla is free. We could use clonezilla two ways: Clonezilla LiveCD y Clonezilla Server Edition. Clonezilla LiveCD let us create image partitions or whole hard disk and save it on another directory using Samba, ssh or nfs. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,4],"tags":[27,28,14],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","category-gentoo-linux","category-linux","tag-clonezilla","tag-deploy","tag-gentoo-2"],"_links":{"self":[{"href":"https:\/\/www.otioti.com\/index.php?rest_route=\/wp\/v2\/posts\/10","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.otioti.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.otioti.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.otioti.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.otioti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10"}],"version-history":[{"count":1,"href":"https:\/\/www.otioti.com\/index.php?rest_route=\/wp\/v2\/posts\/10\/revisions"}],"predecessor-version":[{"id":266,"href":"https:\/\/www.otioti.com\/index.php?rest_route=\/wp\/v2\/posts\/10\/revisions\/266"}],"wp:attachment":[{"href":"https:\/\/www.otioti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.otioti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.otioti.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}