sudo apt-get install usb-creator-common gir1.2-gudev-1.0 usb-creator-gtk # python-gudev too?
fdisk -l # list the disks (look for the correct size/type)
umount /dev/sdc # ensure it's not mounted (plugging it in often auto mounts)
sudo apt-get install parted parted /dev/sdc # run parted on the usb disk print # display the partitions rm 1 # remove the first partition
usb-creator-gtk "erase disk"
Source disk (.iso) -> Other -> UbuntuServer12.04.iso make startup disk
17apr08
target pc = a computer with no cd rom but lan (pxe), host pc = a spare computer with working cdrom & nic, a network switch/hub
burn the latest system resuce cd (www.sysresccd.org)
disconnect the switch from any existing networks that might have dhcp servers
make sure that the host & target computers are on the same switch
configure the target pc BIOS to boot from pxe (Network)
configure the host pc BIOS to boot from cdrom before hd
boot the host computer from the system rescue cd
(rescuecd docache = all in RAM, requires at least 128MB, faster to work with than cdrom)
at the linux prompt type "net-setup eth0" to configure your server network card
//"ifconfig" will show you the resulting settings, type "man ifconfig" for more help //ifconfig eth0 address 192.168.1.5 netmask 255.255.255.0 //route add default gw 192.168.1.254
Start your DHCP/TFTP/BOOTPXE server /etc/init.d/pxebootsrv start --verbose
(or "cd /etc/init.d" and then "./pxebootsrv start --verbose")
Turn on target pc
Watch target pc use pxe boot to acquire a dhcp ip address then it downloads the system rescue cd image via lan and boots up system rescue cd!
On the target machine you now have a linux system rescue os to work with
type "wizard" at the promt to use an autoconfigured gui windows type interface, it may not always work
at the terminal console command line prompt type "fdisk -l" to see what hard disk devices are available
//ntfs info about the device ntfsresize -i /dev/sda1
//also you can use ntfs-3g --help, or ntfsresize --help
//simulate reducing the size to 30 GB from 39GB ntfsresize -n -s 30G /dev/sda1
generated the ERROR: Extended record needed (1096 > 1024), not yet supported! Needs: remove virtual memory (windows swap=pagefile.sys), and defragment
ntfsresize -n -s 35800M /dev/sda1
//Trial and error gave me the above number, remember this number!
This only "shrinks" the data (moves it away from the edge of the partition)
We must delete the "old" partition from the MBR (use fdisk or cfdisk or sfdisk) And create a "new" partition with a size 200MB bigger than our shrunk value (36GB)
fdisk /dev/sda m //help p //print u // change to sectors (not blocks?)
id 7 hpfs/ntfs //very important to remember what type of partition it is! 1 -> 4862 Blocks //current start and end points Start point is 1, (phew, that was easy - it could have been much worse!)
39,053,983 / 4862 = 8032 bytes per block 39,000,000 - 36,000,000 = 3,053,983 bytes / 8032 bytes per block = 380 blocks
4862 -380 blocks
(new endpoint) 4481 = 35,993,000 bytes (almost 36GB, right on target)
so delete default deletes partition 1
d //delete the partition p //print to see nothing (all partitions gone) n //new partition p //primary 1 //1 (first primary partition) p //print to see the new first primary partition, default file system is linux (83) t //change the type of partition L //Lists all of the known types, we wrote down 7 HPFS/NTFS so that's easy to replace a //toggle bootable flag, we want this to be the boot partition!!! q //quit without saving changes (you're not sure of the details yet!) w //write and quit (you VERY sure)
UNBELIEVABLE, SUCCESSFUL!!!!!!!!! boots and is checking the file system (marked as dirty but that's ok) Reboots itself again after file check and starts window
ALTERNATIVE METHODS ##########################################################
sfdisk /dev/sda 4861 4862 cyls
blocks = 39,053,983+
parted /dev/sda ? //help p //print the devices
//Note that if you mount the drive you'll have to unmount it to use ntfsresize ntfs-3g /dev/sda1 /mnt/windows
cd /mnt/windows
umount /mnt/windows