1

Topic: GParted via PXE

by dtibbe (david.tibbe@hpi.uni-potsdam.de)

After some attempts I succeeded in booting GParted via PXE. Because I read that some of you wanted the same, I'll post my steps how I got it working.

For sure, we need GParted. I used the USB-Version (0.3.1.1). If the ISO works either and if the steps are similar, I don't know smile Then we will need the tool ext2resize. It is available at http://ext2resize.sf.net and also as Debian package. That's all smile

At first I'll explain a bit how the GParted image works. When we boot from the stick, a little linux image will be loaded from the initial ramdisk (initrd.gz). When it is starting up, it will check each USB-port if there is an stick attached which includes a file named "gparted" in its root directory. If such a port was found, the stick is mounted and the image and GParted will be loaded.
If we want to boot via PXE, we do not have any stick attached to the system, so that check will fail. We also do not want do deliver an additional file (gparted) via the PXE. The solution is to include that file into the initrd and modify the startup script.

Sounds quite easy, doesn't it? wink So, let's start.

First of all, we have to extract the zip archive. Then unzip the initial ramdisk:
# gunzip initrd.gz
The initrd has a proper size but it's to small to include the gparted file (it has a size of round about 23MB). So we have to enlarge the ramdisk. Before we can do that, we have to define the file sizes of initrd and gparted:
# du -m initrd
14    initrd
# du -m gparted
23 gparted
The initrd has a size of 14MB, gparted is 23MB. I've enlarged my initrd with 25MB, so there is enough free space.
Enlarging is done by
# dd if=/dev/zero of=initrd bs=1M seek=14 count=25
That means we'll find the point that is 14MB in the image and append 25MB from there on. The resulting image will have a size of 29MB. Then, we've to run ext2resize on that image to enlarge the file system either:
# ext2resize initrd

Now we will mount that image into the new subfolder image (using a loop-device) to be able to edit it:
# mkdir image
# mount initrd image/ -o loop
If we have a look into that folder, we will find there a complete folder structure as on every other linux system, too. Now, we can copy the gparted-file into the /tmp-folder of the image:
# cp gparted image/tmp

Then we have to edit the startup script of the initial ramdisk. It is named linuxrc and can be found in the image-folder.
In that file, there is a section that tests the USB devices. It starts with the line
  USB_LIST=""
and ends in from of the line
  if [ -f /dev/ramboot ]; then
I have simply deleted them all smile
After that line, the stick will be mounted to /tmp. But we have the gparted-file already there, so we do not need mounting it. Delete that line and the following one with the sleep command. The first line after
  if [ -f /dev/ramboot ]; then
should be
  losetup /dev/loop0 /tmp/gparted >/dev/null 2>&1
Some lines below, the stick will be mounted again, delete that line
  mount -n -t msdos $GPARTED_USB_DEVICE /tmp
either.
Save the file.

Now we've modified everything, we just have to do some clean up.
Unmount the image and gzip the initrd:
# umount image
# gzip initrd

Serve the new initrd.gz with the provided linux-kernel. The other files in the folder are just needed if you boot from the stick, they provide a boot loader.
If you're using pxelinux, you have to do the following:
create a folder gparted in your tftp-root and copy the files in there:
# mkdir gparted
# cp /any/where/initrd.gz gparted
# cp /any/where/linux gparted
Add the following lines to the pxelinux-configuration-file (/tftproot/pxelinux.cfg/default by default)
LABEL gparted
  MENU LABEL GParted
  kernel /gparted/linux
  append noapic initrd=/gparted/initrd.gz root=/dev/ram0 init=/linuxrc ramdisk_size=65000
If you want to use the "Low memory"-version of GParted, set the ramdisk_size to a smaller number, eg. 16384.

That's all. Enjoy GParting wink

Regards,
  David

Larry
GParted-project Admin
Former GParted-LiveCD maintainer (2007)

2 (edited by dtibbe 2006-09-20 16:22:52)

Re: GParted via PXE

For all those, who do not want to create an own disk, I've packed mine. You can download it from http://www.myhpi.de/~dtibbe/tmp/gparted.zip . It includes the linux-kernel, the modified initrd and my original post

Regards,
  David

3

Re: GParted via PXE

dtibbe : your link is broken  (seems to)

Larry
GParted-project Admin
Former GParted-LiveCD maintainer (2007)

4

Re: GParted via PXE

LarryT wrote:

dtibbe : your link is broken  (seems to)

It was the forum wink
Before the dot followed directly after the link and was assumed be part of it...

Regards

5

Re: GParted via PXE

Hey dtibbe, did you make a custom kernel? If you did does it have /proc/config.gz built in? If not can I get the kernel config file?

What name do you want me to use on the news page, changelog, etc...? David Tibbe?

6

Re: GParted via PXE

Patrick Verner wrote:

Hey dtibbe, did you make a custom kernel?

No, i did not. I just used the official files and added the gparted-file into the initrd. I did not recompiled anything

What name do you want me to use on the news page, changelog, etc...? David Tibbe?

Yes, that would be nice.

When you're going to release a new version and if you tell me before, then I could make a new PXE-version so that all can be released at the same time if you want

Regards,
  David

7 (edited by toored 2006-10-06 01:21:39)

Re: GParted via PXE

I was having problems with the file dtibbe provided so created my own. You can download it from the following location:  http://www.filesend.net/download.php?f= … dafea3c0c0
File needs to be d/l once every 30 days for it to stay online

or:
http://up-file.com/download/c949c868932 … 1.zip.html
or:
http://mihd.net/5.6241/gparted-pxe-3.1-1.zip.html


BTW, thanks dtibbe for the howto smile

8

Re: GParted via PXE

Hello,

your changes are not for GPartEd 0.3.1
Exist there any capabilities to implement it in 0.3.1 ?
Or have anyone a PXE bootkernel for those version for me?

Thanks a lot

9

Re: GParted via PXE

I added:

if cat /proc/cmdline | grep -q pxeboot
then
  echo "Detected pxeboot on kernel cmdline"
  > /dev/pxeboot
fi

if [ -f /dev/pxeboot -a -f /tmp/gparted ]
   then
echo ""
echo Booting from initrd Drive with Ramdisk...
losetup /dev/loop0 /tmp/gparted >/dev/null 2>&1
echo Mounting root file system...
mount -n /dev/loop0 /mnt -t squashfs >/dev/null 2>&1
sleep 1
cd /mnt
pivot_root . mnt
umount -n /mnt/proc >/dev/null 2>&1
exec chroot . sh -c 'umount -n /mnt >/dev/null 2>&1; exec -a init.new /sbin/init 3' <dev/console >dev/console 2>&1
fi

Then you just add "pxeboot" to the append line:

label GParted LiveCD 0.3.3
        kernel gparted-livecd-0.3.3-0/linux
        append noapic initrd=gparted-livecd-0.3.3-0/initrd.gz root=/dev/ram0 init=/linuxrc ramdisk_size=65000 pxeboot

10

Re: GParted via PXE

i am getting Invalid or corrupt kernel image

Anyone else?

11

Re: GParted via PXE

I still get the same error.

For informations mail me.
Is there something like an updated Version?
Really need a gParted booted via PXE.

12

Re: GParted via PXE

Did you check MD5 ?

*** It is highly recommended to backup any important files before doing resize/move operations. ***

13

Re: GParted via PXE

BTW, from GParted live 0.3.6 (actually 0.3.7-2), a different method for PXE server was added. Check this:
http://gparted.sourceforge.net/livepxe.php

14 (edited by jenszahner 2008-06-09 14:43:00)

Re: GParted via PXE

I've made a patch to the new method of booting GParted using PXE server not requiring setting up a http server.
Take a look at my patch:

http://gparted-forum.surf4.info/viewtopic.php?id=1481